mirror of
https://mirror.skon.top/https://github.com/FFmpeg/FFmpeg
synced 2026-04-20 21:00:41 +08:00
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 <jdek@itanimul.li> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 },
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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] = {
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
* @author Zane van Iperen <zane@zanevaniperen.com>
|
||||
*/
|
||||
|
||||
#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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user