From 76c0b4ece314043545a012c871a904f878fd8238 Mon Sep 17 00:00:00 2001 From: Daniel Mendler Date: Tue, 29 Jan 2019 22:35:01 +0100 Subject: [PATCH] fix warnings: switch-enum --- amalgamate.sh | 12 ++++++------ miniz_zip.h | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/amalgamate.sh b/amalgamate.sh index aac798f..f926273 100755 --- a/amalgamate.sh +++ b/amalgamate.sh @@ -23,20 +23,22 @@ do sed -i "s/#include \"$i.h\"//g" $OUTPUT_PREFIX.c done +WARNINGS="-Wall -Wextra -Wswitch-enum" + echo "int main() { return 0; }" > main.c echo "Test compile with GCC..." -gcc -pedantic -Wall -Wextra main.c $OUTPUT_PREFIX.c -o test.out +gcc -pedantic $WARNINGS main.c $OUTPUT_PREFIX.c -o test.out echo "Test compile with GCC ANSI..." -gcc -ansi -pedantic -Wall -Wextra main.c $OUTPUT_PREFIX.c -o test.out +gcc -ansi -pedantic $WARNINGS main.c $OUTPUT_PREFIX.c -o test.out if command -v clang then echo "Test compile with clang..." - clang -Wall -Wextra -Wpedantic -fsanitize=unsigned-integer-overflow main.c $OUTPUT_PREFIX.c -o test.out + clang $WARNINGS -Wpedantic -fsanitize=unsigned-integer-overflow main.c $OUTPUT_PREFIX.c -o test.out fi for def in MINIZ_NO_STDIO MINIZ_NO_TIME MINIZ_NO_ARCHIVE_APIS MINIZ_NO_ARCHIVE_WRITING_APIS MINIZ_NO_ZLIB_APIS MINIZ_NO_ZLIB_COMPATIBLE_NAMES MINIZ_NO_MALLOC do echo "Test compile with GCC and define $def..." - gcc -ansi -pedantic -Wall -Wextra main.c $OUTPUT_PREFIX.c -o test.out -D${def} + gcc -ansi -pedantic $WARNINGS main.c $OUTPUT_PREFIX.c -o test.out -D${def} done rm test.out rm main.c @@ -65,5 +67,3 @@ EOF cd .. echo "Amalgamation created." - - diff --git a/miniz_zip.h b/miniz_zip.h index 9314361..0cbd74b 100644 --- a/miniz_zip.h +++ b/miniz_zip.h @@ -143,10 +143,11 @@ typedef enum { MZ_ZIP_FILE_NOT_FOUND, MZ_ZIP_ARCHIVE_TOO_LARGE, MZ_ZIP_VALIDATION_FAILED, - MZ_ZIP_WRITE_CALLBACK_FAILED, - MZ_ZIP_TOTAL_ERRORS + MZ_ZIP_WRITE_CALLBACK_FAILED } mz_zip_error; +#define MZ_ZIP_TOTAL_ERRORS (MZ_ZIP_WRITE_CALLBACK_FAILED + 1) /* change if errors are added */ + typedef struct { mz_uint64 m_archive_size;