[vte] pty: Small code cleanup
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte] pty: Small code cleanup
- Date: Sun, 29 Nov 2015 19:58:47 +0000 (UTC)
commit c7071e819b20f22cf4ec2b7abe6da1f49c6ceaed
Author: Christian Persch <chpe gnome org>
Date: Sun Nov 29 20:57:55 2015 +0100
pty: Small code cleanup
Just put the code at the only call site instead of in a separate function.
https://bugzilla.gnome.org/show_bug.cgi?id=747046
src/pty.cc | 44 ++++++++++++--------------------------------
1 files changed, 12 insertions(+), 32 deletions(-)
---
diff --git a/src/pty.cc b/src/pty.cc
index e6bdc05..cbdebba 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -636,17 +636,21 @@ fd_set_nonblock(int fd,
}
/*
- * _vte_pty_getpt:
+ * _vte_pty_open_unix98:
+ * @pty: a #VtePty
* @error: a location to store a #GError, or %NULL
*
- * Opens a file descriptor for the next available PTY master.
- * Sets the descriptor to blocking mode!
+ * Opens a new file descriptor to a new PTY master.
*
- * Returns: a new file descriptor, or %-1 on failure
+ * Returns: %TRUE on success, %FALSE on failure with @error filled in
*/
-static int
-_vte_pty_getpt(GError **error)
+static gboolean
+_vte_pty_open_unix98(VtePty *pty,
+ GError **error)
{
+ VtePtyPrivate *priv = pty->priv;
+
+ /* Attempt to open the master. */
int fd = posix_openpt(O_RDWR | O_NOCTTY | O_CLOEXEC);
if (fd == -1 && errno == EINVAL) {
/* Try without CLOEXEC and apply the flag afterwards */
@@ -693,32 +697,6 @@ _vte_pty_getpt(GError **error)
return -1;
}
- return fd;
-}
-
-/*
- * _vte_pty_open_unix98:
- * @pty: a #VtePty
- * @error: a location to store a #GError, or %NULL
- *
- * Opens a new file descriptor to a new PTY master.
- *
- * Returns: %TRUE on success, %FALSE on failure with @error filled in
- */
-static gboolean
-_vte_pty_open_unix98(VtePty *pty,
- GError **error)
-{
- VtePtyPrivate *priv = pty->priv;
- int fd;
-
- /* Attempt to open the master. */
- fd = _vte_pty_getpt(error);
- if (fd == -1)
- return FALSE;
-
- _vte_debug_print(VTE_DEBUG_PTY, "Allocated pty on fd %d.\n", fd);
-
/* Read the slave number and unlock it. */
if (grantpt(fd) != 0) {
int errsv = errno;
@@ -738,6 +716,8 @@ _vte_pty_open_unix98(VtePty *pty,
return FALSE;
}
+ _vte_debug_print(VTE_DEBUG_PTY, "Allocated pty on fd %d.\n", fd);
+
priv->pty_fd = fd;
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]