[vte/vte-0-34] [stream] Use -1, not 0, as "not opened yet"
- From: Behdad Esfahbod <behdad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vte/vte-0-34] [stream] Use -1, not 0, as "not opened yet"
- Date: Mon, 30 Sep 2013 00:32:09 +0000 (UTC)
commit 2cf872c90d85163f297e3a0fd56866a29849e0bf
Author: Behdad Esfahbod <behdad behdad org>
Date: Sun Sep 29 20:13:45 2013 -0400
[stream] Use -1, not 0, as "not opened yet"
As suggested by ChPe.
src/vtestream-file.h | 9 +++++----
src/vteutils.c | 9 ---------
2 files changed, 5 insertions(+), 13 deletions(-)
---
diff --git a/src/vtestream-file.h b/src/vtestream-file.h
index 0badb31..88985fa 100644
--- a/src/vtestream-file.h
+++ b/src/vtestream-file.h
@@ -145,8 +145,9 @@ static GType _vte_file_stream_get_type (void);
G_DEFINE_TYPE (VteFileStream, _vte_file_stream, VTE_TYPE_STREAM)
static void
-_vte_file_stream_init (VteFileStream *stream G_GNUC_UNUSED)
+_vte_file_stream_init (VteFileStream *stream)
{
+ stream->fd[0] = stream->fd[1] = -1;
}
VteStream *
@@ -160,8 +161,8 @@ _vte_file_stream_finalize (GObject *object)
{
VteFileStream *stream = (VteFileStream *) object;
- if (stream->fd[0]) close (stream->fd[0]);
- if (stream->fd[1]) close (stream->fd[1]);
+ if (stream->fd[0] != -1) close (stream->fd[0]);
+ if (stream->fd[1] != -1) close (stream->fd[1]);
G_OBJECT_CLASS (_vte_file_stream_parent_class)->finalize(object);
}
@@ -171,7 +172,7 @@ _vte_file_stream_ensure_fd0 (VteFileStream *stream)
{
gint fd;
- if (G_LIKELY (stream->fd[0]))
+ if (G_LIKELY (stream->fd[0] != -1))
return;
fd = _vte_mkstemp ();
diff --git a/src/vteutils.c b/src/vteutils.c
index 7615f51..feea47e 100644
--- a/src/vteutils.c
+++ b/src/vteutils.c
@@ -73,14 +73,5 @@ _vte_mkstemp (void)
done:
#endif
- /* make sure fd is not 0 */
- if (G_UNLIKELY (fd == 0)) {
- int new_fd;
-
- new_fd = dup (fd);
- close (fd);
- fd = new_fd;
- }
-
return fd;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]