Skip to content

Commit 7fa9306

Browse files
authored
Add a warning to catch 0 to pointer conversion. (#2742)
This could help finding some weird casts (like bool to ptr)
1 parent 8feaf13 commit 7fa9306

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
302302
message(STATUS "libavif: Enabling warnings for Clang")
303303
target_compile_options(
304304
avif_enable_warnings INTERFACE -Wall -Wextra -Wgnu-empty-initializer -Wshorten-64-to-32 -Wstrict-prototypes
305+
-Wzero-as-null-pointer-constant
305306
)
306307
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU")
307308
message(STATUS "libavif: Enabling warnings for GCC")

apps/avifgainmaputil/extractgainmap_command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ExtractGainMapCommand::ExtractGainMapCommand()
1818

1919
avifResult ExtractGainMapCommand::Run() {
2020
DecoderPtr decoder(avifDecoderCreate());
21-
if (decoder == NULL) {
21+
if (decoder == nullptr) {
2222
return AVIF_RESULT_OUT_OF_MEMORY;
2323
}
2424
decoder->imageContentToDecode = AVIF_IMAGE_CONTENT_GAIN_MAP;

apps/avifgainmaputil/imageio.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,15 @@ avifResult ReadImage(avifImage* image, const std::string& input_filename,
9898
return AVIF_RESULT_INVALID_ARGUMENT;
9999
} else if (input_format == AVIF_APP_FILE_FORMAT_AVIF) {
100100
DecoderPtr decoder(avifDecoderCreate());
101-
if (decoder == NULL) {
101+
if (decoder == nullptr) {
102102
return AVIF_RESULT_OUT_OF_MEMORY;
103103
}
104104
avifResult result = ReadAvif(decoder.get(), input_filename, ignore_profile);
105105
if (result != AVIF_RESULT_OK) {
106106
return result;
107107
}
108108
if (decoder->image->imageOwnsYUVPlanes &&
109-
(decoder->image->alphaPlane == NULL ||
109+
(decoder->image->alphaPlane == nullptr ||
110110
decoder->image->imageOwnsAlphaPlane)) {
111111
std::swap(*image, *decoder->image);
112112
} else {

apps/avifgainmaputil/printmetadata_command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PrintMetadataCommand::PrintMetadataCommand()
3838

3939
avifResult PrintMetadataCommand::Run() {
4040
DecoderPtr decoder(avifDecoderCreate());
41-
if (decoder == NULL) {
41+
if (decoder == nullptr) {
4242
return AVIF_RESULT_OUT_OF_MEMORY;
4343
}
4444

apps/avifgainmaputil/swapbase_command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ SwapBaseCommand::SwapBaseCommand()
128128

129129
avifResult SwapBaseCommand::Run() {
130130
DecoderPtr decoder(avifDecoderCreate());
131-
if (decoder == NULL) {
131+
if (decoder == nullptr) {
132132
return AVIF_RESULT_OUT_OF_MEMORY;
133133
}
134134
decoder->imageContentToDecode |= AVIF_IMAGE_CONTENT_GAIN_MAP;

apps/avifgainmaputil/tonemap_command.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ avifResult TonemapCommand::Run() {
6868
const bool tone_mapping_to_hdr = (headroom > 0.0f);
6969

7070
DecoderPtr decoder(avifDecoderCreate());
71-
if (decoder == NULL) {
71+
if (decoder == nullptr) {
7272
return AVIF_RESULT_OUT_OF_MEMORY;
7373
}
7474
decoder->imageContentToDecode |= AVIF_IMAGE_CONTENT_GAIN_MAP;

0 commit comments

Comments
 (0)