[easytag] Use g_close() instead of close()
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Use g_close() instead of close()
- Date: Tue, 19 Jan 2016 17:33:28 +0000 (UTC)
commit 99890b917c6ce9814cdc7361d3ad951fc3216973
Author: David King <amigadave amigadave com>
Date: Tue Jan 19 16:48:10 2016 +0000
Use g_close() instead of close()
Available since GLib 2.36, g_close() provides a portable wrapper around
close().
src/browser.c | 3 ++-
src/misc.c | 4 +++-
tests/test-misc.c | 9 ++++++---
3 files changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/browser.c b/src/browser.c
index 4c6aa36..e01fef2 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -4335,7 +4335,8 @@ Rename_Directory (EtBrowser *self)
if ( (fd_tmp = mkstemp(tmp_path)) >= 0 )
{
- close(fd_tmp);
+ /* TODO: handle error. */
+ g_close (fd_tmp, NULL);
g_unlink (tmp_path);
}
diff --git a/src/misc.c b/src/misc.c
index f5e5f37..e5b069e 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -22,6 +22,7 @@
#include "misc.h"
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -435,7 +436,8 @@ et_rename_file (const char *old_filepath,
if (fd >= 0)
{
- close (fd);
+ /* TODO: Handle error. */
+ g_close (fd, NULL);
}
tmp_file = g_file_new_for_path (tmp_filename);
diff --git a/tests/test-misc.c b/tests/test-misc.c
index 724dd33..3cecb28 100644
--- a/tests/test-misc.c
+++ b/tests/test-misc.c
@@ -134,8 +134,10 @@ misc_rename_file (void)
g_assert_no_error (error1);
g_assert_no_error (error2);
- close (fd1);
- close (fd2);
+ g_close (fd1, error1);
+ g_close (fd2, error2);
+ g_assert_no_error (error1);
+ g_assert_no_error (error2);
/* Renaming to an existing filename should fail. */
et_rename_file (filename1, filename2, &error1);
@@ -149,7 +151,8 @@ misc_rename_file (void)
fd3 = g_file_open_tmp ("EasyTAG-test3.XXXXXX", &filename3, &error3);
g_assert_no_error (error3);
- close (fd3);
+ g_close (fd3, error3);
+ g_assert_no_error (error3);
g_assert_cmpint (g_unlink (filename3), ==, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]