This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 0b77f791912bf6355206c68b677e71cd61227036 Author: Andreas Rheinhardt <[email protected]> AuthorDate: Mon Jan 5 17:24:44 2026 +0100 Commit: Andreas Rheinhardt <[email protected]> CommitDate: Fri Feb 20 11:59:37 2026 +0100 avutil/attributes_internal: Add attribute_nonstring This attribute is used to signal to the compiler that an array object initialized via a string literal is not a real string and may lack the space for the trailing zero, as in char fourcc[4]="FOUR". This is in preparation for enabling the -Wunterminated-string-initialization warning. Reviewed-by: J. Dekker <[email protected]> Signed-off-by: Andreas Rheinhardt <[email protected]> --- libavcodec/gif.h | 6 ++++-- libavformat/amr.c | 9 +++++---- libavformat/concatdec.c | 3 ++- libavformat/id3v2.c | 7 ++++--- libavformat/mccdec.c | 3 ++- libavutil/attributes_internal.h | 9 +++++++++ libavutil/tests/blowfish.c | 5 +++-- libavutil/uuid.c | 3 ++- 8 files changed, 31 insertions(+), 14 deletions(-) diff --git a/libavcodec/gif.h b/libavcodec/gif.h index 7fb61495bc..7848b8876e 100644 --- a/libavcodec/gif.h +++ b/libavcodec/gif.h @@ -31,8 +31,10 @@ #include <stdint.h> -static const uint8_t gif87a_sig[6] = "GIF87a"; -static const uint8_t gif89a_sig[6] = "GIF89a"; +#include "libavutil/attributes_internal.h" + +static attribute_nonstring const uint8_t gif87a_sig[6] = "GIF87a"; +static attribute_nonstring const uint8_t gif89a_sig[6] = "GIF89a"; #define GCE_DISPOSAL_NONE 0 #define GCE_DISPOSAL_INPLACE 1 diff --git a/libavformat/amr.c b/libavformat/amr.c index 9cc61baf55..e825121af3 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -25,6 +25,7 @@ Write and read amr data according to RFC3267, http://www.ietf.org/rfc/rfc3267.tx #include "config_components.h" +#include "libavutil/attributes_internal.h" #include "libavutil/channel_layout.h" #include "libavutil/intreadwrite.h" #include "avformat.h" @@ -39,10 +40,10 @@ typedef struct AMRContext { FFRawDemuxerContext rawctx; } AMRContext; -static const uint8_t AMR_header[6] = "#!AMR\x0a"; -static const uint8_t AMRMC_header[12] = "#!AMR_MC1.0\x0a"; -static const uint8_t AMRWB_header[9] = "#!AMR-WB\x0a"; -static const uint8_t AMRWBMC_header[15] = "#!AMR-WB_MC1.0\x0a"; +static attribute_nonstring const uint8_t AMR_header[6] = "#!AMR\x0a"; +static attribute_nonstring const uint8_t AMRMC_header[12] = "#!AMR_MC1.0\x0a"; +static attribute_nonstring const uint8_t AMRWB_header[9] = "#!AMR-WB\x0a"; +static attribute_nonstring const uint8_t AMRWBMC_header[15] = "#!AMR-WB_MC1.0\x0a"; static const uint8_t amrnb_packed_size[16] = { 13, 14, 16, 18, 20, 21, 27, 32, 6, 1, 1, 1, 1, 1, 1, 1 diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c index e0c2c87248..c57d1b649a 100644 --- a/libavformat/concatdec.c +++ b/libavformat/concatdec.c @@ -18,6 +18,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes_internal.h" #include "libavutil/avstring.h" #include "libavutil/avassert.h" #include "libavutil/bprint.h" @@ -419,7 +420,7 @@ static int concat_read_close(AVFormatContext *avf) typedef struct ParseSyntax { const char *keyword; - char args[MAX_ARGS]; + attribute_nonstring char args[MAX_ARGS]; uint8_t flags; } ParseSyntax; diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c index 98969c67a0..5fc82ad9dc 100644 --- a/libavformat/id3v2.c +++ b/libavformat/id3v2.c @@ -32,6 +32,7 @@ #include <zlib.h> #endif +#include "libavutil/attributes_internal.h" #include "libavutil/avstring.h" #include "libavutil/bprint.h" #include "libavutil/dict.h" @@ -87,7 +88,7 @@ static const AVMetadataConv id3v2_2_metadata_conv[] = { { 0 } }; -const char ff_id3v2_tags[][4] = { +attribute_nonstring const char ff_id3v2_tags[][4] = { "TALB", "TBPM", "TCOM", "TCON", "TCOP", "TDLY", "TENC", "TEXT", "TFLT", "TIT1", "TIT2", "TIT3", "TKEY", "TLAN", "TLEN", "TMED", "TOAL", "TOFN", "TOLY", "TOPE", "TOWN", "TPE1", "TPE2", "TPE3", @@ -95,13 +96,13 @@ const char ff_id3v2_tags[][4] = { { 0 }, }; -const char ff_id3v2_4_tags[][4] = { +attribute_nonstring const char ff_id3v2_4_tags[][4] = { "TDEN", "TDOR", "TDRC", "TDRL", "TDTG", "TIPL", "TMCL", "TMOO", "TPRO", "TSOA", "TSOP", "TSOT", "TSST", { 0 }, }; -const char ff_id3v2_3_tags[][4] = { +attribute_nonstring const char ff_id3v2_3_tags[][4] = { "TDAT", "TIME", "TORY", "TRDA", "TSIZ", "TYER", { 0 }, }; diff --git a/libavformat/mccdec.c b/libavformat/mccdec.c index e9b6fa14b4..4384704f32 100644 --- a/libavformat/mccdec.c +++ b/libavformat/mccdec.c @@ -26,6 +26,7 @@ #include "libavcodec/bytestream.h" #include "libavcodec/codec_id.h" #include "libavcodec/smpte_436m.h" +#include "libavutil/attributes_internal.h" #include "libavutil/avstring.h" #include "libavutil/avutil.h" #include "libavutil/error.h" @@ -84,7 +85,7 @@ typedef struct alias { #define CCPAD "\xFA\x0\x0" #define CCPAD3 CCPAD CCPAD CCPAD -static const char cc_pad[27] = CCPAD3 CCPAD3 CCPAD3; +static attribute_nonstring const char cc_pad[27] = CCPAD3 CCPAD3 CCPAD3; static const alias aliases[20] = { // clang-format off diff --git a/libavutil/attributes_internal.h b/libavutil/attributes_internal.h index bc85ce77ff..15d89120ad 100644 --- a/libavutil/attributes_internal.h +++ b/libavutil/attributes_internal.h @@ -33,4 +33,13 @@ #define EXTERN extern attribute_visibility_hidden +#if (AV_HAS_ATTRIBUTE(nonstring) && (AV_GCC_VERSION_AT_LEAST(15,1) || defined(__clang__))) +// Attribute to mark a variable initialized via a string literal as not +// containing string data to suppress warnings about unterminated strings +// in situations like char fourcc[4] = "TALB". +#define attribute_nonstring __attribute__((nonstring)) +#else +#define attribute_nonstring +#endif + #endif /* AVUTIL_ATTRIBUTES_INTERNAL_H */ diff --git a/libavutil/tests/blowfish.c b/libavutil/tests/blowfish.c index 0dd4d22c9d..41c12e5992 100644 --- a/libavutil/tests/blowfish.c +++ b/libavutil/tests/blowfish.c @@ -21,6 +21,7 @@ #include <stdlib.h> #include <string.h> +#include "libavutil/attributes_internal.h" #include "libavutil/mem.h" #include "libavutil/blowfish.h" @@ -109,9 +110,9 @@ static const uint32_t ciphertext_r[NUM_VARIABLE_KEY_TESTS] = { }; /* plaintext bytes */ -static const uint8_t plaintext[8] = "BLOWFISH"; +static attribute_nonstring const uint8_t plaintext[8] = "BLOWFISH"; -static const uint8_t plaintext2[16] = "BLOWFISHBLOWFISH"; +static attribute_nonstring const uint8_t plaintext2[16] = "BLOWFISHBLOWFISH"; /* ciphertext bytes */ static const uint8_t ciphertext[8] = { diff --git a/libavutil/uuid.c b/libavutil/uuid.c index 062e28736b..3f5075c066 100644 --- a/libavutil/uuid.c +++ b/libavutil/uuid.c @@ -60,6 +60,7 @@ * @author Zane van Iperen <[email protected]> */ +#include "attributes_internal.h" #include "uuid.h" #include "error.h" #include "avstring.h" @@ -112,7 +113,7 @@ int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu) return 0; } -static const char hexdigits_lower[16] = "0123456789abcdef"; +static attribute_nonstring const char hexdigits_lower[16] = "0123456789abcdef"; void av_uuid_unparse(const AVUUID uuid, char *out) { _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
