diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-02-27 17:59:00 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-02-27 17:59:27 -0800 |
commit | 6b73b09f931a0642e9615380374178ce0784e240 (patch) | |
tree | eb3591071797afc0c44ad32db725b9299098beec | |
parent | a3b0c7b919c1faf5d8797d1c26fd632823b7e54e (diff) | |
download | paxutils-6b73b09f931a0642e9615380374178ce0784e240.tar.gz |
Port better to non-GCC compilers
Gnulib now defines _Noreturn for us on pre-C11 compilers,
so use that instead of the less-portable __attribute__ ((noreturn)).
* lib/system.h (__attribute__): Remove; no longer used.
* paxlib/paxlib.h: Use _Noreturn instead of __attribute__ ((noreturn)).
* paxtest/paxtest.c (dump): First arg is char *,
not unsigned char *, to avoid type mismatch.
-rw-r--r-- | lib/system.h | 9 | ||||
-rw-r--r-- | paxlib/paxlib.h | 18 | ||||
-rw-r--r-- | paxtest/paxtest.c | 7 |
3 files changed, 15 insertions, 19 deletions
diff --git a/lib/system.h b/lib/system.h index 6f36684..1bd5ba9 100644 --- a/lib/system.h +++ b/lib/system.h @@ -23,13 +23,6 @@ #include <alloca.h> -#ifndef __attribute__ -/* This feature is available in gcc versions 2.5 and later. */ -# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__ -# define __attribute__(spec) /* empty */ -# endif -#endif - #include <sys/types.h> #include <ctype.h> @@ -483,7 +476,7 @@ sys_reset_uid_gid (void) struct passwd *pw; uid_t uid = getuid (); gid_t gid = getgid (); - + if ((pw = getpwuid (uid)) == NULL) { FATAL_ERROR ((0, errno, "%s(%lu)", "getpwuid", (unsigned long)uid)); diff --git a/paxlib/paxlib.h b/paxlib/paxlib.h index d4251d1..c6e8382 100644 --- a/paxlib/paxlib.h +++ b/paxlib/paxlib.h @@ -73,30 +73,30 @@ extern int exit_status; void pax_decode_mode (mode_t mode, char *string); void call_arg_error (char const *call, char const *name); -void call_arg_fatal (char const *call, char const *name) __attribute__ ((noreturn)); +_Noreturn void call_arg_fatal (char const *call, char const *name); void call_arg_warn (char const *call, char const *name); void chmod_error_details (char const *name, mode_t mode); void chown_error_details (char const *name, uid_t uid, gid_t gid); void decode_mode (mode_t, char *); -void chdir_fatal (char const *) __attribute__ ((noreturn)); +_Noreturn void chdir_fatal (char const *); void chmod_error_details (char const *, mode_t); void chown_error_details (char const *, uid_t, gid_t); void close_error (char const *); void close_warn (char const *); -void exec_fatal (char const *) __attribute__ ((noreturn)); +_Noreturn void exec_fatal (char const *); void link_error (char const *, char const *); void mkdir_error (char const *); void mkfifo_error (char const *); void mknod_error (char const *); void open_error (char const *); -void open_fatal (char const *) __attribute__ ((noreturn)); +_Noreturn void open_fatal (char const *); void open_warn (char const *); void read_error (char const *); void read_error_details (char const *, off_t, size_t); -void read_fatal (char const *) __attribute__ ((noreturn)); -void read_fatal_details (char const *, off_t, size_t) __attribute__ ((noreturn)); +_Noreturn void read_fatal (char const *); +_Noreturn void read_fatal_details (char const *, off_t, size_t); void read_warn_details (char const *, off_t, size_t); void readlink_error (char const *); void readlink_warn (char const *); @@ -107,7 +107,7 @@ void seek_error (char const *); void seek_error_details (char const *, off_t); void seek_warn (char const *); void seek_warn_details (char const *, off_t); -void stat_fatal (char const *) __attribute__ ((noreturn)); +_Noreturn void stat_fatal (char const *); void stat_error (char const *); void stat_warn (char const *); void symlink_error (char const *, char const *); @@ -119,8 +119,8 @@ void waitpid_error (char const *); void write_error (char const *); void write_error_details (char const *, size_t, size_t); -void pax_exit (void) __attribute__ ((noreturn)); -void fatal_exit (void) __attribute__ ((noreturn)); +_Noreturn void pax_exit (void); +_Noreturn void fatal_exit (void); #define STRINGIFY_BIGINT(i, b) umaxtostr (i, b) diff --git a/paxtest/paxtest.c b/paxtest/paxtest.c index bf839ac..5ba7ce9 100644 --- a/paxtest/paxtest.c +++ b/paxtest/paxtest.c @@ -43,13 +43,16 @@ fatal_exit (void) } void -dump (unsigned char *buf, size_t size) +dump (char *buf, size_t size) { while (size) { int i; for (i = 0; i < 16 && size; i++, size--, buf++) - printf ("%02X ", *buf); + { + unsigned char ch = *buf; + printf ("%02X ", ch); + } printf ("\n"); } } |