Commit 066c6de7 authored by Björn Svensson's avatar Björn Svensson
Browse files

Use size_t/long to avoid truncation

Equivalent changes introduced to redis sds.c via:
https://github.com/redis/redis/pull/4568
parent f8de9a4b
...@@ -174,7 +174,7 @@ void sdsfree(sds s) { ...@@ -174,7 +174,7 @@ void sdsfree(sds s) {
* the output will be "6" as the string was modified but the logical length * the output will be "6" as the string was modified but the logical length
* remains 6 bytes. */ * remains 6 bytes. */
void sdsupdatelen(sds s) { void sdsupdatelen(sds s) {
int reallen = strlen(s); size_t reallen = strlen(s);
sdssetlen(s, reallen); sdssetlen(s, reallen);
} }
...@@ -580,7 +580,7 @@ sds sdscatprintf(sds s, const char *fmt, ...) { ...@@ -580,7 +580,7 @@ sds sdscatprintf(sds s, const char *fmt, ...) {
*/ */
sds sdscatfmt(sds s, char const *fmt, ...) { sds sdscatfmt(sds s, char const *fmt, ...) {
const char *f = fmt; const char *f = fmt;
int i; long i;
va_list ap; va_list ap;
va_start(ap,fmt); va_start(ap,fmt);
...@@ -755,14 +755,14 @@ int sdsrange(sds s, ssize_t start, ssize_t end) { ...@@ -755,14 +755,14 @@ int sdsrange(sds s, ssize_t start, ssize_t end) {
/* Apply tolower() to every character of the sds string 's'. */ /* Apply tolower() to every character of the sds string 's'. */
void sdstolower(sds s) { void sdstolower(sds s) {
int len = sdslen(s), j; size_t len = sdslen(s), j;
for (j = 0; j < len; j++) s[j] = tolower(s[j]); for (j = 0; j < len; j++) s[j] = tolower(s[j]);
} }
/* Apply toupper() to every character of the sds string 's'. */ /* Apply toupper() to every character of the sds string 's'. */
void sdstoupper(sds s) { void sdstoupper(sds s) {
int len = sdslen(s), j; size_t len = sdslen(s), j;
for (j = 0; j < len; j++) s[j] = toupper(s[j]); for (j = 0; j < len; j++) s[j] = toupper(s[j]);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment