Fix lots of clang warnings
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c20cfcd..b1c90eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -30,6 +30,8 @@
-Wno-covered-switch-default
-Wno-deprecated-declarations
-Wno-disabled-macro-expansion
+ -Wno-documentation
+ -Wno-documentation-unknown-command
-Wno-double-promotion
-Wno-format-nonliteral
-Wno-language-extension-token
diff --git a/include/avif/internal.h b/include/avif/internal.h
index ed74b1f..ae1ecaf 100644
--- a/include/avif/internal.h
+++ b/include/avif/internal.h
@@ -50,7 +50,7 @@
uint32_t elementSize; \
uint32_t count; \
uint32_t capacity; \
- } TYPENAME;
+ } TYPENAME
void avifArrayCreate(void * arrayStruct, uint32_t elementSize, uint32_t initialCapacity);
uint32_t avifArrayPushIndex(void * arrayStruct);
void * avifArrayPushPtr(void * arrayStruct);
@@ -77,7 +77,7 @@
avifBool alpha; // if true, this is decoding an alpha plane
} avifCodecDecodeInput;
-avifCodecDecodeInput * avifCodecDecodeInputCreate();
+avifCodecDecodeInput * avifCodecDecodeInputCreate(void);
void avifCodecDecodeInputDestroy(avifCodecDecodeInput * decodeInput);
// ---------------------------------------------------------------------------
@@ -140,8 +140,8 @@
avifCodecDestroyInternalFunc destroyInternal;
} avifCodec;
-avifCodec * avifCodecCreateAOM(); // requires AVIF_CODEC_AOM
-avifCodec * avifCodecCreateDav1d(); // requires AVIF_CODEC_DAV1D
+avifCodec * avifCodecCreateAOM(void); // requires AVIF_CODEC_AOM
+avifCodec * avifCodecCreateDav1d(void); // requires AVIF_CODEC_DAV1D
void avifCodecDestroy(avifCodec * codec);
// ---------------------------------------------------------------------------
diff --git a/src/codec_aom.c b/src/codec_aom.c
index 5a8ca21..6fc32a0 100644
--- a/src/codec_aom.c
+++ b/src/codec_aom.c
@@ -3,11 +3,28 @@
#include "avif/internal.h"
+// These are for libaom to deal with
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wduplicate-enum"
+#pragma clang diagnostic ignored "-Wextra-semi"
+#pragma clang diagnostic ignored "-Wused-but-marked-unused"
+#endif
+
#include "aom/aom_decoder.h"
#include "aom/aom_encoder.h"
#include "aom/aomcx.h"
#include "aom/aomdx.h"
+#ifdef __clang__
+#pragma clang diagnostic pop
+
+// This fixes complaints with aom_codec_control() and aom_img_fmt that are from libaom
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wused-but-marked-unused"
+#pragma clang diagnostic ignored "-Wassign-enum"
+#endif
+
#include <string.h>
struct avifCodecInternal
@@ -31,7 +48,7 @@
avifFree(codec->internal);
}
-avifBool aomCodecDecode(struct avifCodec * codec)
+static avifBool aomCodecDecode(struct avifCodec * codec)
{
aom_codec_iface_t * decoder_interface = aom_codec_av1_dx();
if (aom_codec_dec_init(&codec->internal->decoder, decoder_interface, NULL, 0)) {
@@ -388,7 +405,7 @@
memcpy(outConfig, &codec->internal->config, sizeof(avifCodecConfigurationBox));
}
-avifCodec * avifCodecCreateAOM()
+avifCodec * avifCodecCreateAOM(void)
{
avifCodec * codec = (avifCodec *)avifAlloc(sizeof(avifCodec));
memset(codec, 0, sizeof(struct avifCodec));
@@ -403,3 +420,7 @@
memset(codec->internal, 0, sizeof(struct avifCodecInternal));
return codec;
}
+
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
diff --git a/src/codec_dav1d.c b/src/codec_dav1d.c
index 14f1aaa..a3ac0aa 100644
--- a/src/codec_dav1d.c
+++ b/src/codec_dav1d.c
@@ -148,7 +148,7 @@
avifImageFreePlanes(image, AVIF_PLANES_YUV);
for (int yuvPlane = 0; yuvPlane < 3; ++yuvPlane) {
image->yuvPlanes[yuvPlane] = dav1dImage->data[yuvPlane];
- image->yuvRowBytes[yuvPlane] = dav1dImage->stride[(yuvPlane == AVIF_CHAN_Y) ? 0 : 1];
+ image->yuvRowBytes[yuvPlane] = (uint32_t)dav1dImage->stride[(yuvPlane == AVIF_CHAN_Y) ? 0 : 1];
}
image->decoderOwnsYUVPlanes = AVIF_TRUE;
} else {
@@ -156,13 +156,13 @@
avifImageFreePlanes(image, AVIF_PLANES_A);
image->alphaPlane = dav1dImage->data[0];
- image->alphaRowBytes = dav1dImage->stride[0];
+ image->alphaRowBytes = (uint32_t)dav1dImage->stride[0];
image->decoderOwnsAlphaPlane = AVIF_TRUE;
}
return AVIF_TRUE;
}
-avifCodec * avifCodecCreateDav1d()
+avifCodec * avifCodecCreateDav1d(void)
{
avifCodec * codec = (avifCodec *)avifAlloc(sizeof(avifCodec));
memset(codec, 0, sizeof(struct avifCodec));
diff --git a/src/read.c b/src/read.c
index cb979b4..411d6e3 100644
--- a/src/read.c
+++ b/src/read.c
@@ -173,7 +173,7 @@
// ---------------------------------------------------------------------------
// avifCodecDecodeInput
-avifCodecDecodeInput * avifCodecDecodeInputCreate()
+avifCodecDecodeInput * avifCodecDecodeInputCreate(void)
{
avifCodecDecodeInput * decodeInput = (avifCodecDecodeInput *)avifAlloc(sizeof(avifCodecDecodeInput));
memset(decodeInput, 0, sizeof(avifCodecDecodeInput));
diff --git a/src/write.c b/src/write.c
index 4d4a79c..3967907 100644
--- a/src/write.c
+++ b/src/write.c
@@ -425,7 +425,7 @@
// unsigned int (3) seq_profile;
// unsigned int (5) seq_level_idx_0;
- avifStreamWriteU8(s, ((cfg->seqProfile & 0x7) << 5) | (cfg->seqLevelIdx0 & 0x1f));
+ avifStreamWriteU8(s, (uint8_t)((cfg->seqProfile & 0x7) << 5) | (uint8_t)(cfg->seqLevelIdx0 & 0x1f));
uint8_t bits = 0;
bits |= (cfg->seqTier0 & 0x1) << 7; // unsigned int (1) seq_tier_0;