OK to commit these cleanups? Maybe we should push on Bruno to add ENODATA to gnulib's <errno.h> replacement, particularly since you are now considering using ENODATA for SELinux errors. While the system.h version allows compilation, it would be better to have a dedicated errno rather than -1, as well as strerror support, if some other platform happens to encounter the SELinux path that sets ENODATA. gmane probably wrapped long lines :(
>From 69b7a7ab900a043d6330b400659fb69a1aedde8e Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Thu, 8 Oct 2009 08:13:02 -0600 Subject: [PATCH 1/3] maint: move timeout exit statuses * src/timeout.c (EXIT_TIMEDOUT, EXIT_CANCELED): Remove as macros... * src/system.h (EXIT_TIMEDOUT, EXIT_CANCELED): ...and provide as enum values instead. --- src/system.h | 2 ++ src/timeout.c | 6 ------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/system.h b/src/system.h index ce71148..102b93d 100644 --- a/src/system.h +++ b/src/system.h @@ -107,6 +107,8 @@ you must include <sys/types.h> before including this file /* Exit statuses for programs like 'env' that exec other programs. */ enum { + EXIT_TIMEDOUT = 124, + EXIT_CANCELED = 125, EXIT_CANNOT_INVOKE = 126, EXIT_ENOENT = 127 }; diff --git a/src/timeout.c b/src/timeout.c index 7069f2c..7b0f1d7 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -73,12 +73,6 @@ #define AUTHORS proper_name_utf8 ("Padraig Brady", "P\303\241draig Brady") -/* Note ETIMEDOUT is 110 on GNU/Linux systems but this is non standard */ -#define EXIT_TIMEDOUT 124 - -/* Internal failure. */ -#define EXIT_CANCELED 125 - static int timed_out; static int term_signal = SIGTERM; /* same default as kill command. */ static int monitored_pid; -- 1.6.4.2 >From 3fe95b8d5294df9747982cc6e41a6adb621450a0 Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Thu, 8 Oct 2009 08:10:50 -0600 Subject: [PATCH 2/3] maint: remove unused macros and declarations * src/system.h (strdupa): Delete unused macro. (EDQUOT, EISDIR, ENOSYS, EOVERFLOW, F_OK, X_OK, W_OK, R_OK): Delete; macros provided by gnulib. (includes): Gnulib guarantees both <time.h> and <sys/time.h>, in either order. (free, malloc, memchr, realloc, getenv, lseek): Delete, gnulib guarantees these declarations. * m4/check-decl.m4 (gl_CHECK_DECLS): Delete checks now done by gnulib. --- m4/check-decl.m4 | 8 +----- src/system.h | 74 +++--------------------------------------------------- 2 files changed, 5 insertions(+), 77 deletions(-) diff --git a/m4/check-decl.m4 b/m4/check-decl.m4 index d1a520a..530c59e 100644 --- a/m4/check-decl.m4 +++ b/m4/check-decl.m4 @@ -1,4 +1,4 @@ -#serial 24 +#serial 25 # Check declarations for this package. dnl Copyright (C) 1997-2001, 2003-2006, 2008-2009 Free Software @@ -37,13 +37,7 @@ AC_DEFUN([gl_CHECK_DECLS], AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>]) - AC_CHECK_DECLS_ONCE([free]) - AC_CHECK_DECLS_ONCE([getenv]) AC_CHECK_DECLS_ONCE([geteuid]) AC_CHECK_DECLS_ONCE([getlogin]) AC_CHECK_DECLS_ONCE([getuid]) - AC_CHECK_DECLS_ONCE([lseek]) - AC_CHECK_DECLS_ONCE([malloc]) - AC_CHECK_DECLS_ONCE([memchr]) - AC_CHECK_DECLS_ONCE([realloc]) ]) diff --git a/src/system.h b/src/system.h index 102b93d..976e4ac 100644 --- a/src/system.h +++ b/src/system.h @@ -44,16 +44,8 @@ you must include <sys/types.h> before including this file #include "configmake.h" -#if TIME_WITH_SYS_TIME -# include <sys/time.h> -# include <time.h> -#else -# if HAVE_SYS_TIME_H -# include <sys/time.h> -# else -# include <time.h> -# endif -#endif +#include <sys/time.h> +#include <time.h> /* Since major is a function on SVR4, we can't use `ifndef major'. */ #if MAJOR_IN_MKDEV @@ -86,16 +78,8 @@ you must include <sys/types.h> before including this file #include <errno.h> -/* Some systems don't define the following symbols. */ -#ifndef EDQUOT -# define EDQUOT (-1) -#endif -#ifndef EISDIR -# define EISDIR (-1) -#endif -#ifndef ENOSYS -# define ENOSYS (-1) -#endif +/* Some systems don't define this; POSIX mentions it but says it is + obsolete, so gnulib does not provide it either. */ #ifndef ENODATA # define ENODATA (-1) #endif @@ -125,13 +109,6 @@ initialize_exit_failure (int status) #include <fcntl.h> -#ifndef F_OK -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 -#endif - #include <dirent.h> #ifndef _D_EXACT_NAMLEN # define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name) @@ -281,30 +258,6 @@ select_plural (uintmax_t n) #define STREQ(a, b) (strcmp (a, b) == 0) -#if !HAVE_DECL_FREE -void free (); -#endif - -#if !HAVE_DECL_MALLOC -char *malloc (); -#endif - -#if !HAVE_DECL_MEMCHR -char *memchr (); -#endif - -#if !HAVE_DECL_REALLOC -char *realloc (); -#endif - -#if !HAVE_DECL_GETENV -char *getenv (); -#endif - -#if !HAVE_DECL_LSEEK -off_t lseek (); -#endif - #if !HAVE_DECL_GETLOGIN char *getlogin (); #endif @@ -534,25 +487,6 @@ enum # define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) #endif -#if defined strdupa -# define ASSIGN_STRDUPA(DEST, S) \ - do { DEST = strdupa (S); } while (0) -#else -# define ASSIGN_STRDUPA(DEST, S) \ - do \ - { \ - const char *s_ = (S); \ - size_t len_ = strlen (s_) + 1; \ - char *tmp_dest_ = alloca (len_); \ - DEST = memcpy (tmp_dest_, s_, len_); \ - } \ - while (0) -#endif - -#ifndef EOVERFLOW -# define EOVERFLOW EINVAL -#endif - #if ! HAVE_SYNC # define sync() /* empty */ #endif -- 1.6.4.2 >From cb1d20e5764917ce16d7ba970061c5c3a591097c Mon Sep 17 00:00:00 2001 From: Eric Blake <[email protected]> Date: Thu, 8 Oct 2009 08:35:55 -0600 Subject: [PATCH 3/3] maint: use X2NREALLOC in more places * src/chroot.c (set_additional_groups): Use X2NREALLOC rather than x2nrealloc. * src/factor.c (emit_factor): Likewise. * src/setuidgid.c (main): Likewise. --- src/chroot.c | 2 +- src/factor.c | 2 +- src/setuidgid.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/chroot.c b/src/chroot.c index 5e8cb9c..9269f1b 100644 --- a/src/chroot.c +++ b/src/chroot.c @@ -91,7 +91,7 @@ set_additional_groups (char const *groups) } if (n_gids == n_gids_allocated) - gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids); + gids = X2NREALLOC (gids, &n_gids_allocated); gids[n_gids++] = value; } diff --git a/src/factor.c b/src/factor.c index f48a720..38c9a11 100644 --- a/src/factor.c +++ b/src/factor.c @@ -67,7 +67,7 @@ static void emit_factor (mpz_t n) { if (nfactors_found == nfactors_allocated) - factor = x2nrealloc (factor, &nfactors_allocated, sizeof *factor); + factor = X2NREALLOC (factor, &nfactors_allocated); mpz_init (factor[nfactors_found]); mpz_set (factor[nfactors_found], n); ++nfactors_found; diff --git a/src/setuidgid.c b/src/setuidgid.c index 7176b1a..34be515 100644 --- a/src/setuidgid.c +++ b/src/setuidgid.c @@ -110,7 +110,7 @@ main (int argc, char **argv) error (EXIT_FAILURE, 0, _("invalid group %s"), quote (gr)); if (n_gids == n_gids_allocated) - gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids); + gids = X2NREALLOC (gids, &n_gids_allocated); gids[n_gids++] = tmp_ul; if (*ptr == '\0') -- 1.6.4.2
