From 0e39cb8e34a2266971d849f7b5f73c0bb176e09f Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 2 May 2020 23:54:27 +0200 Subject: [PATCH] stricter warnings, wip --- Makefile.host | 3 ++- client/deps/amiitool/amiibo.c | 10 +++++----- client/deps/amiitool/keygen.c | 2 +- client/deps/hardnested/hardnested_bf_core.c | 4 ++-- client/deps/hardnested/hardnested_bruteforce.c | 2 +- client/deps/jansson/hashtable.c | 4 ++-- client/deps/jansson/hashtable_seed.c | 2 +- client/deps/liblua/llex.c | 2 +- client/src/cmdhfmfu.h | 2 +- common/crapto1/crapto1.c | 2 +- common/zlib/deflate.c | 3 +++ 11 files changed, 20 insertions(+), 16 deletions(-) diff --git a/Makefile.host b/Makefile.host index 9f5688939..7ed942401 100644 --- a/Makefile.host +++ b/Makefile.host @@ -15,7 +15,8 @@ ifeq ($(DEFSBEENHERE),) $(error Can't find Makefile.defs) endif -CFLAGS ?= -Wall -Werror -O3 +CFLAGS ?= -Wall -Werror -O3 -Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused -Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat -Wformat-security -Winit-self -Wmissing-include-dirs -Wmissing-prototypes -Wstrict-prototypes -Wnested-externs -Wmissing-declarations +# -Wbad-function-cast -Wextra -Wswitch-enum -Wold-style-definition CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES) vpath %.c $(MYSRCPATHS) diff --git a/client/deps/amiitool/amiibo.c b/client/deps/amiitool/amiibo.c index 809f611d3..ad41220bb 100644 --- a/client/deps/amiitool/amiibo.c +++ b/client/deps/amiitool/amiibo.c @@ -13,7 +13,7 @@ #define HMAC_POS_DATA 0x008 #define HMAC_POS_TAG 0x1B4 -void nfc3d_amiibo_calc_seed(const uint8_t *dump, uint8_t *key) { +static void nfc3d_amiibo_calc_seed(const uint8_t *dump, uint8_t *key) { memcpy(key + 0x00, dump + 0x029, 0x02); memset(key + 0x02, 0x00, 0x0E); memcpy(key + 0x10, dump + 0x1D4, 0x08); @@ -21,14 +21,14 @@ void nfc3d_amiibo_calc_seed(const uint8_t *dump, uint8_t *key) { memcpy(key + 0x20, dump + 0x1E8, 0x20); } -void nfc3d_amiibo_keygen(const nfc3d_keygen_masterkeys *masterKeys, const uint8_t *dump, nfc3d_keygen_derivedkeys *derivedKeys) { +static void nfc3d_amiibo_keygen(const nfc3d_keygen_masterkeys *masterKeys, const uint8_t *dump, nfc3d_keygen_derivedkeys *derivedKeys) { uint8_t seed[NFC3D_KEYGEN_SEED_SIZE]; nfc3d_amiibo_calc_seed(dump, seed); nfc3d_keygen(masterKeys, seed, derivedKeys); } -void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys *keys, const uint8_t *in, uint8_t *out) { +static void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys *keys, const uint8_t *in, uint8_t *out) { mbedtls_aes_context aes; size_t nc_off = 0; unsigned char nonce_counter[16]; @@ -47,7 +47,7 @@ void nfc3d_amiibo_cipher(const nfc3d_keygen_derivedkeys *keys, const uint8_t *in memcpy(out + 0x1D4, in + 0x1D4, 0x034); } -void nfc3d_amiibo_tag_to_internal(const uint8_t *tag, uint8_t *intl) { +static void nfc3d_amiibo_tag_to_internal(const uint8_t *tag, uint8_t *intl) { memcpy(intl + 0x000, tag + 0x008, 0x008); memcpy(intl + 0x008, tag + 0x080, 0x020); memcpy(intl + 0x028, tag + 0x010, 0x024); @@ -57,7 +57,7 @@ void nfc3d_amiibo_tag_to_internal(const uint8_t *tag, uint8_t *intl) { memcpy(intl + 0x1DC, tag + 0x054, 0x02C); } -void nfc3d_amiibo_internal_to_tag(const uint8_t *intl, uint8_t *tag) { +static void nfc3d_amiibo_internal_to_tag(const uint8_t *intl, uint8_t *tag) { memcpy(tag + 0x008, intl + 0x000, 0x008); memcpy(tag + 0x080, intl + 0x008, 0x020); memcpy(tag + 0x010, intl + 0x028, 0x024); diff --git a/client/deps/amiitool/keygen.c b/client/deps/amiitool/keygen.c index f148c0dc8..6322a0fe9 100644 --- a/client/deps/amiitool/keygen.c +++ b/client/deps/amiitool/keygen.c @@ -10,7 +10,7 @@ #include #include -void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys *baseKeys, const uint8_t *baseSeed, uint8_t *output, size_t *outputSize) { +static void nfc3d_keygen_prepare_seed(const nfc3d_keygen_masterkeys *baseKeys, const uint8_t *baseSeed, uint8_t *output, size_t *outputSize) { assert(baseKeys != NULL); assert(baseSeed != NULL); assert(output != NULL); diff --git a/client/deps/hardnested/hardnested_bf_core.c b/client/deps/hardnested/hardnested_bf_core.c index 9402d9684..0f2d57f16 100644 --- a/client/deps/hardnested/hardnested_bf_core.c +++ b/client/deps/hardnested/hardnested_bf_core.c @@ -556,7 +556,7 @@ void SetSIMDInstr(SIMDExecInstr instr) { bitslice_test_nonces_function_p = &bitslice_test_nonces_dispatch; } -static SIMDExecInstr GetSIMDInstr() { +static SIMDExecInstr GetSIMDInstr(void) { SIMDExecInstr instr = SIMD_NONE; #if defined (__i386__) || defined (__x86_64__) @@ -578,7 +578,7 @@ static SIMDExecInstr GetSIMDInstr() { return instr; } -SIMDExecInstr GetSIMDInstrAuto() { +SIMDExecInstr GetSIMDInstrAuto(void) { SIMDExecInstr instr = intSIMDInstr; if (instr == SIMD_AUTO) return GetSIMDInstr(); diff --git a/client/deps/hardnested/hardnested_bruteforce.c b/client/deps/hardnested/hardnested_bruteforce.c index 159454110..82f8c6c04 100644 --- a/client/deps/hardnested/hardnested_bruteforce.c +++ b/client/deps/hardnested/hardnested_bruteforce.c @@ -433,7 +433,7 @@ static bool read_bench_data(statelist_t *test_candidates) { } -float brute_force_benchmark() { +float brute_force_benchmark(void) { statelist_t test_candidates[NUM_BRUTE_FORCE_THREADS]; test_candidates[0].states[ODD_STATE] = malloc((TEST_BENCH_SIZE + 1) * sizeof(uint32_t)); diff --git a/client/deps/jansson/hashtable.c b/client/deps/jansson/hashtable.c index 38c10a0c7..23fbc867b 100644 --- a/client/deps/jansson/hashtable.c +++ b/client/deps/jansson/hashtable.c @@ -5,14 +5,14 @@ * it under the terms of the MIT license. See LICENSE for details. */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include #endif #include #include -#if HAVE_STDINT_H +#ifdef HAVE_STDINT_H #include #endif diff --git a/client/deps/jansson/hashtable_seed.c b/client/deps/jansson/hashtable_seed.c index 3856691d3..715279879 100644 --- a/client/deps/jansson/hashtable_seed.c +++ b/client/deps/jansson/hashtable_seed.c @@ -162,7 +162,7 @@ static int seed_from_timestamp_and_pid(uint32_t *seed) { return 0; } -static uint32_t generate_seed() { +static uint32_t generate_seed(void) { uint32_t seed = 0; int done = 0; diff --git a/client/deps/liblua/llex.c b/client/deps/liblua/llex.c index 3f0a1601b..bde26fa4f 100644 --- a/client/deps/liblua/llex.c +++ b/client/deps/liblua/llex.c @@ -197,7 +197,7 @@ static void buffreplace(LexState *ls, char from, char to) { } -#if ANDROID +#if defined(ANDROID) #define getlocaldecpoint() '.' #elif !defined(getlocaledecpoint) #define getlocaledecpoint() (localeconv()->decimal_point[0]) diff --git a/client/src/cmdhfmfu.h b/client/src/cmdhfmfu.h index 85f6a8475..be52b1ed8 100644 --- a/client/src/cmdhfmfu.h +++ b/client/src/cmdhfmfu.h @@ -30,7 +30,7 @@ void printMFUdumpEx(mfu_dump_t *card, uint16_t pages, uint8_t startpage); int CmdHFMFUltra(const char *Cmd); uint32_t ul_ev1_pwdgenA(uint8_t *uid); -uint32_t ul_ev1_pwdgenA(uint8_t *uid); +uint32_t ul_ev1_pwdgenB(uint8_t *uid); uint32_t ul_ev1_pwdgenC(uint8_t *uid); uint32_t ul_ev1_pwdgenD(uint8_t *uid); diff --git a/common/crapto1/crapto1.c b/common/crapto1/crapto1.c index e697b68f0..0d7aaa49e 100644 --- a/common/crapto1/crapto1.c +++ b/common/crapto1/crapto1.c @@ -26,7 +26,7 @@ #if !defined LOWMEM && defined __GNUC__ static uint8_t filterlut[1 << 20]; -static void __attribute__((constructor)) fill_lut() { +static void __attribute__((constructor)) fill_lut(void) { uint32_t i; for (i = 0; i < 1 << 20; ++i) filterlut[i] = filter(i); diff --git a/common/zlib/deflate.c b/common/zlib/deflate.c index a44bdb3ab..f06654f95 100644 --- a/common/zlib/deflate.c +++ b/common/zlib/deflate.c @@ -82,6 +82,9 @@ local void slide_hash OF((deflate_state *s)); local void fill_window OF((deflate_state *s)); local block_state deflate_stored OF((deflate_state *s, int flush)); local block_state deflate_fast OF((deflate_state *s, int flush)); +#ifdef ZLIB_PM3_TUNED +local uInt try_harder OF((deflate_state *s, uInt strstart, uInt lookahead, IPos hash_head)); +#endif #ifndef FASTEST local block_state deflate_slow OF((deflate_state *s, int flush)); #endif