]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Replace __LA_DEAD with __LA_NORETURN (#2000)
authorAtariDreams <83477269+AtariDreams@users.noreply.github.com>
Mon, 4 Dec 2023 16:29:29 +0000 (11:29 -0500)
committerGitHub <noreply@github.com>
Mon, 4 Dec 2023 16:29:29 +0000 (08:29 -0800)
Also add the MSC_VER version of the macro.

15 files changed:
cat/bsdcat.c
cat/bsdcat_platform.h
cpio/cpio.c
cpio/cpio_platform.h
libarchive/archive_check_magic.c
libarchive/archive_private.h
libarchive_fe/err.h
libarchive_fe/passphrase.c
tar/bsdtar.c
tar/bsdtar.h
tar/bsdtar_platform.h
tar/subst.c
test_utils/test_main.c
unzip/bsdunzip.c
unzip/bsdunzip_platform.h

index 69fa06fdf159e27899494f62ecdf4199f8a9e26d..42a93aa56b6fcc94522517e0ac43f04f19166c6d 100644 (file)
@@ -129,12 +129,16 @@ main(int argc, char **argv)
                switch (c) {
                case 'h':
                        usage(stdout, 0);
-                       break;
+                       /* NOTREACHED */
+                       /* Fallthrough */
                case OPTION_VERSION:
                        version();
-                       break;
+                       /* NOTREACHED */
+                       /* Fallthrough */
                default:
                        usage(stderr, 1);
+                       /* Fallthrough */
+                       /* NOTREACHED */
                }
        }
 
index 5b58cd7ee761c0c9105515e5297e900723362cb9..78a6113e6f01e3ea93fc3e655c3d2f416e82c45a 100644 (file)
 
 /* How to mark functions that don't return. */
 /* This facilitates use of some newer static code analysis tools. */
