Permalink
Browse files

removed a number of stupid compilation warnings on Linux

  • Loading branch information...
1 parent 92e2822 commit 10c12171cc2f94087c85651b14831c1e52daa087 @antirez committed Nov 2, 2010
Showing with 21 additions and 18 deletions.
  1. +2 −1 src/redis-check-dump.c
  2. +1 −1 src/redis.c
  3. +16 −14 src/ziplist.c
  4. +2 −2 src/zipmap.c
View
@@ -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]);
}
}
View
@@ -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;
View
@@ -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);
}
View
@@ -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("[");

0 comments on commit 10c1217

Please sign in to comment.