From: Emil Velikov Date: Fri, 8 Dec 2023 03:22:27 +0000 (+0000) Subject: Minor __LA_NORETURN inspired fixes (#2028) X-Git-Tag: v3.7.3~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5713db2d4eaeac636ca243507921903d9fd59e7;p=thirdparty%2Flibarchive.git Minor __LA_NORETURN inspired fixes (#2028) Earlier MR https://github.com/libarchive/libarchive/pull/2000 forgot to annotate some functions as __LA_NORETURN. While fixing that I've noticed that the bsdcat.h header could use some fixes so I've snuck those in. Kind of make sense to group in one PR, but can split people prefer so. /cc @AtariDreams fyi --------- Signed-off-by: Emil Velikov --- diff --git a/cat/bsdcat.c b/cat/bsdcat.c index 42a93aa56..19d3de65c 100644 --- a/cat/bsdcat.c +++ b/cat/bsdcat.c @@ -36,6 +36,9 @@ #include #endif +#include +#include + #include "bsdcat.h" #include "err.h" @@ -47,7 +50,7 @@ static const char *bsdcat_current_path; static int exit_status = 0; -void +static __LA_NORETURN void usage(FILE *stream, int eval) { const char *p; @@ -57,7 +60,7 @@ usage(FILE *stream, int eval) exit(eval); } -static void +static __LA_NORETURN void version(void) { printf("bsdcat %s - %s \n", @@ -66,7 +69,15 @@ version(void) exit(0); } -void +static void +bsdcat_print_error(void) +{ + lafe_warnc(0, "%s: %s", + bsdcat_current_path, archive_error_string(a)); + exit_status = 1; +} + +static void bsdcat_next(void) { if (a != NULL) { @@ -81,15 +92,7 @@ bsdcat_next(void) archive_read_support_format_raw(a); } -void -bsdcat_print_error(void) -{ - lafe_warnc(0, "%s: %s", - bsdcat_current_path, archive_error_string(a)); - exit_status = 1; -} - -void +static void bsdcat_read_to_stdout(const char* filename) { int r; diff --git a/cat/bsdcat.h b/cat/bsdcat.h index 6467d6e3d..504757a44 100644 --- a/cat/bsdcat.h +++ b/cat/bsdcat.h @@ -34,9 +34,6 @@ #include "config.h" #endif -#include -#include - struct bsdcat { /* Option parser state */ int getopt_state; @@ -53,9 +50,5 @@ enum { }; int bsdcat_getopt(struct bsdcat *); -void usage(FILE *stream, int eval); -void bsdcat_next(void); -void bsdcat_print_error(void); -void bsdcat_read_to_stdout(const char* filename); #endif diff --git a/cpio/cpio.c b/cpio/cpio.c index d510c4811..c9af535f6 100644 --- a/cpio/cpio.c +++ b/cpio/cpio.c @@ -107,22 +107,22 @@ static int entry_to_archive(struct cpio *, struct archive_entry *); static int file_to_archive(struct cpio *, const char *); static void free_cache(struct name_cache *cache); static void list_item_verbose(struct cpio *, struct archive_entry *); -static void long_help(void) __LA_NORETURN; +static __LA_NORETURN void long_help(void); static const char *lookup_gname(struct cpio *, gid_t gid); static int lookup_gname_helper(struct cpio *, const char **name, id_t gid); static const char *lookup_uname(struct cpio *, uid_t uid); static int lookup_uname_helper(struct cpio *, const char **name, id_t uid); -static void mode_in(struct cpio *) __LA_NORETURN; -static void mode_list(struct cpio *) __LA_NORETURN; +static __LA_NORETURN void mode_in(struct cpio *); +static __LA_NORETURN void mode_list(struct cpio *); static void mode_out(struct cpio *); static void mode_pass(struct cpio *, const char *); static const char *remove_leading_slash(const char *); static int restore_time(struct cpio *, struct archive_entry *, const char *, int fd); -static void usage(void) __LA_NORETURN; -static void version(void) __LA_NORETURN; +static __LA_NORETURN void usage(void); +static __LA_NORETURN void version(void); static const char * passphrase_callback(struct archive *, void *); static void passphrase_free(char *); diff --git a/libarchive/archive_private.h b/libarchive/archive_private.h index 41f40e876..0f05169b7 100644 --- a/libarchive/archive_private.h +++ b/libarchive/archive_private.h @@ -153,7 +153,7 @@ int __archive_check_magic(struct archive *, unsigned int magic, return ARCHIVE_FATAL; \ } while (0) -void __archive_errx(int retvalue, const char *msg) __LA_NORETURN; +__LA_NORETURN void __archive_errx(int retvalue, const char *msg); void __archive_ensure_cloexec_flag(int fd); int __archive_mktemp(const char *tmpdir); diff --git a/libarchive_fe/err.h b/libarchive_fe/err.h index e1af236b6..bd9281539 100644 --- a/libarchive_fe/err.h +++ b/libarchive_fe/err.h @@ -48,8 +48,7 @@ #endif void lafe_warnc(int code, const char *fmt, ...) __LA_PRINTFLIKE(2, 3); -void lafe_errc(int eval, int code, const char *fmt, ...) __LA_NORETURN - __LA_PRINTFLIKE(3, 4); +__LA_NORETURN void lafe_errc(int eval, int code, const char *fmt, ...) __LA_PRINTFLIKE(3, 4); const char * lafe_getprogname(void); void lafe_setprogname(const char *name, const char *defaultname); diff --git a/tar/bsdtar.c b/tar/bsdtar.c index 87544dc65..d50ebd20b 100644 --- a/tar/bsdtar.c +++ b/tar/bsdtar.c @@ -113,11 +113,11 @@ need_report(void) } #endif -static void long_help(void) __LA_NORETURN; +static __LA_NORETURN void long_help(void); static void only_mode(struct bsdtar *, const char *opt, const char *valid); static void set_mode(struct bsdtar *, char opt); -static void version(void) __LA_NORETURN; +static __LA_NORETURN void version(void); /* A basic set of security flags to request from libarchive. */ #define SECURITY \ diff --git a/tar/bsdtar.h b/tar/bsdtar.h index ea6e131f1..ee7884f46 100644 --- a/tar/bsdtar.h +++ b/tar/bsdtar.h @@ -206,7 +206,7 @@ void tar_mode_r(struct bsdtar *bsdtar); void tar_mode_t(struct bsdtar *bsdtar); void tar_mode_u(struct bsdtar *bsdtar); void tar_mode_x(struct bsdtar *bsdtar); -void usage(void) __LA_NORETURN; +__LA_NORETURN void usage(void); int yes(const char *fmt, ...) __LA_PRINTF(1, 2); #if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)