diff options
| author | Peter Kjellerstedt <peter.kjellerstedt@axis.com> | 2025-06-02 22:56:03 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2025-06-05 11:02:21 +0100 |
| commit | 394592ed583b1558b06debd74759e7cd67fa5008 (patch) | |
| tree | 17081b34d8cedb17e2be0209911b23da5fffaa81 /meta/recipes-devtools/m4 | |
| parent | 19bee937be57e7249b2dc3fb749553d870b5b8d2 (diff) | |
| download | poky-394592ed583b1558b06debd74759e7cd67fa5008.tar.gz | |
m4: Backport a patch to build with --disable-nls
Building with USE_NLS = "no" results in the following errors:
lib/spawn-pipe.c: In function 'create_pipe':
lib/spawn-pipe.c:218:7: error: format not a string literal and no
format arguments [-Werror=format-security]
218 | error (EXIT_FAILURE, errno, _("cannot create pipe"));
| ^~~~~
lib/spawn-pipe.c:221:7: error: format not a string literal and no
format arguments [-Werror=format-security]
221 | error (EXIT_FAILURE, errno, _("cannot create pipe"));
| ^~~~~
lib/clean-temp.c: In function 'create_temp_dir':
lib/clean-temp.c:234:7: error: format not a string literal and no
format arguments [-Werror=format-security]
234 | error (0, errno,
| ^~~~~
Backport a patch from gnulib to avoid the problem.
(From OE-Core rev: 635df18f32e8f13cc5897737450dbd9f9207db3b)
Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/m4')
| -rw-r--r-- | meta/recipes-devtools/m4/m4-1.4.20.inc | 1 | ||||
| -rw-r--r-- | meta/recipes-devtools/m4/m4/0001-gettext-h-Avoid-gcc-Wformat-security-warnings-with-d.patch | 133 |
2 files changed, 134 insertions, 0 deletions
diff --git a/meta/recipes-devtools/m4/m4-1.4.20.inc b/meta/recipes-devtools/m4/m4-1.4.20.inc index 2ea3a9bace..0640395050 100644 --- a/meta/recipes-devtools/m4/m4-1.4.20.inc +++ b/meta/recipes-devtools/m4/m4-1.4.20.inc | |||
| @@ -7,6 +7,7 @@ GNU M4 also has built-in functions for including files, running shell commands, | |||
| 7 | inherit autotools texinfo ptest gettext | 7 | inherit autotools texinfo ptest gettext |
| 8 | 8 | ||
| 9 | SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \ | 9 | SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \ |
| 10 | file://0001-gettext-h-Avoid-gcc-Wformat-security-warnings-with-d.patch \ | ||
| 10 | " | 11 | " |
| 11 | SRC_URI:append:class-target = " file://run-ptest \ | 12 | SRC_URI:append:class-target = " file://run-ptest \ |
| 12 | file://serial-tests-config.patch \ | 13 | file://serial-tests-config.patch \ |
diff --git a/meta/recipes-devtools/m4/m4/0001-gettext-h-Avoid-gcc-Wformat-security-warnings-with-d.patch b/meta/recipes-devtools/m4/m4/0001-gettext-h-Avoid-gcc-Wformat-security-warnings-with-d.patch new file mode 100644 index 0000000000..6fad05041f --- /dev/null +++ b/meta/recipes-devtools/m4/m4/0001-gettext-h-Avoid-gcc-Wformat-security-warnings-with-d.patch | |||
| @@ -0,0 +1,133 @@ | |||
| 1 | From c4dc0ab4424fca31635b7837b1c180f7d3df8ede Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Bruno Haible <bruno@clisp.org> | ||
| 3 | Date: Wed, 28 May 2025 15:14:07 +0200 | ||
| 4 | Subject: [PATCH] gettext-h: Avoid gcc -Wformat-security warnings with | ||
| 5 | --disable-nls. | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | Reported by Holger Hoffstätte <holger@applied-asynchrony.com> in | ||
| 11 | <https://lists.gnu.org/archive/html/bug-gnulib/2025-05/msg00225.html>. | ||
| 12 | |||
| 13 | * lib/gettext.h (gettext, dgettext, dcgettext): With gcc in C mode, | ||
| 14 | define these as inline functions. | ||
| 15 | * lib/sigpipe-die.c (sigpipe_die): Use translated string as a format | ||
| 16 | string, relying on the format string checking done by 'msgfmt -c'. | ||
| 17 | * lib/xmemcoll.c (collate_error): Revert commit from 2025-01-17. | ||
| 18 | * lib/xprintf.c (xvprintf, xvfprintf): Likewise. | ||
| 19 | * lib/openat-die.c (openat_save_fail, openat_restore_fail): Revert | ||
| 20 | commit from 2024-12-10. | ||
| 21 | |||
| 22 | Upstream-Status: Backport [https://cgit.git.savannah.gnu.org/cgit/gnulib.git/commit/?id=6e5015dd557b20ae4a0829c4bf78480ce2f4cb04] | ||
| 23 | Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> | ||
| 24 | --- | ||
| 25 | lib/gettext.h | 49 ++++++++++++++++++++++++++++++++++++------------ | ||
| 26 | lib/openat-die.c | 4 ++-- | ||
| 27 | lib/xprintf.c | 4 ++-- | ||
| 28 | 3 files changed, 41 insertions(+), 16 deletions(-) | ||
| 29 | |||
| 30 | diff --git a/lib/gettext.h b/lib/gettext.h | ||
| 31 | index ea0c27e..bb3d975 100644 | ||
| 32 | --- a/lib/gettext.h | ||
| 33 | +++ b/lib/gettext.h | ||
| 34 | @@ -59,18 +59,43 @@ | ||
| 35 | # endif | ||
| 36 | # endif | ||
| 37 | |||
| 38 | -/* Disabled NLS. | ||
| 39 | - The casts to 'const char *' serve the purpose of producing warnings | ||
| 40 | - for invalid uses of the value returned from these functions. | ||
| 41 | - On pre-ANSI systems without 'const', the config.h file is supposed to | ||
| 42 | - contain "#define const". */ | ||
| 43 | -# undef gettext | ||
| 44 | -# define gettext(Msgid) ((const char *) (Msgid)) | ||
| 45 | -# undef dgettext | ||
| 46 | -# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) | ||
| 47 | -# undef dcgettext | ||
| 48 | -# define dcgettext(Domainname, Msgid, Category) \ | ||
| 49 | - ((void) (Category), dgettext (Domainname, Msgid)) | ||
| 50 | +/* Disabled NLS. */ | ||
| 51 | +# if defined __GNUC__ && !defined __clang__ && !defined __cplusplus | ||
| 52 | +/* Use inline functions, to avoid warnings | ||
| 53 | + warning: format not a string literal and no format arguments | ||
| 54 | + that don't occur with enabled NLS. */ | ||
| 55 | +__attribute__ ((__always_inline__, __gnu_inline__)) extern inline | ||
| 56 | +const char * | ||
| 57 | +gettext (const char *msgid) | ||
| 58 | +{ | ||
| 59 | + return msgid; | ||
| 60 | +} | ||
| 61 | +__attribute__ ((__always_inline__, __gnu_inline__)) extern inline | ||
| 62 | +const char * | ||
| 63 | +dgettext (const char *domain, const char *msgid) | ||
| 64 | +{ | ||
| 65 | + (void) domain; | ||
| 66 | + return msgid; | ||
| 67 | +} | ||
| 68 | +__attribute__ ((__always_inline__, __gnu_inline__)) extern inline | ||
| 69 | +const char * | ||
| 70 | +dcgettext (const char *domain, const char *msgid, int category) | ||
| 71 | +{ | ||
| 72 | + (void) domain; | ||
| 73 | + (void) category; | ||
| 74 | + return msgid; | ||
| 75 | +} | ||
| 76 | +# else | ||
| 77 | +/* The casts to 'const char *' serve the purpose of producing warnings | ||
| 78 | + for invalid uses of the value returned from these functions. */ | ||
| 79 | +# undef gettext | ||
| 80 | +# define gettext(Msgid) ((const char *) (Msgid)) | ||
| 81 | +# undef dgettext | ||
| 82 | +# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) | ||
| 83 | +# undef dcgettext | ||
| 84 | +# define dcgettext(Domainname, Msgid, Category) \ | ||
| 85 | + ((void) (Category), dgettext (Domainname, Msgid)) | ||
| 86 | +# endif | ||
| 87 | # undef ngettext | ||
| 88 | # define ngettext(Msgid1, Msgid2, N) \ | ||
| 89 | ((N) == 1 \ | ||
| 90 | diff --git a/lib/openat-die.c b/lib/openat-die.c | ||
| 91 | index 3fbb5d8..79a5b23 100644 | ||
| 92 | --- a/lib/openat-die.c | ||
| 93 | +++ b/lib/openat-die.c | ||
| 94 | @@ -34,7 +34,7 @@ _Noreturn void | ||
| 95 | openat_save_fail (int errnum) | ||
| 96 | { | ||
| 97 | #ifndef GNULIB_LIBPOSIX | ||
| 98 | - error (exit_failure, errnum, "%s", | ||
| 99 | + error (exit_failure, errnum, | ||
| 100 | _("unable to record current working directory")); | ||
| 101 | #endif | ||
| 102 | /* _Noreturn cannot be applied to error, since it returns | ||
| 103 | @@ -53,7 +53,7 @@ _Noreturn void | ||
| 104 | openat_restore_fail (int errnum) | ||
| 105 | { | ||
| 106 | #ifndef GNULIB_LIBPOSIX | ||
| 107 | - error (exit_failure, errnum, "%s", | ||
| 108 | + error (exit_failure, errnum, | ||
| 109 | _("failed to return to initial working directory")); | ||
| 110 | #endif | ||
| 111 | |||
| 112 | diff --git a/lib/xprintf.c b/lib/xprintf.c | ||
| 113 | index 4d9a3e5..790af53 100644 | ||
| 114 | --- a/lib/xprintf.c | ||
| 115 | +++ b/lib/xprintf.c | ||
| 116 | @@ -45,7 +45,7 @@ xvprintf (char const *restrict format, va_list args) | ||
| 117 | { | ||
| 118 | off64_t retval = vzprintf (format, args); | ||
| 119 | if (retval < 0 && ! ferror (stdout)) | ||
| 120 | - error (exit_failure, errno, "%s", _("cannot perform formatted output")); | ||
| 121 | + error (exit_failure, errno, _("cannot perform formatted output")); | ||
| 122 | |||
| 123 | return retval; | ||
| 124 | } | ||
| 125 | @@ -67,7 +67,7 @@ xvfprintf (FILE *restrict stream, char const *restrict format, va_list args) | ||
| 126 | { | ||
| 127 | off64_t retval = vfzprintf (stream, format, args); | ||
| 128 | if (retval < 0 && ! ferror (stream)) | ||
| 129 | - error (exit_failure, errno, "%s", _("cannot perform formatted output")); | ||
| 130 | + error (exit_failure, errno, _("cannot perform formatted output")); | ||
| 131 | |||
| 132 | return retval; | ||
| 133 | } | ||
