Permalink
Browse files

[Portability] strtol and strtoul fixes.

  • Loading branch information...
enricogior committed Jul 1, 2016
1 parent 4d3b8f4 commit 2388de8062976eb2da7a7d848c58a075f4f8c1c9
View
@@ -648,7 +648,7 @@ static char *nextArgument(char *start, char **str, size_t *len) {
if (p == NULL) return NULL;
}
*len = (int)PORT_STRTOL(p+1,NULL,10);
*len = (int)strtol(p+1,NULL,10);
p = strchr(p,'\r');
assert(p);
*str = p+2;
@@ -34,6 +34,11 @@
#define strcasecmp _stricmp
#define strtoll _strtoi64
#ifdef _WIN64
#define strtol _strtoi64
#define strtoul _strtoui64
#endif
#define sleep(x) Sleep((x)*1000)
/* Redis calls usleep(1) to give thread some time.
* Sleep(0) should do the same on Windows.
@@ -70,10 +70,4 @@ typedef int pid_t;
typedef unsigned __int32 u_int32_t;
#endif
#ifdef _WIN64
#define PORT_STRTOL strtoll
#else
#define PORT_STRTOL strtol
#endif
#endif
View
@@ -674,7 +674,7 @@ int loadAppendOnlyFile(char *filename) {
goto readerr;
}
if (buf[0] != '$') goto fmterr;
len = PORT_STRTOL(buf+1,NULL,10);
len = strtol(buf+1,NULL,10);
argsds = sdsnewlen(NULL,len);
if (len && fread(argsds,len,1,fp) == 0) {
sdsfree(argsds);
View
@@ -153,7 +153,7 @@ void loadServerConfigFromString(char *config) {
server.unixsocket = zstrdup(argv[1]);
} else if (!strcasecmp(argv[0],"unixsocketperm") && argc == 2) {
errno = 0;
server.unixsocketperm = (mode_t)PORT_STRTOL(argv[1], NULL, 8);
server.unixsocketperm = (mode_t)strtol(argv[1], NULL, 8);
if (errno || server.unixsocketperm > 0777) {
err = "Invalid socket file permissions"; goto loaderr;
}
View
@@ -75,7 +75,7 @@ int readLong(FILE *fp, char prefix, PORT_LONG *target) {
ERROR("Expected prefix '%c', got: '%c'",buf[0],prefix);
return 0;
}
*target = PORT_STRTOL(buf+1,&eptr,10);
*target = strtol(buf+1,&eptr,10);
return consumeNewline(eptr);
}
View
@@ -225,7 +225,7 @@ int processHeader(void) {
ERROR("Wrong signature in header\n");
}
dump_version = (int)PORT_STRTOL(buf + 5, NULL, 10);
dump_version = (int) strtol(buf + 5, NULL, 10);
if (dump_version < 1 || dump_version > 6) {
ERROR("Unknown RDB format version: %d\n", dump_version);
}
View
@@ -1909,7 +1909,7 @@ static PORT_LONG getLongInfoField(char *info, char *field) {
PORT_LONG l;
if (!value) return PORT_LONG_MIN;
l = PORT_STRTOL(value, NULL, 10);
l = strtol(value,NULL,10);
free(value);
return l;
}
View
@@ -2720,7 +2720,7 @@ sds genRedisInfoString(char *section) {
"config_file:%s\r\n",
REDIS_VERSION,
redisGitSHA1(),
PORT_STRTOL(redisGitDirty(),NULL,10) > 0,
strtol(redisGitDirty(),NULL,10) > 0,
(PORT_ULONGLONG) redisBuildId(),
mode,
#ifdef _WIN32
@@ -3521,7 +3521,7 @@ void redisAsciiArt(void) {
"Redis %s (%s/%d) %s bit, %s mode, port %d, pid %ld ready to start.",
REDIS_VERSION,
redisGitSHA1(),
PORT_STRTOL(redisGitDirty(),NULL,10) > 0,
strtol(redisGitDirty(),NULL,10) > 0,
(sizeof(PORT_LONG) == 8) ? "64" : "32",
mode, server.port,
(PORT_LONG) getpid()
@@ -3530,7 +3530,7 @@ void redisAsciiArt(void) {
snprintf(buf,1024*16,ascii_logo,
REDIS_VERSION,
redisGitSHA1(),
PORT_STRTOL(redisGitDirty(),NULL,10) > 0,
strtol(redisGitDirty(),NULL,10) > 0,
(sizeof(PORT_LONG) == 8) ? "64" : "32",
mode, server.port,
(PORT_LONG) getpid()
View
@@ -1125,7 +1125,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
"MASTER <-> SLAVE sync: receiving streamed RDB from master");
} else {
usemark = 0;
server.repl_transfer_size = PORT_STRTOL(buf+1,NULL,10);
server.repl_transfer_size = strtol(buf+1,NULL,10);
redisLog(REDIS_NOTICE,
"MASTER <-> SLAVE sync: receiving %lld bytes from master",
(PORT_LONGLONG) server.repl_transfer_size);
View
@@ -378,7 +378,7 @@ size_t zmalloc_get_smap_bytes_by_field(char *field) {
char *p = strchr(line,'k');
if (p) {
*p = '\0';
bytes += PORT_STRTOL(line+flen,NULL,10) * 1024;
bytes += strtol(line+flen,NULL,10) * 1024;
}
}
}

0 comments on commit 2388de8

Please sign in to comment.