mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
fix sprintf and snprintf format string
There are some cases of printing unsigned integer with %d conversion specificator and vice versa (signed integer with %u specificator). Patch by Sergey Polovko. Backported to Redis from Disque.
This commit is contained in:
parent
e6a5117426
commit
96628cc40d
@ -516,7 +516,7 @@ void _serverAssertPrintClientInfo(client *c) {
|
|||||||
if (c->argv[j]->type == OBJ_STRING && sdsEncodedObject(c->argv[j])) {
|
if (c->argv[j]->type == OBJ_STRING && sdsEncodedObject(c->argv[j])) {
|
||||||
arg = (char*) c->argv[j]->ptr;
|
arg = (char*) c->argv[j]->ptr;
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf,sizeof(buf),"Object type: %d, encoding: %d",
|
snprintf(buf,sizeof(buf),"Object type: %u, encoding: %u",
|
||||||
c->argv[j]->type, c->argv[j]->encoding);
|
c->argv[j]->type, c->argv[j]->encoding);
|
||||||
arg = buf;
|
arg = buf;
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ static sds cliFormatReplyTTY(redisReply *r, char *prefix) {
|
|||||||
_prefix = sdscat(sdsnew(prefix),_prefixlen);
|
_prefix = sdscat(sdsnew(prefix),_prefixlen);
|
||||||
|
|
||||||
/* Setup prefix format for every entry */
|
/* Setup prefix format for every entry */
|
||||||
snprintf(_prefixfmt,sizeof(_prefixfmt),"%%s%%%dd) ",idxlen);
|
snprintf(_prefixfmt,sizeof(_prefixfmt),"%%s%%%ud) ",idxlen);
|
||||||
|
|
||||||
for (i = 0; i < r->elements; i++) {
|
for (i = 0; i < r->elements; i++) {
|
||||||
/* Don't use the prefix for the first element, as the parent
|
/* Don't use the prefix for the first element, as the parent
|
||||||
@ -2050,7 +2050,7 @@ void bytesToHuman(char *s, long long n) {
|
|||||||
}
|
}
|
||||||
if (n < 1024) {
|
if (n < 1024) {
|
||||||
/* Bytes */
|
/* Bytes */
|
||||||
sprintf(s,"%lluB",n);
|
sprintf(s,"%lldB",n);
|
||||||
return;
|
return;
|
||||||
} else if (n < (1024*1024)) {
|
} else if (n < (1024*1024)) {
|
||||||
d = (double)n/(1024);
|
d = (double)n/(1024);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user