Fix compile warning when define REDIS_TEST (#8261)

Co-authored-by: Oran Agra <oran@redislabs.com>
This commit is contained in:
sundb 2021-01-10 01:52:42 +08:00 committed by GitHub
parent 46729a7404
commit 802fdc129b
5 changed files with 12 additions and 27 deletions

View File

@ -134,7 +134,7 @@ int crc64Test(int argc, char *argv[]) {
printf("[calcula]: e9c6d914c4b8d9ca == %016" PRIx64 "\n", printf("[calcula]: e9c6d914c4b8d9ca == %016" PRIx64 "\n",
(uint64_t)_crc64(0, "123456789", 9)); (uint64_t)_crc64(0, "123456789", 9));
printf("[64speed]: e9c6d914c4b8d9ca == %016" PRIx64 "\n", 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 " char li[] = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed "
"do eiusmod tempor incididunt ut labore et dolore magna " "do eiusmod tempor incididunt ut labore et dolore magna "
"aliqua. Ut enim ad minim veniam, quis nostrud exercitation " "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", printf("[calcula]: c7794709e69683b3 == %016" PRIx64 "\n",
(uint64_t)_crc64(0, li, sizeof(li))); (uint64_t)_crc64(0, li, sizeof(li)));
printf("[64speed]: c7794709e69683b3 == %016" PRIx64 "\n", printf("[64speed]: c7794709e69683b3 == %016" PRIx64 "\n",
(uint64_t)crc64(0, li, sizeof(li))); (uint64_t)crc64(0, (unsigned char*)li, sizeof(li)));
return 0; return 0;
} }

View File

@ -358,12 +358,6 @@ static long long usec(void) {
return (((long long)tv.tv_sec)*1000000)+tv.tv_usec; 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) { static intset *createSet(int bits, int size) {
uint64_t mask = (1<<bits)-1; uint64_t mask = (1<<bits)-1;
uint64_t value; uint64_t value;

View File

@ -66,7 +66,7 @@ static const size_t optimization_level[] = {4096, 8192, 16384, 32768, 65536};
#else #else
#define D(...) \ #define D(...) \
do { \ do { \
printf("%s:%s:%d:\t", __FILE__, __FUNCTION__, __LINE__); \ printf("%s:%s:%d:\t", __FILE__, __func__, __LINE__); \
printf(__VA_ARGS__); \ printf(__VA_ARGS__); \
printf("\n"); \ printf("\n"); \
} while (0) } while (0)
@ -1508,15 +1508,6 @@ void quicklistBookmarksClear(quicklist *ql) {
#include <stdint.h> #include <stdint.h>
#include <sys/time.h> #include <sys/time.h>
#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 yell(str, ...) printf("ERROR! " str "\n\n", __VA_ARGS__)
#define OK printf("\tOK\n") #define OK printf("\tOK\n")
@ -1529,7 +1520,7 @@ void quicklistBookmarksClear(quicklist *ql) {
#define ERR(x, ...) \ #define ERR(x, ...) \
do { \ do { \
printf("%s:%s:%d:\t", __FILE__, __FUNCTION__, __LINE__); \ printf("%s:%s:%d:\t", __FILE__, __func__, __LINE__); \
printf("ERROR! " x "\n", __VA_ARGS__); \ printf("ERROR! " x "\n", __VA_ARGS__); \
err++; \ err++; \
} while (0) } while (0)
@ -1614,7 +1605,7 @@ static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count,
ql_info(ql); ql_info(ql);
if (len != ql->len) { 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++; errors++;
} }
@ -1670,7 +1661,7 @@ static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count,
if (node->encoding != QUICKLIST_NODE_ENCODING_RAW) { if (node->encoding != QUICKLIST_NODE_ENCODING_RAW) {
yell("Incorrect compression: node %d is " yell("Incorrect compression: node %d is "
"compressed at depth %d ((%u, %u); total " "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, at, ql->compress, low_raw, high_raw, ql->len, node->sz,
node->recompress); node->recompress);
errors++; errors++;
@ -1680,7 +1671,7 @@ static int _ql_verify(quicklist *ql, uint32_t len, uint32_t count,
!node->attempted_compress) { !node->attempted_compress) {
yell("Incorrect non-compression: node %d is NOT " yell("Incorrect non-compression: node %d is NOT "
"compressed at depth %d ((%u, %u); total " "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, at, ql->compress, low_raw, high_raw, ql->len, node->sz,
node->recompress, node->attempted_compress); node->recompress, node->attempted_compress);
errors++; errors++;
@ -2706,7 +2697,7 @@ int quicklistTest(int argc, char *argv[]) {
if (node->encoding != QUICKLIST_NODE_ENCODING_RAW) { if (node->encoding != QUICKLIST_NODE_ENCODING_RAW) {
ERR("Incorrect compression: node %d is " ERR("Incorrect compression: node %d is "
"compressed at depth %d ((%u, %u); total " "compressed at depth %d ((%u, %u); total "
"nodes: %u; size: %u)", "nodes: %lu; size: %u)",
at, depth, low_raw, high_raw, ql->len, at, depth, low_raw, high_raw, ql->len,
node->sz); node->sz);
} }
@ -2714,7 +2705,7 @@ int quicklistTest(int argc, char *argv[]) {
if (node->encoding != QUICKLIST_NODE_ENCODING_LZF) { if (node->encoding != QUICKLIST_NODE_ENCODING_LZF) {
ERR("Incorrect non-compression: node %d is NOT " ERR("Incorrect non-compression: node %d is NOT "
"compressed at depth %d ((%u, %u); total " "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, at, depth, low_raw, high_raw, ql->len,
node->sz, node->attempted_compress); node->sz, node->attempted_compress);
} }

View File

@ -61,7 +61,7 @@ void raxDebugShowNode(const char *msg, raxNode *n);
#ifdef RAX_DEBUG_MSG #ifdef RAX_DEBUG_MSG
#define debugf(...) \ #define debugf(...) \
if (raxDebugMsg) { \ if (raxDebugMsg) { \
printf("%s:%s:%d:\t", __FILE__, __FUNCTION__, __LINE__); \ printf("%s:%s:%d:\t", __FILE__, __func__, __LINE__); \
printf(__VA_ARGS__); \ printf(__VA_ARGS__); \
fflush(stdout); \ fflush(stdout); \
} }

View File

@ -1713,7 +1713,7 @@ int ziplistTest(int argc, char **argv) {
if (p == NULL) { if (p == NULL) {
printf("No entry\n"); printf("No entry\n");
} else { } 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; return 1;
} }
printf("\n"); printf("\n");
@ -1763,7 +1763,7 @@ int ziplistTest(int argc, char **argv) {
if (p == NULL) { if (p == NULL) {
printf("No entry\n"); printf("No entry\n");
} else { } 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; return 1;
} }
printf("\n"); printf("\n");