]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Minor __LA_NORETURN inspired fixes (#2028)
authorEmil Velikov <emil.l.velikov@gmail.com>
Fri, 8 Dec 2023 03:22:27 +0000 (03:22 +0000)
committerGitHub <noreply@github.com>
Fri, 8 Dec 2023 03:22:27 +0000 (19:22 -0800)
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 <emil.l.velikov@gmail.com>
cat/bsdcat.c
cat/bsdcat.h
cpio/cpio.c
libarchive/archive_private.h
libarchive_fe/err.h
tar/bsdtar.c
tar/bsdtar.h

index 42a93aa56b6fcc94522517e0ac43f04f19166c6d..19d3de65cea425562ab841406144c5a3359bd0ac 100644 (file)
@@ -36,6 +36,9 @@
 #include <string.h>
 #endif
 
+#include <archive.h>
+#include <archive_entry.h>
+
 #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;
index 6467d6e3d310d4dc0fd154a404e277e32277c396..504757a44040d5b97a6fedff55924cbf7518d226 100644 (file)
@@ -34,9 +34,6 @@
 #include "config.h"
 #endif
 
-#include <archive.h>
-#include <archive_entry.h>
-
 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
index d510c481165d2e2779f7d0578ea563b1385d9c7b..c9af535f6d0a3f90ca3b3140a46f4af753cb233b 100644 (file)
@@ -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 *);
 
index 41f40e8765256b85b6a9bb0c4eee7b15bf8153c6..0f05169b7d25b26169657af4bfcef8689a8abf09 100644 (file)
@@ -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);
index e1af236b6683b85d47328102a96bb7758f323336..bd9281539693c5b48d8ab90d773bf80961681772 100644 (file)
@@ -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);
index 87544dc6556703c505a1803b346d74dd141d9823..d50ebd20bd1c71a32fd222293b8f23ad3c92504a 100644 (file)
@@ -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                                        \
index ea6e131f17c5dcb9d9b9af3101538a6b51817e80..ee7884f4666f5e4cc488a0ed9153570494b5b726 100644 (file)
@@ -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)