Skip to content

Commit 2eb35fc

Browse files
committed
Fix Clang's -Wformat warnings
Use the %u format specifier with uint32_t arguments. Cast an enum type to int and use the %d format specifier with it. The underlying type of an enum type is implementation-defined. GCC uses unsigned int whenever possible, whereas MSVC always uses int. So there is no portable format specifier for an enum type. Since all enum constants have the int type (this is not implementation-defined), it is safe to cast an enum type to int and use the %d format specifier with it.
1 parent d486dad commit 2eb35fc

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/read.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,7 @@ static avifResult avifParseItemReferenceBox(avifMeta * meta, const uint8_t * raw
28772877
if (item->hasDimgFrom) {
28782878
// ISO/IEC 23008-12 (HEIF) 6.6.1: The number of SingleItemTypeReferenceBoxes with the box type 'dimg'
28792879
// and with the same value of from_item_ID shall not be greater than 1.
2880-
avifDiagnosticsPrintf(diag, "Box[iinf] contains duplicate boxes of type 'dimg' with the same from_item_ID value %d", fromID);
2880+
avifDiagnosticsPrintf(diag, "Box[iinf] contains duplicate boxes of type 'dimg' with the same from_item_ID value %u", fromID);
28812881
return AVIF_RESULT_BMFF_PARSE_FAILED;
28822882
}
28832883
item->hasDimgFrom = AVIF_TRUE;
@@ -3385,7 +3385,7 @@ static avifBool avifParseEditListBox(avifTrack * track, const uint8_t * raw, siz
33853385
uint32_t entryCount;
33863386
AVIF_CHECK(avifROStreamReadU32(&s, &entryCount)); // unsigned int(32) entry_count;
33873387
if (entryCount != 1) {
3388-
avifDiagnosticsPrintf(diag, "Box[elst] contains an entry_count != 1 [%d]", entryCount);
3388+
avifDiagnosticsPrintf(diag, "Box[elst] contains an entry_count != 1 [%u]", entryCount);
33893389
return AVIF_FALSE;
33903390
}
33913391

@@ -5367,7 +5367,7 @@ avifResult avifDecoderReset(avifDecoder * decoder)
53675367
continue;
53685368
}
53695369
if (avifDecoderItemShouldBeSkipped(inputImageItem)) {
5370-
avifDiagnosticsPrintf(data->diag, "Box[sato] input item %d is not a supported image type", inputImageItem->id);
5370+
avifDiagnosticsPrintf(data->diag, "Box[sato] input item %u is not a supported image type", inputImageItem->id);
53715371
return AVIF_RESULT_DECODE_SAMPLE_TRANSFORM_FAILED;
53725372
}
53735373
// Input image item order is important because input image items are indexed according to this order.

src/write.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ static avifResult avifEncoderWriteSampleTransformPayload(avifEncoder * encoder,
10051005
const avifResult result = avifEncoderWriteSampleTransformTokens(&s, &expression);
10061006
avifArrayDestroy(&expression);
10071007
if (result != AVIF_RESULT_OK) {
1008-
avifDiagnosticsPrintf(&encoder->diag, "Failed to write sample transform metadata for recipe %d", encoder->sampleTransformRecipe);
1008+
avifDiagnosticsPrintf(&encoder->diag, "Failed to write sample transform metadata for recipe %d", (int)encoder->sampleTransformRecipe);
10091009
return result;
10101010
}
10111011

@@ -1467,7 +1467,7 @@ static avifResult avifValidateGrid(uint32_t gridCols,
14671467
const uint32_t expectedCellHeight = (cellIndex < (cellCount - gridCols)) ? tileHeight : bottomRightCell->height;
14681468
if ((cellImage->width != expectedCellWidth) || (cellImage->height != expectedCellHeight)) {
14691469
avifDiagnosticsPrintf(diag,
1470-
"%s cell %d has invalid dimensions: expected %dx%d found %dx%d",
1470+
"%s cell %u has invalid dimensions: expected %ux%u found %ux%u",
14711471
validateGainMap ? "gain map" : "image",
14721472
cellIndex,
14731473
expectedCellWidth,
@@ -1498,7 +1498,7 @@ static avifResult avifValidateGrid(uint32_t gridCols,
14981498

14991499
if ((bottomRightCell->width > tileWidth) || (bottomRightCell->height > tileHeight)) {
15001500
avifDiagnosticsPrintf(diag,
1501-
"the last %s cell can be smaller but not larger than the other cells which are %dx%d, found %dx%d",
1501+
"the last %s cell can be smaller but not larger than the other cells which are %ux%u, found %ux%u",
15021502
validateGainMap ? "gain map" : "image",
15031503
tileWidth,
15041504
tileHeight,

0 commit comments

Comments
 (0)