From 4b7a3270689127e60a586e2231b3d2b7a47c4a79 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 1 Dec 2020 08:02:50 -0800 Subject: fix strange printf formatting warning so now, `%p` _requires_ a `void*` pointer ? --- Makefile | 5 +++-- tests/fuzzer.c | 21 +++++++++++---------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index cce932f..c3f42dd 100644 --- a/Makefile +++ b/Makefile @@ -134,7 +134,8 @@ test: $(MAKE) -C $(EXDIR) $@ .PHONY: clangtest -clangtest: CFLAGS ?= -O3 # strangely, this line has the hidden side effect of `unexport CFLAGS` +clangtest: CFLAGS ?= -O3 # make's bug (http://savannah.gnu.org/bugs/?func=detailitem&item_id=59230) +# this line has the hidden side effect of `unexport CFLAGS` export CFLAGS # fix the side effect by issuing export command clangtest: CFLAGS += -Werror -Wconversion -Wno-sign-conversion clangtest: CC = clang @@ -189,7 +190,7 @@ versionsTest: clean $(MAKE) -C $(TESTDIR) $@ .PHONY: cxxtest cxx32test -cxxtest cxx32test: CC = "$(CXX) -Wno-deprecated" +cxxtest cxx32test: CC := "$(CXX) -Wno-deprecated" cxxtest cxx32test: CFLAGS = -O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror cxx32test: CFLAGS += -m32 cxxtest cxx32test: clean diff --git a/tests/fuzzer.c b/tests/fuzzer.c index 03bdf01..e6fa13c 100644 --- a/tests/fuzzer.c +++ b/tests/fuzzer.c @@ -1136,12 +1136,12 @@ static void FUZ_unitTests(int compressionLevel) assert(shc != NULL); memset(shc, 0, sizeof(*shc)); DISPLAYLEVEL(4, "state1(%p) state2(%p) state3(%p) LZ4_stream_t size(0x%x): ", - &(shc->state1), &(shc->state2), &(shc->state3), (unsigned)sizeof(LZ4_stream_t)); - FUZ_CHECKTEST( LZ4_initStream(&(shc->state1), sizeof(shc->state1)) == NULL, "state1 (%p) failed init", &(shc->state1) ); - FUZ_CHECKTEST( LZ4_initStream(&(shc->state2), sizeof(shc->state2)) == NULL, "state2 (%p) failed init", &(shc->state2) ); - FUZ_CHECKTEST( LZ4_initStream(&(shc->state3), sizeof(shc->state3)) == NULL, "state3 (%p) failed init", &(shc->state3) ); + (void*)&(shc->state1), (void*)&(shc->state2), (void*)&(shc->state3), (unsigned)sizeof(LZ4_stream_t)); + FUZ_CHECKTEST( LZ4_initStream(&(shc->state1), sizeof(shc->state1)) == NULL, "state1 (%p) failed init", (void*)&(shc->state1) ); + FUZ_CHECKTEST( LZ4_initStream(&(shc->state2), sizeof(shc->state2)) == NULL, "state2 (%p) failed init", (void*)&(shc->state2) ); + FUZ_CHECKTEST( LZ4_initStream(&(shc->state3), sizeof(shc->state3)) == NULL, "state3 (%p) failed init", (void*)&(shc->state3) ); FUZ_CHECKTEST( LZ4_initStream((char*)&(shc->state1) + 1, sizeof(shc->state1)) != NULL, - "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc->state1) + 1 ); + "hc1+1 (%p) init must fail, due to bad alignment", (void*)((char*)&(shc->state1) + 1) ); free(shc); } DISPLAYLEVEL(3, "all inits OK \n"); @@ -1246,12 +1246,13 @@ static void FUZ_unitTests(int compressionLevel) assert(shc != NULL); memset(shc, 0, sizeof(*shc)); DISPLAYLEVEL(4, "hc1(%p) hc2(%p) hc3(%p) size(0x%x): ", - &(shc->hc1), &(shc->hc2), &(shc->hc3), (unsigned)sizeof(LZ4_streamHC_t)); - FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc1), sizeof(shc->hc1)) == NULL, "hc1 (%p) failed init", &(shc->hc1) ); - FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc2), sizeof(shc->hc2)) == NULL, "hc2 (%p) failed init", &(shc->hc2) ); - FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc3), sizeof(shc->hc3)) == NULL, "hc3 (%p) failed init", &(shc->hc3) ); + (void*)&(shc->hc1), (void*)&(shc->hc2), (void*)&(shc->hc3), + (unsigned)sizeof(LZ4_streamHC_t)); + FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc1), sizeof(shc->hc1)) == NULL, "hc1 (%p) failed init", (void*)&(shc->hc1) ); + FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc2), sizeof(shc->hc2)) == NULL, "hc2 (%p) failed init", (void*)&(shc->hc2) ); + FUZ_CHECKTEST( LZ4_initStreamHC(&(shc->hc3), sizeof(shc->hc3)) == NULL, "hc3 (%p) failed init", (void*)&(shc->hc3) ); FUZ_CHECKTEST( LZ4_initStreamHC((char*)&(shc->hc1) + 1, sizeof(shc->hc1)) != NULL, - "hc1+1 (%p) init must fail, due to bad alignment", (char*)&(shc->hc1) + 1 ); + "hc1+1 (%p) init must fail, due to bad alignment", (void*)((char*)&(shc->hc1) + 1) ); free(shc); } DISPLAYLEVEL(3, "all inits OK \n"); -- cgit v0.12