From 802fdc129b4592282f3fe404f681b26d0b378b45 Mon Sep 17 00:00:00 2001 From: sundb Date: Sun, 10 Jan 2021 01:52:42 +0800 Subject: [PATCH] Fix compile warning when define REDIS_TEST (#8261) Co-authored-by: Oran Agra --- src/crc64.c | 4 ++-- src/intset.c | 6 ------ src/quicklist.c | 23 +++++++---------------- src/rax.c | 2 +- src/ziplist.c | 4 ++-- 5 files changed, 12 insertions(+), 27 deletions(-) diff --git a/src/crc64.c b/src/crc64.c index 4cbc019f6..6c9432c4a 100644 --- a/src/crc64.c +++ b/src/crc64.c @@ -134,7 +134,7 @@ int crc64Test(int argc, char *argv[]) { printf("[calcula]: e9c6d914c4b8d9ca == %016" PRIx64 "\n", (uint64_t)_crc64(0, "123456789", 9)); printf("[64speed]: e9c6d914c4b8d9ca == %016" PRIx64 "\n", - (uint64_t)crc64(0, "123456789", 9)); + (uint64_t)crc64(0, (unsigned char*)"123456789", 9)); char li[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed " "do eiusmod tempor incididunt ut labore et dolore magna " "aliqua. Ut enim ad minim veniam, quis nostrud exercitation " @@ -146,7 +146,7 @@ int crc64Test(int argc, char *argv[]) { printf("[calcula]: c7794709e69683b3 == %016" PRIx64 "\n", (uint64_t)_crc64(0, li, sizeof(li))); printf("[64speed]: c7794709e69683b3 == %016" PRIx64 "\n", - (uint64_t)crc64(0, li, sizeof(li))); + (uint64_t)crc64(0, (unsigned char*)li, sizeof(li))); return 0; } diff --git a/src/intset.c b/src/intset.c index 54afae875..74de87acb 100644 --- a/src/intset.c +++ b/src/intset.c @@ -358,12 +358,6 @@ static long long usec(void) { return (((long long)tv.tv_sec)*1000000)+tv.tv_usec; } -#define assert(_e) ((_e)?(void)0:(_assert(#_e,__FILE__,__LINE__),exit(1))) -static void _assert(char *estr, char *file, int line) { - printf("\n\n=== ASSERTION FAILED ===\n"); - printf("==> %s:%d '%s' is not true\n",file,line,estr); -} - static intset *createSet(int bits, int size) { uint64_t mask = (1< #include -#define assert(_e) \ - do { \ - if (!(_e)) { \ - printf("\n\n=== ASSERTION FAILED ===\n"); \ - printf("==> %s:%d '%s' is not true\n", __FILE__, __LINE__, #_e); \ - err++; \ - } \ - } while (0) - #define yell(str, ...) printf("ERROR! " str "\n\n", __VA_ARGS__) #define OK printf("\tOK\n") @@ -1529,7 +1520,7 @@ void quicklistBookmarksClear(quicklist *ql) { #define ERR(x, ...) \ do { \ - printf("%s:%s:%d:\t", __FILE__, __FUNCTION__, __LINE__); \ + printf("%s:%s:%d:\t", __FILE__, __func__, __LINE__); \ printf("ERROR! " x "\n", __VA_ARGS__); \ err++; \ } while (0) @@ -1614,7 +1605,7 @@ static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count, ql_info(ql); if (len != ql->len) { - yell("quicklist length wrong: expected %d, got %u", len, ql->len); + yell("quicklist length wrong: expected %d, got %lu", len, ql->len); errors++; } @@ -1670,7 +1661,7 @@ static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count, if (node->encoding != QUICKLIST_NODE_ENCODING_RAW) { yell("Incorrect compression: node %d is " "compressed at depth %d ((%u, %u); total " - "nodes: %u; size: %u; recompress: %d)", + "nodes: %lu; size: %u; recompress: %d)", at, ql->compress, low_raw, high_raw, ql->len, node->sz, node->recompress); errors++; @@ -1680,7 +1671,7 @@ static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count, !node->attempted_compress) { yell("Incorrect non-compression: node %d is NOT " "compressed at depth %d ((%u, %u); total " - "nodes: %u; size: %u; recompress: %d; attempted: %d)", + "nodes: %lu; size: %u; recompress: %d; attempted: %d)", at, ql->compress, low_raw, high_raw, ql->len, node->sz, node->recompress, node->attempted_compress); errors++; @@ -2706,7 +2697,7 @@ int quicklistTest(int argc, char *argv[]) { if (node->encoding != QUICKLIST_NODE_ENCODING_RAW) { ERR("Incorrect compression: node %d is " "compressed at depth %d ((%u, %u); total " - "nodes: %u; size: %u)", + "nodes: %lu; size: %u)", at, depth, low_raw, high_raw, ql->len, node->sz); } @@ -2714,7 +2705,7 @@ int quicklistTest(int argc, char *argv[]) { if (node->encoding != QUICKLIST_NODE_ENCODING_LZF) { ERR("Incorrect non-compression: node %d is NOT " "compressed at depth %d ((%u, %u); total " - "nodes: %u; size: %u; attempted: %d)", + "nodes: %lu; size: %u; attempted: %d)", at, depth, low_raw, high_raw, ql->len, node->sz, node->attempted_compress); } diff --git a/src/rax.c b/src/rax.c index 1ffb42287..0826b974a 100644 --- a/src/rax.c +++ b/src/rax.c @@ -61,7 +61,7 @@ void raxDebugShowNode(const char *msg, raxNode *n); #ifdef RAX_DEBUG_MSG #define debugf(...) \ if (raxDebugMsg) { \ - printf("%s:%s:%d:\t", __FILE__, __FUNCTION__, __LINE__); \ + printf("%s:%s:%d:\t", __FILE__, __func__, __LINE__); \ printf(__VA_ARGS__); \ fflush(stdout); \ } diff --git a/src/ziplist.c b/src/ziplist.c index 96ba47e13..a4f38c5e8 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -1713,7 +1713,7 @@ int ziplistTest(int argc, char **argv) { if (p == NULL) { printf("No entry\n"); } else { - printf("ERROR: Out of range index should return NULL, returned offset: %ld\n", p-zl); + printf("ERROR: Out of range index should return NULL, returned offset: %ld\n", (long)(p-zl)); return 1; } printf("\n"); @@ -1763,7 +1763,7 @@ int ziplistTest(int argc, char **argv) { if (p == NULL) { printf("No entry\n"); } else { - printf("ERROR: Out of range index should return NULL, returned offset: %ld\n", p-zl); + printf("ERROR: Out of range index should return NULL, returned offset: %ld\n", (long)(p-zl)); return 1; } printf("\n");