[libgsf] GsfOutputStdio: cleanup.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgsf] GsfOutputStdio: cleanup.
- Date: Mon, 7 Jan 2013 21:51:24 +0000 (UTC)
commit 82feb352c89746b0e182dcc361d0d2fa07f19dab
Author: Morten Welinder <terra gnome org>
Date: Mon Jan 7 16:50:41 2013 -0500
GsfOutputStdio: cleanup.
ChangeLog | 7 +++++++
NEWS | 2 ++
configure.in | 11 +++--------
gsf/gsf-output-stdio.c | 34 +++++++++++++---------------------
4 files changed, 25 insertions(+), 29 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8a99f36..890af73 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2013-01-07 Morten Welinder <terra gnome org>
+ * gsf/gsf-output-stdio.c (chown_wrapper): New function.
+ (chmod_wrapper, access_wrapper): Eliminate in favour of g_chmod
+ and g_access.
+
+ * configure.in: Check for g_chown instead of g_chmod and g_access
+ which we can now assume.
+
* gsf/gsf-infile-zip.c (zip_child_init): Attempt working around
another clang false positive.
diff --git a/NEWS b/NEWS
index d2e9b75..2a276f5 100644
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ Frob:
Morten:
* Deal with G_TYPE_CHAR signedness.
* Fix error handling of gsf_output_gio_new_for_uri.
+ * Clean out mistaken null checks from g_object_new.
+ * Clean out old glib tests.
Paolo Bonzini:
* Fix gsf_input_dep for msole streams. [#689706]
diff --git a/configure.in b/configure.in
index d2c7b2d..d23a18b 100644
--- a/configure.in
+++ b/configure.in
@@ -265,14 +265,9 @@ SAVE_LIBS=$LIBS
CFLAGS="$CFLAGS $LIBGSF_CFLAGS"
LIBS="$LIBGSF_LIBS $LIBS"
AC_CHECK_FUNCS(g_value_get_schar g_value_set_schar)
-AC_MSG_CHECKING([for g_chmod])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_chmod("/xxx",0777);]])],
- [AC_DEFINE(HAVE_G_CHMOD, 1, [Define if g_chmod is available as macro or function])
- AC_MSG_RESULT(yes)],
- [AC_MSG_RESULT(no)])
-AC_MSG_CHECKING([for g_access])
-AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_access("/xxx",0777);]])],
- [AC_DEFINE(HAVE_G_ACCESS, 1, [Define if g_access is available as macro or function])
+AC_MSG_CHECKING([for g_chown])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <glib/gstdio.h>]], [[(void)g_chown("/xxx",-1,-1);]])],
+ [AC_DEFINE(HAVE_G_CHOWN, 1, [Define if g_chown is available as macro or function])
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
CFLAGS=$SAVE_CFLAGS
diff --git a/gsf/gsf-output-stdio.c b/gsf/gsf-output-stdio.c
index 4eb8100..d9e4cdd 100644
--- a/gsf/gsf-output-stdio.c
+++ b/gsf/gsf-output-stdio.c
@@ -101,25 +101,17 @@ unlink_and_retry:
goto done;
}
+#ifdef HAVE_CHOWN
static int
-chmod_wrapper (const char *filename, mode_t mode)
+chown_wrapper (const char *filename, uid_t owner, gid_t group)
{
-#ifdef HAVE_G_CHMOD
- return g_chmod (filename, mode);
+#ifdef HAVE_G_CHOWN
+ return g_chown (filename, owner, group);
#else
- return chmod (filename, mode);
+ return chown (filename, owner, group);
#endif
}
-
-static int
-access_wrapper (char const *filename, int what)
-{
-#ifdef HAVE_G_ACCESS
- return g_access (filename, what);
-#else
- return access (filename, what);
#endif
-}
#define GSF_MAX_LINK_LEVEL 256
@@ -268,16 +260,16 @@ gsf_output_stdio_close (GsfOutput *output)
* can do here, I'm afraid. The final data is saved anyways.
* Note the order: mode, uid+gid, gid, uid, mode.
*/
- chmod_wrapper (stdio->real_filename, stdio->st.st_mode);
+ g_chmod (stdio->real_filename, stdio->st.st_mode);
#ifdef HAVE_CHOWN
- if (chown (stdio->real_filename,
- stdio->st.st_uid,
- stdio->st.st_gid)) {
+ if (chown_wrapper (stdio->real_filename,
+ stdio->st.st_uid,
+ stdio->st.st_gid)) {
/* We cannot set both. Maybe we can set one. */
- chown (stdio->real_filename, -1, stdio->st.st_gid);
- chown (stdio->real_filename, stdio->st.st_uid, -1);
+ chown_wrapper (stdio->real_filename, -1, stdio->st.st_gid);
+ chown_wrapper (stdio->real_filename, stdio->st.st_uid, -1);
}
- chmod_wrapper (stdio->real_filename, stdio->st.st_mode);
+ g_chmod (stdio->real_filename, stdio->st.st_mode);
#endif
}
@@ -442,7 +434,7 @@ gsf_output_stdio_new_valist (char const *filename, GError **err,
}
/* FIXME? Race conditions en masse. */
- if (access_wrapper (real_filename, W_OK) == -1) {
+ if (g_access (real_filename, W_OK) == -1) {
if (err != NULL) {
int save_errno = errno;
char *dname = g_filename_display_name
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]