diff options
author | Colin Walters <walters@verbum.org> | 2013-01-04 17:15:17 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2013-01-04 17:17:02 -0500 |
commit | 6c736d9309d5ffbc60ed0a58e21f0f8ad609ba10 (patch) | |
tree | 2fe6a9675a934c403e2c7dace8f4ccb64a11228d | |
parent | 660aa3e43f53d272508fc8fcd3eef62b426c59ae (diff) | |
download | libgsystem-6c736d9309d5ffbc60ed0a58e21f0f8ad609ba10.tar.gz |
fileutils: Code cleanup for close() invocations
Naming is similar to systemd's internals.
-rw-r--r-- | 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; } |