From: antirez Date: Tue, 2 Nov 2010 10:15:09 +0000 (+0100) Subject: removed a number of stupid compilation warnings on Linux X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/10c12171cc2f94087c85651b14831c1e52daa087 removed a number of stupid compilation warnings on Linux --- diff --git a/src/redis-check-dump.c b/src/redis-check-dump.c index 987e1db3..93b9c99d 100644 --- a/src/redis-check-dump.c +++ b/src/redis-check-dump.c @@ -538,7 +538,8 @@ void printErrorStack(entry *e) { /* display error stack */ for (i = 0; i < errors.level; i++) { - printf("0x%08lx - %s\n", errors.offset[i], errors.error[i]); + printf("0x%08lx - %s\n", + (unsigned long) errors.offset[i], errors.error[i]); } } diff --git a/src/redis.c b/src/redis.c index 4aa19560..6375555b 100644 --- a/src/redis.c +++ b/src/redis.c @@ -1250,7 +1250,7 @@ void freeMemoryIfNeeded(void) { if (tryFreeOneObjectFromFreelist() == REDIS_OK) continue; for (j = 0; j < server.dbnum; j++) { - long bestval; + long bestval = 0; /* just to prevent warning */ sds bestkey = NULL; struct dictEntry *de; redisDb *db = server.db+j; diff --git a/src/ziplist.c b/src/ziplist.c index 98ad3113..a9923d65 100644 --- a/src/ziplist.c +++ b/src/ziplist.c @@ -754,9 +754,9 @@ void ziplistRepr(unsigned char *zl) { "pls: %2u, " "payload %5u" "} ", - (long unsigned int)p, + (long unsigned)p, index, - p-zl, + (unsigned long) (p-zl), entry.headersize+entry.len, entry.headersize, entry.prevrawlen, @@ -765,10 +765,11 @@ void ziplistRepr(unsigned char *zl) { p += entry.headersize; if (ZIP_IS_STR(entry.encoding)) { if (entry.len > 40) { - fwrite(p,40,1,stdout); + if (fwrite(p,40,1,stdout) == 0) perror("fwrite"); printf("..."); } else { - fwrite(p,entry.len,1,stdout); + if (entry.len && + fwrite(p,entry.len,1,stdout) == 0) perror("fwrite"); } } else { printf("%lld", (long long) zipLoadInteger(p,entry.encoding)); @@ -857,7 +858,7 @@ void pop(unsigned char *zl, int where) { printf("Pop tail: "); if (vstr) - fwrite(vstr,vlen,1,stdout); + if (vlen && fwrite(vstr,vlen,1,stdout) == 0) perror("fwrite"); else printf("%lld", vlong); @@ -932,7 +933,7 @@ int main(int argc, char **argv) { return 1; } if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); printf("\n"); } else { printf("%lld\n", value); @@ -962,7 +963,7 @@ int main(int argc, char **argv) { return 1; } if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); printf("\n"); } else { printf("%lld\n", value); @@ -979,7 +980,7 @@ int main(int argc, char **argv) { return 1; } if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); printf("\n"); } else { printf("%lld\n", value); @@ -1007,7 +1008,7 @@ int main(int argc, char **argv) { while (ziplistGet(p, &entry, &elen, &value)) { printf("Entry: "); if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); } else { printf("%lld", value); } @@ -1024,7 +1025,7 @@ int main(int argc, char **argv) { while (ziplistGet(p, &entry, &elen, &value)) { printf("Entry: "); if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); } else { printf("%lld", value); } @@ -1041,7 +1042,7 @@ int main(int argc, char **argv) { while (ziplistGet(p, &entry, &elen, &value)) { printf("Entry: "); if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); } else { printf("%lld", value); } @@ -1070,7 +1071,7 @@ int main(int argc, char **argv) { while (ziplistGet(p, &entry, &elen, &value)) { printf("Entry: "); if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); } else { printf("%lld", value); } @@ -1087,7 +1088,7 @@ int main(int argc, char **argv) { while (ziplistGet(p, &entry, &elen, &value)) { printf("Entry: "); if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) perror("fwrite"); } else { printf("%lld", value); } @@ -1144,7 +1145,8 @@ int main(int argc, char **argv) { } else { printf("Entry: "); if (entry) { - fwrite(entry,elen,1,stdout); + if (elen && fwrite(entry,elen,1,stdout) == 0) + perror("fwrite"); } else { printf("%lld",value); } diff --git a/src/zipmap.c b/src/zipmap.c index 35faeabe..be780a82 100644 --- a/src/zipmap.c +++ b/src/zipmap.c @@ -374,14 +374,14 @@ void zipmapRepr(unsigned char *p) { l = zipmapDecodeLength(p); printf("{key %u}",l); p += zipmapEncodeLength(NULL,l); - fwrite(p,l,1,stdout); + if (l != 0 && fwrite(p,l,1,stdout) == 0) perror("fwrite"); p += l; l = zipmapDecodeLength(p); printf("{value %u}",l); p += zipmapEncodeLength(NULL,l); e = *p++; - fwrite(p,l,1,stdout); + if (l != 0 && fwrite(p,l,1,stdout) == 0) perror("fwrite"); p += l+e; if (e) { printf("[");