-#undef __LA_DEAD
+#undef __LA_NORETURN
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
-                         (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define        __LA_DEAD       __attribute__((__noreturn__))
-#else
-#define        __LA_DEAD
+                          (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_NORETURN       __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#define __LA_NORETURN __declspec(noreturn)
+#else 
+#define __LA_NORETURN
 #endif
 
 #endif /* !BSDCAT_PLATFORM_H_INCLUDED */
index cf68029ad420be5b05d9bb268f4326c6b32377af..d510c481165d2e2779f7d0578ea563b1385d9c7b 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_DEAD;
+static void    long_help(void) __LA_NORETURN;
 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_DEAD;
-static void    mode_list(struct cpio *) __LA_DEAD;
+static void    mode_in(struct cpio *) __LA_NORETURN;
+static void    mode_list(struct cpio *) __LA_NORETURN;
 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_DEAD;
-static void    version(void) __LA_DEAD;
+static void    usage(void) __LA_NORETURN;
+static void    version(void) __LA_NORETURN;
 static const char * passphrase_callback(struct archive *, void *);
 static void    passphrase_free(char *);
 
@@ -250,7 +250,7 @@ main(int argc, char *argv[])
                        break;
                case 'h':
                        long_help();
-                       break;
+                       /* NOTREACHED */
                case 'I': /* NetBSD/OpenBSD */
                        cpio->filename = cpio->argument;
                        break;
@@ -357,7 +357,7 @@ main(int argc, char *argv[])
                        break;
                case OPTION_VERSION: /* GNU convention */
                        version();
-                       break;
+                       /* NOTREACHED */
 #if 0
                /*
                 * cpio_getopt() handles -W specially, so it's not
@@ -426,7 +426,7 @@ main(int argc, char *argv[])
                        mode_list(cpio);
                else
                        mode_in(cpio);
-               break;
+               /* NOTREACHED */
        case 'p':
                if (*cpio->argv == NULL || **cpio->argv == '\0')
                        lafe_errc(1, 0,
index 9cb577b82ba30f6bf483ee40dafa142dce958113..263404b40dab40f998a3f7db2aa106f406a8ee29 100644 (file)
 /* How to mark functions that don't return. */
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
                           (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define __LA_DEAD       __attribute__((__noreturn__))
+#define __LA_NORETURN __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#define __LA_NORETURN __declspec(noreturn)
 #else
-#define __LA_DEAD
+#define __LA_NORETURN
 #endif
 
 #endif /* !CPIO_PLATFORM_H_INCLUDED */
index f31f6a50135a355a5af9fb6d508c6824e3556ce9..24dc6c50540ee58faf30a93b274dd03287242a87 100644 (file)
@@ -61,7 +61,7 @@ errmsg(const char *m)
        }
 }
 
-static __LA_DEAD void
+static __LA_NORETURN void
 diediedie(void)
 {
 #if defined(_WIN32) && !defined(__CYGWIN__) && defined(_DEBUG)
index b0096c0358d7e40b338f05e37a76a19b04c8e2be..41f40e8765256b85b6a9bb0c4eee7b15bf8153c6 100644 (file)
 #include "archive_string.h"
 
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
-                         (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define        __LA_DEAD       __attribute__((__noreturn__))
+                                                 (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_NORETURN __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#define __LA_NORETURN __declspec(noreturn)
 #else
-#define        __LA_DEAD
+#define __LA_NORETURN
 #endif
 
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
@@ -151,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_DEAD;
+void   __archive_errx(int retvalue, const char *msg) __LA_NORETURN;
 
 void   __archive_ensure_cloexec_flag(int fd);
 int    __archive_mktemp(const char *tmpdir);
index c663103b0b44ef4773c77322567a39a8c8977bc9..e1af236b6683b85d47328102a96bb7758f323336 100644 (file)
 #define LAFE_ERR_H
 
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
-                          (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define __LA_DEAD       __attribute__((__noreturn__))
+                                                 (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_NORETURN __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#define __LA_NORETURN __declspec(noreturn)
 #else
-#define __LA_DEAD
+#define __LA_NORETURN
 #endif
 
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
@@ -46,7 +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_DEAD
+void   lafe_errc(int eval, int code, const char *fmt, ...) __LA_NORETURN
                  __LA_PRINTFLIKE(3, 4);
 
 const char *   lafe_getprogname(void);
index b6dff48672a21a20df11570ecb38d7ae9b18919b..9d95d527067bb1815dfd83758e2558d30f96eb21 100644 (file)
@@ -329,7 +329,7 @@ lafe_readpassphrase(const char *prompt, char *buf, size_t bufsiz)
                        break;
                default:
                        lafe_errc(1, errno, "Couldn't read passphrase");
-                       break;
+                       /* NOTREACHED */
                }
        }
        return (p);
index 60cb6bad98c8f91fcb28d16c6345a8bc0c33cdd3..87544dc6556703c505a1803b346d74dd141d9823 100644 (file)
@@ -113,11 +113,11 @@ need_report(void)
 }
 #endif
 
-static void             long_help(void) __LA_DEAD;
+static void             long_help(void) __LA_NORETURN;
 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_DEAD;
+static void             version(void) __LA_NORETURN;
 
 /* A basic set of security flags to request from libarchive. */
 #define        SECURITY                                        \
@@ -399,8 +399,7 @@ main(int argc, char **argv)
                        break;
                case OPTION_HELP: /* GNU tar, others */
                        long_help();
-                       exit(0);
-                       break;
+                       /* NOTREACHED*/
                case OPTION_HFS_COMPRESSION: /* Mac OS X v10.6 or later */
                        bsdtar->extract_flags |=
                            ARCHIVE_EXTRACT_HFS_COMPRESSION_FORCED;
@@ -737,7 +736,7 @@ main(int argc, char **argv)
                        break;
                case OPTION_VERSION: /* GNU convention */
                        version();
-                       break;
+                       /* NOTREACHED */
 #if 0
                /*
                 * The -W longopt feature is handled inside of
@@ -803,7 +802,6 @@ main(int argc, char **argv)
        /* If no "real" mode was specified, treat -h as --help. */
        if ((bsdtar->mode == '\0') && possible_help_request) {
                long_help();
-               exit(0);
        }
 
        /* Otherwise, a mode is required. */
index 4f9378f821d18668d576bfdd0a865d66321d0950..ea6e131f17c5dcb9d9b9af3101538a6b51817e80 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_DEAD;
+void   usage(void) __LA_NORETURN;
 int    yes(const char *fmt, ...) __LA_PRINTF(1, 2);
 
 #if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H)
index 04cb752e9d9fcb1d9eec534927d1cb8a9223c25b..a4f37d95e9b3cc377c8600b630b4f7ca40dee5ef 100644 (file)
 
 /* How to mark functions that don't return. */
 /* This facilitates use of some newer static code analysis tools. */
-#undef __LA_DEAD
+#undef __LA_NORETURN
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
-                         (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define        __LA_DEAD       __attribute__((__noreturn__))
-#else
-#define        __LA_DEAD
+                          (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_NORETURN       __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#define __LA_NORETURN __declspec(noreturn)
+#else 
+#define __LA_NORETURN
 #endif
 
 #endif /* !BSDTAR_PLATFORM_H_INCLUDED */
index 3322245c1bd68c7fb618312084bbb3ef5e0a6008..6152f8672d9d3bdcca9f811e262cfa816b5eeebc 100644 (file)
@@ -158,6 +158,7 @@ add_substitution(struct bsdtar *bsdtar, const char *rule_text)
                        break;
                default:
                        lafe_errc(1, 0, "Invalid replacement flag %c", *end_pattern);
+                       /* NOTREACHED */
                }
        }
 }
index ffc33e4e05a6d60485851dd9fb7262105e17cd63..16b677a945fb3d9daf2545695159acc78388f6b7 100644 (file)
@@ -4175,7 +4175,6 @@ main(int argc, char **argv)
                                free(refdir_alloc);
                                free(testprogdir);
                                usage(progname);
-                               return (1);
                        }
                        for (i = 0; i < test_num; i++) {
                                tests_run++;
index 6c6e50ae2e18de733429632f8bce4649d1346ff2..a471965197e2c2e97007b574f2807e5773e30b0a 100644 (file)
@@ -1230,10 +1230,8 @@ main(int argc, char *argv[])
         */
        nopts = getopts(argc, argv);
 
-       if (version_opt == 1) {
+       if (version_opt == 1)
                version();
-               exit(EXIT_SUCCESS);
-       }
 
        /*
         * When more of the zipinfo mode options are implemented, this
index 5bfc71a6887a04541d25cf02110a810a4cf54676..d4fcbb1aeab4e619fda8ca95c1a9e881126212c7 100644 (file)
 
 /* How to mark functions that don't return. */
 /* This facilitates use of some newer static code analysis tools. */
-#undef __LA_DEAD
+#undef __LA_NORETURN
 #if defined(__GNUC__) && (__GNUC__ > 2 || \
-                         (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
-#define        __LA_DEAD       __attribute__((__noreturn__))
-#else
-#define        __LA_DEAD
+                          (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
+#define __LA_NORETURN       __attribute__((__noreturn__))
+#elif defined(_MSC_VER)
+#define __LA_NORETURN __declspec(noreturn)
+#else 
+#define __LA_NORETURN
 #endif
 
 #endif /* !BSDUNZIP_PLATFORM_H_INCLUDED */