]> git.ipfire.org Git - thirdparty/xz.git/commitdiff
xz, xzdec, lzmainfo: Use tuklib_attr_noreturn.
authorLasse Collin <lasse.collin@tukaani.org>
Mon, 11 Sep 2023 16:03:35 +0000 (19:03 +0300)
committerLasse Collin <lasse.collin@tukaani.org>
Tue, 7 May 2024 12:58:20 +0000 (15:58 +0300)
For compatibility with C23's [[noreturn]], tuklib_attr_noreturn
must be at the beginning of declaration (before "extern" or
"static", and even before any GNU C's __attribute__).

This commit also moves all other function attributes to
the beginning of function declarations. "extern" is kept
at the beginning of a line so the attributes are listed on
separate lines before "extern" or "static".

(cherry picked from commit b71b8922ef3971e5ccffd1e213888d44abe21d11)

src/lzmainfo/lzmainfo.c
src/xz/coder.c
src/xz/hardware.h
src/xz/message.h
src/xz/options.c
src/xz/util.h
src/xzdec/xzdec.c

index b0ccdfb430ec39dc8dca77ad673481a91ec596ba..71e62958ad6756e307d8936f086f4600c2a9eb68 100644 (file)
@@ -26,7 +26,8 @@
 #endif
 
 
-static void lzma_attribute((__noreturn__))
+tuklib_attr_noreturn
+static void
 help(void)
 {
        printf(
@@ -45,7 +46,8 @@ _("Usage: %s [--help] [--version] [FILE]...\n"
 }
 
 
-static void lzma_attribute((__noreturn__))
+tuklib_attr_noreturn
+static void
 version(void)
 {
        puts("lzmainfo (" PACKAGE_NAME ") " LZMA_VERSION_STRING);
index 4f51e8d5c0e05f6362f18e7046e5978046014167..fc26fb32258565757533b762c00b2d0d5197cc75 100644 (file)
@@ -123,7 +123,8 @@ coder_add_filter(lzma_vli id, void *options)
 }
 
 
-static void lzma_attribute((__noreturn__))
+tuklib_attr_noreturn
+static void
 memlimit_too_small(uint64_t memory_usage)
 {
        message(V_ERROR, _("Memory usage limit is too low for the given "
index 4fae61815656f8a5717a859887ba95c3849c5078..cdbc982d625b09034850de890059aed66286fe4a 100644 (file)
@@ -34,4 +34,5 @@ extern void hardware_memlimit_set(uint64_t new_memlimit,
 extern uint64_t hardware_memlimit_get(enum operation_mode mode);
 
 /// Display the amount of RAM and memory usage limits and exit.
-extern void hardware_memlimit_show(void) lzma_attribute((__noreturn__));
+tuklib_attr_noreturn
+extern void hardware_memlimit_show(void);
index 894ac7835f713fc957b428f115a177d5463e635b..d7af1cd9c52a7b065cb9ffc1aacc44935743ebab 100644 (file)
@@ -44,42 +44,44 @@ extern enum message_verbosity message_verbosity_get(void);
 /// \brief      Print a message if verbosity level is at least "verbosity"
 ///
 /// This doesn't touch the exit status.
-extern void message(enum message_verbosity verbosity, const char *fmt, ...)
-               lzma_attribute((__format__(__printf__, 2, 3)));
+lzma_attribute((__format__(__printf__, 2, 3)))
+extern void message(enum message_verbosity verbosity, const char *fmt, ...);
 
 
 /// \brief      Prints a warning and possibly sets exit status
 ///
 /// The message is printed only if verbosity level is at least V_WARNING.
 /// The exit status is set to WARNING unless it was already at ERROR.
-extern void message_warning(const char *fmt, ...)
-               lzma_attribute((__format__(__printf__, 1, 2)));
+lzma_attribute((__format__(__printf__, 1, 2)))
+extern void message_warning(const char *fmt, ...);
 
 
 /// \brief      Prints an error message and sets exit status
 ///
 /// The message is printed only if verbosity level is at least V_ERROR.
 /// The exit status is set to ERROR.
-extern void message_error(const char *fmt, ...)
-               lzma_attribute((__format__(__printf__, 1, 2)));
+lzma_attribute((__format__(__printf__, 1, 2)))
+extern void message_error(const char *fmt, ...);
 
 
 /// \brief      Prints an error message and exits with EXIT_ERROR
 ///
 /// The message is printed only if verbosity level is at least V_ERROR.
-extern void message_fatal(const char *fmt, ...)
-               lzma_attribute((__format__(__printf__, 1, 2)))
-               lzma_attribute((__noreturn__));
+tuklib_attr_noreturn
+lzma_attribute((__format__(__printf__, 1, 2)))
+extern void message_fatal(const char *fmt, ...);
 
 
 /// Print an error message that an internal error occurred and exit with
 /// EXIT_ERROR.
-extern void message_bug(void) lzma_attribute((__noreturn__));
+tuklib_attr_noreturn
+extern void message_bug(void);
 
 
 /// Print a message that establishing signal handlers failed, and exit with
 /// exit status ERROR.
-extern void message_signal_handler(void) lzma_attribute((__noreturn__));
+tuklib_attr_noreturn
+extern void message_signal_handler(void);
 
 
 /// Convert lzma_ret to a string.
@@ -116,11 +118,13 @@ extern void message_try_help(void);
 
 
 /// Prints the version number to stdout and exits with exit status SUCCESS.
-extern void message_version(void) lzma_attribute((__noreturn__));
+tuklib_attr_noreturn
+extern void message_version(void);
 
 
 /// Print the help message.
-extern void message_help(bool long_help) lzma_attribute((__noreturn__));
+tuklib_attr_noreturn
+extern void message_help(bool long_help);
 
 
 /// \brief      Set the total number of files to be processed
index ab73b77d5bcca3869e34cc1296766ebf99017935..94bdd6b88238229ff73bf4b28cc88f69ebc6a0a5 100644 (file)
@@ -241,7 +241,8 @@ enum {
 };
 
 
-static void lzma_attribute((__noreturn__))
+tuklib_attr_noreturn
+static void
 error_lzma_preset(const char *valuestr)
 {
        message_fatal(_("Unsupported LZMA1/LZMA2 preset: %s"), valuestr);
index 6e824dadb07baf28d0f32e4b2a01b0ba432cdf3f..7aa9caee6471880c9680f07429674c76d54ed2db 100644 (file)
@@ -19,8 +19,8 @@
 
 
 /// \brief      Safe realloc() that never returns NULL
-extern void *xrealloc(void *ptr, size_t size)
-               lzma_attr_alloc_size(2);
+lzma_attr_alloc_size(2)
+extern void *xrealloc(void *ptr, size_t size);
 
 
 /// \brief      Safe strdup() that never returns NULL
@@ -101,8 +101,8 @@ extern const char *uint64_to_nicestr(uint64_t value,
 ///
 /// A maximum of *left bytes is written starting from *pos. *pos and *left
 /// are updated accordingly.
-extern void my_snprintf(char **pos, size_t *left, const char *fmt, ...)
-               lzma_attribute((__format__(__printf__, 3, 4)));
+lzma_attribute((__format__(__printf__, 3, 4)))
+extern void my_snprintf(char **pos, size_t *left, const char *fmt, ...);
 
 
 /// \brief      Check if filename is empty and print an error message
index c1bd19986424c296664e13df5f8c56f8d73ed11d..556c548d05ad5c920d759380747e1eed9ffc81bd 100644 (file)
@@ -40,7 +40,8 @@
 static int display_errors = 2;
 
 
-static void lzma_attribute((__format__(__printf__, 1, 2)))
+lzma_attribute((__format__(__printf__, 1, 2)))
+static void
 my_errorf(const char *fmt, ...)
 {
        va_list ap;
@@ -57,7 +58,8 @@ my_errorf(const char *fmt, ...)
 }
 
 
-static void lzma_attribute((__noreturn__))
+tuklib_attr_noreturn
+static void
 help(void)
 {
        printf(
@@ -81,7 +83,8 @@ PACKAGE_NAME " home page: <" PACKAGE_URL ">\n", progname);
 }
 
 
-static void lzma_attribute((__noreturn__))
+tuklib_attr_noreturn
+static void
 version(void)
 {
        printf(TOOL_FORMAT "dec (" PACKAGE_NAME ") " LZMA_VERSION_STRING "\n"