avformat,avcodec: use PRI format macros for uint32_t in log messages

Use PRIu32/PRIX32 format specifiers instead of %d/%u/%X for uint32_t
variables in av_log calls. On some platforms (e.g. NuttX), uint32_t is
typedef'd as unsigned long rather than unsigned int, which triggers
-Wformat warnings despite both types being 4 bytes. Using PRI macros
is the portable way to match the actual underlying type of uint32_t.

Signed-off-by: zengshuang <zengshuang@xiaomi.com>
This commit is contained in:
zengshuang
2026-02-26 16:17:47 +08:00
committed by Zhao Zhili
parent 2c7fe8d8ad
commit 9d73d10c50
6 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -385,7 +385,7 @@ static int handle_crc(MPADecodeContext *s, int sec_len)
crc_val = av_crc(crc_tab, crc_val, tmp_buf, 3);
if (crc_val) {
av_log(s->avctx, AV_LOG_ERROR, "CRC mismatch %X!\n", crc_val);
av_log(s->avctx, AV_LOG_ERROR, "CRC mismatch %"PRIX32"!\n", crc_val);
if (s->err_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
}
+1 -1
View File
@@ -457,7 +457,7 @@ static void dump_cropping(void *ctx, const AVPacketSideData *sd, int log_level)
left = AV_RL32(sd->data + 8);
right = AV_RL32(sd->data + 12);
av_log(ctx, log_level, "%d/%d/%d/%d", left, right, top, bottom);
av_log(ctx, log_level, "%"PRIu32"/%"PRIu32"/%"PRIu32"/%"PRIu32"", left, right, top, bottom);
}
static void dump_tdrdi(void *ctx, const AVPacketSideData *sd, int log_level)
+2 -2
View File
@@ -120,7 +120,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t **bufp, int buf_size,
left = bytestream2_get_bytes_left(&g);
if (len <= 0 || len > left) {
if (len > MAX_TRUNC_PICTURE_SIZE || len >= INT_MAX - AV_INPUT_BUFFER_PADDING_SIZE) {
av_log(s, AV_LOG_ERROR, "Attached picture metadata block too big %u\n", len);
av_log(s, AV_LOG_ERROR, "Attached picture metadata block too big %"PRIu32"\n", len);
if (s->error_recognition & AV_EF_EXPLODE)
return AVERROR_INVALIDDATA;
return 0;
@@ -132,7 +132,7 @@ int ff_flac_parse_picture(AVFormatContext *s, uint8_t **bufp, int buf_size,
if (truncate_workaround &&
s->strict_std_compliance <= FF_COMPLIANCE_NORMAL &&
len > left && (len & 0xffffff) == left) {
av_log(s, AV_LOG_INFO, "Correcting truncated metadata picture size from %u to %u\n", left, len);
av_log(s, AV_LOG_INFO, "Correcting truncated metadata picture size from %"PRIu32" to %"PRIu32"\n", left, len);
trunclen = len - left;
} else {
av_log(s, AV_LOG_ERROR, "Attached picture metadata block too short\n");
+2 -2
View File
@@ -567,7 +567,7 @@ retry:
// UTF8 and 4 means "UTF8 sort". For any other type (UTF16 or e.g.
// a picture), don't return it blindly in a string that is supposed
// to be UTF8 text.
av_log(c->fc, AV_LOG_WARNING, "Skipping unhandled metadata %s of type %d\n", key, data_type);
av_log(c->fc, AV_LOG_WARNING, "Skipping unhandled metadata %s of type %"PRIu32"\n", key, data_type);
av_free(str);
return 0;
} else {
@@ -9315,7 +9315,7 @@ static int mov_read_ispe(MOVContext *c, AVIOContext *pb, MOVAtom atom)
width = avio_rb32(pb);
height = avio_rb32(pb);
av_log(c->fc, AV_LOG_TRACE, "ispe: item_id %d, width %u, height %u\n",
av_log(c->fc, AV_LOG_TRACE, "ispe: item_id %d, width %"PRIu32", height %"PRIu32"\n",
c->cur_item_id, width, height);
item = get_heif_item(c, c->cur_item_id);
+2 -2
View File
@@ -546,7 +546,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
int nb_channels = ch_layout->nb_channels;
if (!num_descr || num_descr < nb_channels) {
av_log(s, AV_LOG_ERROR, "got %d channel descriptions when at least %d were needed\n",
av_log(s, AV_LOG_ERROR, "got %"PRIu32" channel descriptions when at least %d were needed\n",
num_descr, nb_channels);
return AVERROR_INVALIDDATA;
}
@@ -554,7 +554,7 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
if (num_descr > nb_channels) {
int strict = s->strict_std_compliance >= FF_COMPLIANCE_STRICT;
av_log(s, strict ? AV_LOG_ERROR : AV_LOG_WARNING,
"got %d channel descriptions when number of channels is %d\n",
"got %"PRIu32" channel descriptions when number of channels is %d\n",
num_descr, nb_channels);
if (strict)
return AVERROR_INVALIDDATA;
+1 -1
View File
@@ -675,7 +675,7 @@ static int tls_open(URLContext *h, const char *uri, int flags, AVDictionary **op
// check the result of the certificate verification
if ((verify_res_flags = mbedtls_ssl_get_verify_result(&tls_ctx->ssl_context)) != 0) {
av_log(h, AV_LOG_ERROR, "mbedtls_ssl_get_verify_result reported problems "\
"with the certificate verification, returned flags: %u\n",
"with the certificate verification, returned flags: %"PRIu32"\n",
verify_res_flags);
if (verify_res_flags & MBEDTLS_X509_BADCERT_NOT_TRUSTED)
av_log(h, AV_LOG_ERROR, "The certificate is not correctly signed by the trusted CA.\n");