From 6b73b09f931a0642e9615380374178ce0784e240 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 27 Feb 2021 17:59:00 -0800 Subject: 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. --- lib/system.h | 9 +-------- paxlib/paxlib.h | 18 +++++++++--------- 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 -#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 #include @@ -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"); } } -- cgit v1.2.1