From ec0872181b882afe69213c2443f074426ccaa94f Mon Sep 17 00:00:00 2001 From: pwpiwi Date: Tue, 23 Jan 2018 08:27:58 +0100 Subject: [PATCH 1/1] fix clang compiler warnings identified in http://www.proxmark.org/forum/viewtopic.php?id=5388 --- client/cmdhfmfhard.c | 40 ----------------------- client/emv/apduinfo.c | 2 +- client/fpga_compress.c | 4 +-- client/hardnested/hardnested_bruteforce.c | 9 +++-- client/util_posix.c | 4 +++ 5 files changed, 14 insertions(+), 45 deletions(-) diff --git a/client/cmdhfmfhard.c b/client/cmdhfmfhard.c index 96c3a989..69ad898d 100644 --- a/client/cmdhfmfhard.c +++ b/client/cmdhfmfhard.c @@ -150,12 +150,6 @@ static inline void set_bit24(uint32_t *bitarray, uint32_t index) } -static inline void clear_bit24(uint32_t *bitarray, uint32_t index) -{ - bitarray[index>>5] &= ~(0x80000000>>(index&0x0000001f)); -} - - static inline uint32_t test_bit24(uint32_t *bitarray, uint32_t index) { return bitarray[index>>5] & (0x80000000>>(index&0x0000001f)); @@ -196,40 +190,6 @@ static inline uint32_t next_state(uint32_t *bitarray, uint32_t state) } -static inline uint32_t next_not_state(uint32_t *bitarray, uint32_t state) -{ - if (++state == 1<<24) return 1<<24; - uint32_t index = state >> 5; - uint_fast8_t bit = state & 0x1f; - uint32_t line = bitarray[index] << bit; - while (bit <= 0x1f) { - if ((line & 0x80000000) == 0) return state; - state++; - bit++; - line <<= 1; - } - index++; - while (bitarray[index] == 0xffffffff && state < 1<<24) { - index++; - state += 0x20; - } - if (state >= 1<<24) return 1<<24; -#if defined __GNUC__ - return state + __builtin_clz(~bitarray[index]); -#else - bit = 0x00; - line = bitarray[index]; - while (bit <= 0x1f) { - if ((line & 0x80000000) == 0) return state; - state++; - bit++; - line <<= 1; - } - return 1<<24; -#endif -} - - #define BITFLIP_2ND_BYTE 0x0200 diff --git a/client/emv/apduinfo.c b/client/emv/apduinfo.c index ec7a64a1..a631c614 100644 --- a/client/emv/apduinfo.c +++ b/client/emv/apduinfo.c @@ -132,7 +132,7 @@ const APDUCode APDUCodeTable[] = { {"6EXX", APDUCODE_TYPE_ERROR, "Instruction class not supported (procedure byte), (ISO 7816-3)"}, {"6F--", APDUCODE_TYPE_ERROR, "Internal exception"}, {"6F00", APDUCODE_TYPE_ERROR, "Command aborted - more exact diagnosis not possible (e.g., operating system error)."}, - {"6FFF", APDUCODE_TYPE_ERROR, "Card dead (overuse, …)"}, + {"6FFF", APDUCODE_TYPE_ERROR, "Card dead (overuse, ...)"}, {"6FXX", APDUCODE_TYPE_ERROR, "No precise diagnosis (procedure byte), (ISO 7816-3)"}, {"9---", APDUCODE_TYPE_NONE, ""}, {"9000", APDUCODE_TYPE_INFO, "Command successfully executed (OK)."}, diff --git a/client/fpga_compress.c b/client/fpga_compress.c index a672ab58..fc298a8b 100644 --- a/client/fpga_compress.c +++ b/client/fpga_compress.c @@ -297,9 +297,9 @@ int main(int argc, char **argv) } infiles = calloc(num_input_files, sizeof(FILE*)); for (uint16_t i = 0; i < num_input_files; i++) { - infiles[i] = fopen(argv[i+hardnested_mode?2:1], "rb"); + infiles[i] = fopen(argv[i+(hardnested_mode?2:1)], "rb"); if (infiles[i] == NULL) { - fprintf(stderr, "Error. Cannot open input file %s", argv[i+hardnested_mode?2:1]); + fprintf(stderr, "Error. Cannot open input file %s", argv[i+(hardnested_mode?2:1)]); return(EXIT_FAILURE); } } diff --git a/client/hardnested/hardnested_bruteforce.c b/client/hardnested/hardnested_bruteforce.c index 3072fc52..deea69d8 100644 --- a/client/hardnested/hardnested_bruteforce.c +++ b/client/hardnested/hardnested_bruteforce.c @@ -139,8 +139,13 @@ bool verify_key(uint32_t cuid, noncelist_t *nonces, uint8_t *best_first_bytes, u return true; } - -static void* __attribute__((force_align_arg_pointer)) crack_states_thread(void* x){ +static void* +#ifdef __has_attribute +#if __has_attribute(force_align_arg_pointer) +__attribute__((force_align_arg_pointer)) +#endif +#endif +crack_states_thread(void* x){ struct arg { bool silent; diff --git a/client/util_posix.c b/client/util_posix.c index 8f3ed46b..32158ada 100644 --- a/client/util_posix.c +++ b/client/util_posix.c @@ -37,8 +37,12 @@ void msleep(uint32_t n) { #ifdef __APPLE__ +#ifndef CLOCK_MONOTONIC #define CLOCK_MONOTONIC (1) +#endif +#ifndef CLOCK_REALTIME #define CLOCK_REALTIME (2) +#endif #include #include -- 2.39.5