提交 1cf1db97 编写于 作者: E Enrico Giordani

Final portability fixes for 'long' type.

上级 365c4c75
......@@ -180,7 +180,7 @@ void stopAppendOnly(void) {
server.aof_state = REDIS_AOF_OFF;
/* rewrite operation in progress? kill it, wait child exit */
if (server.aof_child_pid != -1) {
redisLog(REDIS_NOTICE, "Killing running AOF rewrite child: %Id", /* PORTABILITY FIX %ld -> %Id */
redisLog(REDIS_NOTICE, "Killing running AOF rewrite child: %Id", WIN_PORT_FIX /* %ld -> %Id */
(PORT_LONG) server.aof_child_pid);
#ifdef _WIN32
AbortForkOperation();
......
......@@ -537,7 +537,7 @@ sds latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) {
}
graph = sdscatprintf(graph,
"%s - high %Iu ms, low %Iu ms (all time high %Iu ms)\n", event, /* PORTABILITY FIX %ld -> %Id, %lu -> %Iu */
"%s - high %Iu ms, low %Iu ms (all time high %Iu ms)\n", event, WIN_PORT_FIX /* %ld -> %Id, %lu -> %Iu */
(PORT_ULONG) max, (PORT_ULONG) min, (PORT_ULONG) ts->max);
for (j = 0; j < LATENCY_GRAPH_COLS; j++)
graph = sdscatlen(graph,"-",1);
......
......@@ -232,8 +232,8 @@ void memtest_test(size_t megabytes, int passes) {
int pass = 0;
if (m == NULL) {
fprintf(stderr,"Unable to allocate %Iu megabytes: %s",
megabytes,strerror(errno)); WIN_PORT_FIX /* %zu -> %Iu */
fprintf(stderr,"Unable to allocate %Iu megabytes: %s", WIN_PORT_FIX /* %zu -> %Iu */
megabytes,strerror(errno));
exit(1);
}
while (pass != passes) {
......
......@@ -100,7 +100,7 @@ robj *createStringObjectFromLongDouble(PORT_LONGDOUBLE value, int humanfriendly)
* way that is "non surprising" for the user (that is, most small
* decimal numbers will be represented in a way that when converted
* back into a string are exactly the same as what the user typed.) */
len = snprintf(buf,sizeof(buf),"%.15Lf",value); WIN_PORT_FIX /* %.17 -> %.15 on Windows the magic number is 15 */
len = snprintf(buf,sizeof(buf),"%.15Lf",value); WIN_PORT_FIX /* %.17 -> %.15 on Windows the magic number is 15 */
/* Now remove trailing zeroes after the '.' */
if (strchr(buf,'.') != NULL) {
char *p = buf+len-1;
......
......@@ -1087,10 +1087,10 @@ int serverCron(struct aeEventLoop *eventLoop, PORT_LONGLONG id, void *clientData
if (!server.sentinel_mode) {
run_with_period(5000) {
redisLog(REDIS_VERBOSE,
"%Iu clients connected (%Iu slaves), %Iu bytes in use",
"%Iu clients connected (%Iu slaves), %Iu bytes in use", WIN_PORT_FIX /* %zu -> %Iu */
listLength(server.clients)-listLength(server.slaves),
listLength(server.slaves),
zmalloc_used_memory()); WIN_PORT_FIX /* %zu -> %Iu */
zmalloc_used_memory());
}
}
......@@ -2750,7 +2750,7 @@ sds genRedisInfoString(char *section) {
"aof_current_size:%lld\r\n"
"aof_base_size:%lld\r\n"
"aof_pending_rewrite:%d\r\n"
"aof_buffer_length:%Iu\r\n"
"aof_buffer_length:%Iu\r\n" WIN_PORT_FIX /* %zu -> %Iu */
"aof_rewrite_buffer_length:%lu\r\n"
"aof_pending_bio_fsync:%llu\r\n"
"aof_delayed_fsync:%lu\r\n",
......@@ -2760,7 +2760,7 @@ sds genRedisInfoString(char *section) {
sdslen(server.aof_buf),
aofRewriteBufferSize(),
bioPendingJobsOfType(REDIS_BIO_AOF_FSYNC),
server.aof_delayed_fsync); WIN_PORT_FIX /* %zu -> %Iu */
server.aof_delayed_fsync);
}
if (server.loading) {
......@@ -3398,8 +3398,8 @@ void loadDataFromDisk(void) {
}
void redisOutOfMemoryHandler(size_t allocation_size) {
redisLog(REDIS_WARNING,"Out Of Memory allocating %Iu bytes!",
allocation_size); WIN_PORT_FIX /* %zu -> %Iu */
redisLog(REDIS_WARNING,"Out Of Memory allocating %Iu bytes!", WIN_PORT_FIX /* %zu -> %Iu */
allocation_size);
redisPanic("Redis aborting for OUT OF MEMORY");
}
......
......@@ -283,7 +283,7 @@ void replicationFeedMonitors(redisClient *c, list *monitors, int dictid, robj **
for (j = 0; j < argc; j++) {
if (argv[j]->encoding == REDIS_ENCODING_INT) {
cmdrepr = sdscatprintf(cmdrepr, "\"%Id\"", (PORT_LONG) argv[j]->ptr); /* PORTABILITY FIX %ld -> %Id */
cmdrepr = sdscatprintf(cmdrepr, "\"%Id\"", (PORT_LONG) argv[j]->ptr); WIN_PORT_FIX /* %ld -> %Id */
} else {
cmdrepr = sdscatrepr(cmdrepr,(char*)argv[j]->ptr,
sdslen(argv[j]->ptr));
......
......@@ -775,7 +775,7 @@ void sentinelRunPendingScripts(void) {
CloseHandle( pi.hThread );
sentinel.running_scripts++;
sentinelEvent(REDIS_DEBUG, "+script-child", NULL, "%ld", (long) sj->pid); /* BUGBUG: fix %ld */
sentinelEvent(REDIS_DEBUG, "+script-child", NULL, "%Id", (PORT_LONG) sj->pid); WIN_PORT_FIX /* %ld -> %Id */
} else {
sentinelEvent(REDIS_WARNING,"-script-error",NULL,
"%s %d %d", sj->argv[0], 99, 0);
......@@ -844,8 +844,8 @@ void sentinelCollectTerminatedScripts(void) {
if(WaitForSingleObject(sj->hScriptProcess,0) == WAIT_OBJECT_0) {
GetExitCodeProcess(sj->hScriptProcess,&exitCode);
sentinelEvent(REDIS_DEBUG,"-script-child",NULL,"%ld %d %d",
(long) sj->pid, exitCode, 0); /* BUGBUG: fix %ld */
sentinelEvent(REDIS_DEBUG, "-script-child", NULL, "%Id %d %d", WIN_PORT_FIX /* %ld -> %Id*/
(PORT_LONG) sj->pid, exitCode, 0);
/* at this point the process ID may be recycled by Windows */
CloseHandle(sj->hScriptProcess);
......@@ -931,8 +931,8 @@ void sentinelKillTimedoutScripts(void) {
if (sj->flags & SENTINEL_SCRIPT_RUNNING &&
(now - sj->start_time) > SENTINEL_SCRIPT_MAX_RUNTIME)
{
sentinelEvent(REDIS_WARNING, "-script-timeout", NULL, "%s %ld",
sj->argv[0], (long) sj->pid); /* BUGBUG */
sentinelEvent(REDIS_WARNING, "-script-timeout", NULL, "%s %Id", WIN_PORT_FIX /* %ld -> %Id*/
sj->argv[0], (PORT_LONG) sj->pid);
#ifdef _WIN32
TerminateProcess(sj->hScriptProcess,1);
#else
......@@ -1606,16 +1606,16 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
/* sentinel down-after-milliseconds */
if (master->down_after_period != SENTINEL_DEFAULT_DOWN_AFTER) {
line = sdscatprintf(sdsempty(),
"sentinel down-after-milliseconds %s %ld",
master->name, (long) master->down_after_period); /* BUGBUG */
"sentinel down-after-milliseconds %s %Id", WIN_PORT_FIX /* %ld -> %Id*/
master->name, (PORT_LONG) master->down_after_period);
rewriteConfigRewriteLine(state,"sentinel",line,1);
}
/* sentinel failover-timeout */
if (master->failover_timeout != SENTINEL_DEFAULT_FAILOVER_TIMEOUT) {
line = sdscatprintf(sdsempty(),
"sentinel failover-timeout %s %ld",
master->name, (long) master->failover_timeout); /* BUGBUG */
"sentinel failover-timeout %s %Id", WIN_PORT_FIX /* %ld -> %Id*/
master->name, (PORT_LONG) master->failover_timeout);
rewriteConfigRewriteLine(state,"sentinel",line,1);
}
......
......@@ -131,8 +131,8 @@ pthread_mutex_t used_memory_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
static void zmalloc_default_oom(size_t size) {
fprintf(stderr, "zmalloc: Out of memory trying to allocate %Iu bytes\n",
size); WIN_PORT_FIX /* %zu -> %Iu */
fprintf(stderr, "zmalloc: Out of memory trying to allocate %Iu bytes\n", WIN_PORT_FIX /* %zu -> %Iu */
size);
fflush(stderr);
abort();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册