[libgsystem] fileutils: Code cleanup for close() invocations
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsystem] fileutils: Code cleanup for close() invocations
- Date: Fri, 4 Jan 2013 22:17:16 +0000 (UTC)
commit 6c736d9309d5ffbc60ed0a58e21f0f8ad609ba10
Author: Colin Walters <walters verbum org>
Date: Fri Jan 4 17:15:17 2013 -0500
fileutils: Code cleanup for close() invocations
Naming is similar to systemd's internals.
gsystem-file-utils.c | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/gsystem-file-utils.c b/gsystem-file-utils.c
index 5e70c34..83b542e 100644
--- a/gsystem-file-utils.c
+++ b/gsystem-file-utils.c
@@ -29,7 +29,23 @@
#include <glib/gstdio.h>
#include <gio/gunixinputstream.h>
#include <glib-unix.h>
-
+
+static int
+close_nointr (int fd)
+{
+ int res;
+ do
+ res = close (fd);
+ while (G_UNLIKELY (res != 0 && errno == EINTR));
+ return res;
+}
+
+static void
+close_nointr_noerror (int fd)
+{
+ (void) close_nointr (fd);
+}
+
static int
_open_fd_noatime (const char *path)
{
@@ -123,7 +139,7 @@ gs_file_map_noatime (GFile *file,
}
ret = g_mapped_file_new_from_fd (fd, FALSE, error);
- (void) close (fd); /* Ignore errors - we always want to close */
+ close_nointr_noerror (fd); /* Ignore errors - we always want to close */
return ret;
}
@@ -159,16 +175,6 @@ gs_file_map_readonly (GFile *file,
return ret;
}
-static int
-close_nointr (int fd)
-{
- int res;
- do
- res = close (fd);
- while (G_UNLIKELY (res != 0 && errno == EINTR));
- return res;
-}
-
/**
* gs_file_sync_data:
* @file: a #GFile
@@ -220,7 +226,7 @@ gs_file_sync_data (GFile *file,
ret = TRUE;
out:
if (fd != -1)
- (void) close_nointr (fd);
+ close_nointr_noerror (fd);
return ret;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]