getting rid of compilation warnings
This commit is contained in:
@@ -34,6 +34,7 @@
|
||||
#include "Win32_Common.h"
|
||||
#include "Win32_Error.h"
|
||||
#include "Win32_Assert.h"
|
||||
#include <system_error>
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -667,7 +668,7 @@ int FDAPI_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
||||
fds[n].revents = pollCopy[n].revents;
|
||||
}
|
||||
|
||||
delete pollCopy;
|
||||
delete[] pollCopy;
|
||||
pollCopy = NULL;
|
||||
|
||||
return ret;
|
||||
@@ -722,7 +723,7 @@ int FDAPI_poll(struct pollfd *fds, nfds_t nfds, int timeout) {
|
||||
if (f_WSAFDIsSet(pollCopy[i].fd, &excepSet)) fds[i].revents |= POLLERR;
|
||||
}
|
||||
|
||||
delete pollCopy;
|
||||
delete[] pollCopy;
|
||||
pollCopy = NULL;
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <windows.h>
|
||||
#include <stdexcept>
|
||||
#include <map>
|
||||
#include <system_error>
|
||||
using namespace std;
|
||||
|
||||
DLLMap& DLLMap::getInstance() {
|
||||
|
||||
@@ -416,7 +416,7 @@ int aeProcessEvents(aeEventLoop *eventLoop, int flags)
|
||||
shortest->when_ms - now_ms;
|
||||
|
||||
if (ms > 0) {
|
||||
tvp->tv_sec = ms/1000;
|
||||
tvp->tv_sec = (long)ms/1000; WIN_PORT_FIX /* cast (long) */
|
||||
tvp->tv_usec = (ms % 1000)*1000;
|
||||
} else {
|
||||
tvp->tv_sec = 0;
|
||||
|
||||
@@ -157,8 +157,14 @@ void aofRewriteBufferAppend(unsigned char *s, PORT_ULONG len) {
|
||||
int numblocks;
|
||||
|
||||
block = zmalloc(sizeof(*block));
|
||||
block->free = AOF_RW_BUF_BLOCK_SIZE;
|
||||
block->used = 0;
|
||||
#ifdef _WIN32
|
||||
if (block) {
|
||||
#endif
|
||||
block->free = AOF_RW_BUF_BLOCK_SIZE;
|
||||
block->used = 0;
|
||||
#ifdef _WIN32
|
||||
}
|
||||
#endif
|
||||
listAddNodeTail(server.aof_rewrite_buf_blocks,block);
|
||||
|
||||
/* Log every time we cross more 10 or 100 blocks, respectively
|
||||
@@ -582,6 +588,7 @@ void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv, int a
|
||||
char seldb[64];
|
||||
|
||||
snprintf(seldb,sizeof(seldb),"%d",dictid);
|
||||
WIN32_ONLY(seldb[sizeof(seldb)-1] = 0;) /*get rid of C6053 warning*/
|
||||
buf = sdscatprintf(buf,"*2\r\n$6\r\nSELECT\r\n$%Iu\r\n%s\r\n", WIN_PORT_FIX /* %lu -> %Iu */
|
||||
(PORT_ULONG)strlen(seldb),seldb);
|
||||
server.aof_selected_db = dictid;
|
||||
@@ -922,7 +929,7 @@ int rewriteListObject(rio *r, robj *key, robj *o) {
|
||||
|
||||
while (quicklistNext(li,&entry)) {
|
||||
if (count == 0) {
|
||||
int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
|
||||
PORT_LONGLONG cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ? WIN_PORT_FIX /* int -> PORT_LONGLONG */
|
||||
AOF_REWRITE_ITEMS_PER_CMD : items;
|
||||
if (rioWriteBulkCount(r,'*',2+cmd_items) == 0) return 0;
|
||||
if (rioWriteBulkString(r,"RPUSH",5) == 0) return 0;
|
||||
@@ -958,7 +965,7 @@ int rewriteSetObject(rio *r, robj *key, robj *o) {
|
||||
int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
|
||||
AOF_REWRITE_ITEMS_PER_CMD : (int)items; WIN_PORT_FIX /* cast (int) */
|
||||
|
||||
if (rioWriteBulkCount(r,'*',2+cmd_items) == 0) return 0;
|
||||
if (rioWriteBulkCount(r,'*',(PORT_LONG)2+cmd_items) == 0) return 0; WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
if (rioWriteBulkString(r,"SADD",4) == 0) return 0;
|
||||
if (rioWriteBulkObject(r,key) == 0) return 0;
|
||||
}
|
||||
@@ -976,7 +983,7 @@ int rewriteSetObject(rio *r, robj *key, robj *o) {
|
||||
int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
|
||||
AOF_REWRITE_ITEMS_PER_CMD : (int)items; WIN_PORT_FIX /* cast (int) */
|
||||
|
||||
if (rioWriteBulkCount(r,'*',2+cmd_items) == 0) return 0;
|
||||
if (rioWriteBulkCount(r,'*',(PORT_LONG)2+cmd_items) == 0) return 0; WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
if (rioWriteBulkString(r,"SADD",4) == 0) return 0;
|
||||
if (rioWriteBulkObject(r,key) == 0) return 0;
|
||||
}
|
||||
@@ -1017,7 +1024,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
|
||||
int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
|
||||
AOF_REWRITE_ITEMS_PER_CMD : (int)items; WIN_PORT_FIX /* cast (int) */
|
||||
|
||||
if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0;
|
||||
if (rioWriteBulkCount(r,'*',2+((PORT_LONG)cmd_items)*2) == 0) return 0; WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
if (rioWriteBulkString(r,"ZADD",4) == 0) return 0;
|
||||
if (rioWriteBulkObject(r,key) == 0) return 0;
|
||||
}
|
||||
@@ -1044,7 +1051,7 @@ int rewriteSortedSetObject(rio *r, robj *key, robj *o) {
|
||||
int cmd_items = (items > AOF_REWRITE_ITEMS_PER_CMD) ?
|
||||
AOF_REWRITE_ITEMS_PER_CMD : (int)items; WIN_PORT_FIX /* cast (int) */
|
||||
|
||||
if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0;
|
||||
if (rioWriteBulkCount(r,'*',2+((PORT_LONG)cmd_items)*2) == 0) return 0; WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
if (rioWriteBulkString(r,"ZADD",4) == 0) return 0;
|
||||
if (rioWriteBulkObject(r,key) == 0) return 0;
|
||||
}
|
||||
@@ -1079,7 +1086,7 @@ static int rioWriteHashIteratorCursor(rio *r, hashTypeIterator *hi, int what) {
|
||||
return (int)rioWriteBulkLongLong(r, vll); WIN_PORT_FIX /* cast (int) */
|
||||
} else if (hi->encoding == OBJ_ENCODING_HT) {
|
||||
sds value = hashTypeCurrentFromHashTable(hi, what);
|
||||
return rioWriteBulkString(r, value, sdslen(value));
|
||||
return (int)rioWriteBulkString(r, value, sdslen(value)); WIN_PORT_FIX /* cast (int) */
|
||||
}
|
||||
|
||||
serverPanic("Unknown hash encoding");
|
||||
@@ -1098,7 +1105,7 @@ int rewriteHashObject(rio *r, robj *key, robj *o) {
|
||||
int cmd_items = (int) ((items > AOF_REWRITE_ITEMS_PER_CMD) ? WIN_PORT_FIX /* cast (int) */
|
||||
AOF_REWRITE_ITEMS_PER_CMD : items);
|
||||
|
||||
if (rioWriteBulkCount(r,'*',2+cmd_items*2) == 0) return 0;
|
||||
if (rioWriteBulkCount(r,'*',2+((PORT_LONG)cmd_items)*2) == 0) return 0; WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
if (rioWriteBulkString(r,"HMSET",5) == 0) return 0;
|
||||
if (rioWriteBulkObject(r,key) == 0) return 0;
|
||||
}
|
||||
@@ -1134,14 +1141,21 @@ int rewriteModuleObject(rio *r, robj *key, robj *o) {
|
||||
* the difference accumulated from the parent into a buffer, that is
|
||||
* concatenated at the end of the rewrite. */
|
||||
ssize_t aofReadDiffFromParent(void) {
|
||||
#ifndef _WIN32
|
||||
char buf[65536]; /* Default pipe buffer size on most Linux systems. */
|
||||
#else
|
||||
char* buf = zmalloc(65536); //allocate dynamically and get rid of C6262 warning
|
||||
#endif
|
||||
ssize_t nread, total = 0;
|
||||
|
||||
while ((nread =
|
||||
read(server.aof_pipe_read_data_from_parent,buf,sizeof(buf))) > 0) {
|
||||
read(server.aof_pipe_read_data_from_parent,buf,IF_WIN32(65536,sizeof(buf)))) > 0) {
|
||||
server.aof_child_diff = sdscatlen(server.aof_child_diff,buf,nread);
|
||||
total += nread;
|
||||
}
|
||||
#ifdef _WIN32
|
||||
zfree(buf);
|
||||
#endif
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -1303,7 +1317,7 @@ int rewriteAppendOnlyFile(char *filename) {
|
||||
/* Write the received diff to the file. */
|
||||
serverLog(LL_NOTICE,
|
||||
"Concatenating %.2f MB of AOF diff received from parent.",
|
||||
(double) sdslen(server.aof_child_diff) / (1024*1024));
|
||||
(double) (sdslen(server.aof_child_diff) / (1024*1024))); WIN_PORT_FIX
|
||||
if (rioWrite(&aof,server.aof_child_diff,sdslen(server.aof_child_diff)) == 0)
|
||||
goto werr;
|
||||
|
||||
@@ -1475,7 +1489,7 @@ int rewriteAppendOnlyFileBackground(void) {
|
||||
#endif
|
||||
/* Parent */
|
||||
server.stat_fork_time = ustime()-start;
|
||||
server.stat_fork_rate = (double) zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024); /* GB per second. */
|
||||
server.stat_fork_rate = (double) (zmalloc_used_memory() * 1000000 / server.stat_fork_time / (1024*1024*1024)); /* GB per second. */ WIN_PORT_FIX
|
||||
latencyAddSampleIfNeeded("fork",server.stat_fork_time/1000);
|
||||
if (childpid == -1) {
|
||||
closeChildInfoPipe();
|
||||
@@ -1521,6 +1535,7 @@ void aofRemoveTempFile(pid_t childpid) {
|
||||
char tmpfile[256];
|
||||
|
||||
snprintf(tmpfile,256,"temp-rewriteaof-bg-%d.aof", (int) childpid);
|
||||
WIN32_ONLY(tmpfile[sizeof(tmpfile) - 1] = 0;) /*get rid of C6053 warning*/
|
||||
unlink(tmpfile);
|
||||
}
|
||||
|
||||
@@ -1590,7 +1605,7 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) {
|
||||
latencyAddSampleIfNeeded("aof-rewrite-diff-write",latency);
|
||||
|
||||
serverLog(LL_NOTICE,
|
||||
"Residual parent diff successfully flushed to the rewritten AOF (%.2f MB)", (double) aofRewriteBufferSize() / (1024*1024));
|
||||
"Residual parent diff successfully flushed to the rewritten AOF (%.2f MB)", (double) (aofRewriteBufferSize() / (1024*1024))); WIN_PORT_FIX
|
||||
|
||||
/* The only remaining thing to do is to rename the temporary file to
|
||||
* the configured file and switch the file descriptor used to do AOF
|
||||
|
||||
@@ -107,6 +107,9 @@ void bioInit(void) {
|
||||
|
||||
/* Initialization of state vars and objects */
|
||||
for (j = 0; j < BIO_NUM_OPS; j++) {
|
||||
#ifdef _WIN32
|
||||
#pragma warning( suppress : 6031 )
|
||||
#endif
|
||||
pthread_mutex_init(&bio_mutex[j],NULL);
|
||||
pthread_cond_init(&bio_newjob_cond[j],NULL);
|
||||
pthread_cond_init(&bio_step_cond[j],NULL);
|
||||
@@ -200,9 +203,9 @@ void *bioProcessBackgroundJobs(void *arg) {
|
||||
|
||||
/* Process the job accordingly to its type. */
|
||||
if (type == BIO_CLOSE_FILE) {
|
||||
close((PORT_LONG)job->arg1);
|
||||
close((int)(PORT_LONG)job->arg1); WIN_PORT_FIX /* cast (int) */
|
||||
} else if (type == BIO_AOF_FSYNC) {
|
||||
aof_fsync((PORT_LONG)job->arg1);
|
||||
aof_fsync((int)(PORT_LONG)job->arg1); WIN_PORT_FIX /* cast (int) */
|
||||
} else if (type == BIO_LAZY_FREE) {
|
||||
/* What we free changes depending on what arguments are set:
|
||||
* arg1 -> free the object at pointer.
|
||||
|
||||
+5
-5
@@ -152,7 +152,7 @@ int yesnotoi(char *s) {
|
||||
}
|
||||
|
||||
void appendServerSaveParams(time_t seconds, int changes) {
|
||||
server.saveparams = zrealloc(server.saveparams,sizeof(struct saveparam)*(server.saveparamslen+1));
|
||||
server.saveparams = zrealloc(server.saveparams,sizeof(struct saveparam)*((PORT_ULONG)server.saveparamslen+1)); WIN_PORT_FIX /* cat (PORT_ULONG) */
|
||||
server.saveparams[server.saveparamslen].seconds = seconds;
|
||||
server.saveparams[server.saveparamslen].changes = changes;
|
||||
server.saveparamslen++;
|
||||
@@ -290,7 +290,7 @@ void loadServerConfigFromString(char *config) {
|
||||
if (length == 2) {
|
||||
server.logfile = zstrdup("\0");
|
||||
} else {
|
||||
size_t l = length - 2 + 1;
|
||||
size_t l = (size_t) length - 2 + 1;
|
||||
char *p = zmalloc(l);
|
||||
memcpy(p, argv[1]+1, l);
|
||||
server.logfile = p;
|
||||
@@ -1528,7 +1528,7 @@ void configGetCommand(client *c) {
|
||||
sdsfree(aux);
|
||||
matches++;
|
||||
}
|
||||
setDeferredMultiBulkLength(c,replylen,matches*2);
|
||||
setDeferredMultiBulkLength(c,replylen,(PORT_LONG)matches*2); WIN_PORT_FIX /* cat (PORT_LONG) */
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------
|
||||
@@ -1579,7 +1579,7 @@ struct rewriteConfigState {
|
||||
|
||||
/* Append the new line to the current configuration state. */
|
||||
void rewriteConfigAppendLine(struct rewriteConfigState *state, sds line) {
|
||||
state->lines = zrealloc(state->lines, sizeof(char*) * (state->numlines+1));
|
||||
state->lines = zrealloc(state->lines, sizeof(char*) * ((PORT_ULONG)state->numlines+1)); WIN_PORT_FIX /* cat (PORT_ULONG) */
|
||||
state->lines[state->numlines++] = line;
|
||||
}
|
||||
|
||||
@@ -2025,7 +2025,7 @@ int rewriteConfigOverwriteFile(char *configfile, sds content) {
|
||||
padding = (int)(sb.st_size - content_size); WIN_PORT_FIX /* cast (int) */
|
||||
content_padded = sdsgrowzero(content_padded,sb.st_size);
|
||||
content_padded[content_size] = '\n';
|
||||
memset(content_padded+content_size+1,'#',padding-1);
|
||||
memset(content_padded+content_size+1,'#',(size_t)padding-1); WIN_PORT_FIX /* cat (size_t) */
|
||||
}
|
||||
|
||||
/* 3) Write the new content using a single write(2). */
|
||||
|
||||
@@ -1182,7 +1182,7 @@ int *getKeysUsingCommandTable(struct redisCommand *cmd,robj **argv, int argc, in
|
||||
|
||||
last = cmd->lastkey;
|
||||
if (last < 0) last = argc+last;
|
||||
keys = zmalloc(sizeof(int)*((last - cmd->firstkey)+1));
|
||||
keys = zmalloc(sizeof(int)*(((PORT_ULONG) last - cmd->firstkey)+1)); WIN_PORT_FIX /* cat (PORT_ULONG) */
|
||||
for (j = cmd->firstkey; j <= last; j += cmd->keystep) {
|
||||
if (j >= argc) {
|
||||
/* Modules commands, and standard commands with a not fixed number
|
||||
@@ -1249,7 +1249,7 @@ int *zunionInterGetKeys(struct redisCommand *cmd, robj **argv, int argc, int *nu
|
||||
/* Keys in z{union,inter}store come from two places:
|
||||
* argv[1] = storage key,
|
||||
* argv[3...n] = keys to intersect */
|
||||
keys = zmalloc(sizeof(int)*(num+1));
|
||||
keys = zmalloc(sizeof(int)*((PORT_ULONG)num+1)); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
|
||||
/* Add all key positions for argv[3...n] to keys[] */
|
||||
for (i = 0; i < num; i++) keys[i] = 3+i;
|
||||
|
||||
+2
-2
@@ -229,7 +229,7 @@ void evictionPoolPopulate(int dbid, dict *sampledict, dict *keydict, struct evic
|
||||
/* Save SDS before overwriting. */
|
||||
sds cached = pool[EVPOOL_SIZE-1].cached;
|
||||
memmove(pool+k+1,pool+k,
|
||||
sizeof(pool[0])*(EVPOOL_SIZE-k-1));
|
||||
sizeof(pool[0])*((size_t)EVPOOL_SIZE-k-1)); WIN_PORT_FIX /* cast (size_t) */
|
||||
pool[k].cached = cached;
|
||||
} else {
|
||||
/* No free space on right? Insert at k-1 */
|
||||
@@ -251,7 +251,7 @@ void evictionPoolPopulate(int dbid, dict *sampledict, dict *keydict, struct evic
|
||||
if (klen > EVPOOL_CACHED_SDS_SIZE) {
|
||||
pool[k].key = sdsdup(key);
|
||||
} else {
|
||||
memcpy(pool[k].cached,key,klen+1);
|
||||
memcpy(pool[k].cached,key,(size_t)klen+1); WIN_PORT_FIX /* cast (size_t) */
|
||||
sdssetlen(pool[k].cached,klen);
|
||||
pool[k].key = pool[k].cached;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1021,7 +1021,7 @@ uint64_t hllCount(struct hllhdr *hdr, int *invalid) {
|
||||
* "LogLog-Beta and More: A New Algorithm for Cardinality Estimation
|
||||
* Based on LogLog Counting" Jason Qin, Denys Kim, Yumei Tung
|
||||
* arXiv:1612.02284 */
|
||||
double zl = log(ez + 1);
|
||||
double zl = log((double)ez + 1); WIN_PORT_FIX /* cast (double) */
|
||||
double beta = -0.370393911*ez +
|
||||
0.070471823*zl +
|
||||
0.17393686*pow(zl,2) +
|
||||
|
||||
+4
-2
@@ -552,7 +552,7 @@ int RM_IsKeysPositionRequest(RedisModuleCtx *ctx) {
|
||||
void RM_KeyAtPos(RedisModuleCtx *ctx, int pos) {
|
||||
if (!(ctx->flags & REDISMODULE_CTX_KEYS_POS_REQUEST)) return;
|
||||
if (pos <= 0) return;
|
||||
ctx->keys_pos = zrealloc(ctx->keys_pos,sizeof(int)*(ctx->keys_count+1));
|
||||
ctx->keys_pos = zrealloc(ctx->keys_pos,sizeof(int)*((PORT_ULONG)ctx->keys_count+1)); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
ctx->keys_pos[ctx->keys_count++] = pos;
|
||||
}
|
||||
|
||||
@@ -1085,7 +1085,7 @@ int RM_ReplyWithArray(RedisModuleCtx *ctx, PORT_LONG len) {
|
||||
if (c == NULL) return REDISMODULE_OK;
|
||||
if (len == REDISMODULE_POSTPONED_ARRAY_LEN) {
|
||||
ctx->postponed_arrays = zrealloc(ctx->postponed_arrays,sizeof(void*)*
|
||||
(ctx->postponed_arrays_count+1));
|
||||
((PORT_ULONG)ctx->postponed_arrays_count+1)); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
ctx->postponed_arrays[ctx->postponed_arrays_count] =
|
||||
addDeferredMultiBulkLength(c);
|
||||
ctx->postponed_arrays_count++;
|
||||
@@ -3968,7 +3968,9 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
|
||||
}
|
||||
|
||||
/* Redis module loaded! Register it. */
|
||||
WIN32_ONLY(if (TRUE) {)
|
||||
dictAdd(modules,ctx.module->name,ctx.module);
|
||||
WIN32_ONLY(})
|
||||
ctx.module->handle = handle;
|
||||
serverLog(LL_NOTICE,"Module '%s' loaded from %s",ctx.module->name,path);
|
||||
moduleFreeContext(&ctx);
|
||||
|
||||
+2
-2
@@ -530,7 +530,7 @@ void addReplyLongLongWithPrefix(client *c, PORT_LONGLONG ll, char prefix) {
|
||||
len = ll2string(buf+1,sizeof(buf)-1,ll);
|
||||
buf[len+1] = '\r';
|
||||
buf[len+2] = '\n';
|
||||
addReplyString(c,buf,len+3);
|
||||
addReplyString(c,buf,(size_t)len+3); WIN_PORT_FIX /* cast (size_t) */
|
||||
}
|
||||
|
||||
void addReplyLongLong(client *c, PORT_LONGLONG ll) {
|
||||
@@ -1910,7 +1910,7 @@ void rewriteClientCommandArgument(client *c, int i, robj *newval) {
|
||||
robj *oldval;
|
||||
|
||||
if (i >= c->argc) {
|
||||
c->argv = zrealloc(c->argv,sizeof(robj*)*(i+1));
|
||||
c->argv = zrealloc(c->argv,sizeof(robj*)*((PORT_ULONG)i+1)); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
c->argc = i+1;
|
||||
c->argv[i] = NULL;
|
||||
}
|
||||
|
||||
+1
-1
@@ -751,7 +751,7 @@ size_t objectComputeSize(robj *o, size_t sample_size) {
|
||||
if (samples) asize += (double)elesize/samples*dictSize(d);
|
||||
} else if (o->encoding == OBJ_ENCODING_INTSET) {
|
||||
intset *is = o->ptr;
|
||||
asize = sizeof(*o)+sizeof(*is)+is->encoding*is->length;
|
||||
asize = sizeof(*o)+sizeof(*is)+is->encoding*(size_t)is->length; WIN_PORT_FIX /* cast (size_t) */
|
||||
} else {
|
||||
serverPanic("Unknown set encoding");
|
||||
}
|
||||
|
||||
@@ -1037,6 +1037,7 @@ int rdbSave(char *filename, rdbSaveInfo *rsi) {
|
||||
int error = 0;
|
||||
|
||||
snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid());
|
||||
WIN32_ONLY(tmpfile[sizeof(tmpfile) - 1] = 0;) /*get rid of C6053 warning*/
|
||||
fp = fopen(tmpfile,IF_WIN32("wb","w"));
|
||||
if (!fp) {
|
||||
char *cwdp = IF_WIN32(_getcwd, getcwd)(cwd, MAXPATHLEN);
|
||||
@@ -1151,6 +1152,7 @@ void rdbRemoveTempFile(pid_t childpid) {
|
||||
char tmpfile[256];
|
||||
|
||||
snprintf(tmpfile,sizeof(tmpfile),"temp-%d.rdb", (int) childpid);
|
||||
WIN32_ONLY(tmpfile[sizeof(tmpfile) - 1] = 0;) /*get rid of C6053 warning*/
|
||||
unlink(tmpfile);
|
||||
}
|
||||
|
||||
@@ -1910,7 +1912,7 @@ int rdbSaveToSlavesSockets(rdbSaveInfo *rsi) {
|
||||
* We'll restore it when the children returns (since duped socket
|
||||
* will share the O_NONBLOCK attribute with the parent). */
|
||||
anetBlock(NULL,slave->fd);
|
||||
anetSendTimeout(NULL,slave->fd,server.repl_timeout*1000);
|
||||
anetSendTimeout(NULL,slave->fd,(PORT_ULONG)server.repl_timeout*1000); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-6
@@ -241,7 +241,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
|
||||
len = ll2string(aux+1,sizeof(aux)-1,argc);
|
||||
aux[len+1] = '\r';
|
||||
aux[len+2] = '\n';
|
||||
feedReplicationBacklog(aux,len+3);
|
||||
feedReplicationBacklog(aux,(size_t)len+3); WIN_PORT_FIX /* cast (size_t) */
|
||||
|
||||
for (j = 0; j < argc; j++) {
|
||||
PORT_LONG objlen = (PORT_LONG) stringObjectLen(argv[j]); WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
@@ -253,7 +253,7 @@ void replicationFeedSlaves(list *slaves, int dictid, robj **argv, int argc) {
|
||||
len = ll2string(aux+1,sizeof(aux)-1,objlen);
|
||||
aux[len+1] = '\r';
|
||||
aux[len+2] = '\n';
|
||||
feedReplicationBacklog(aux,len+3);
|
||||
feedReplicationBacklog(aux,(size_t)len+3); WIN_PORT_FIX /* cast (size_t) */
|
||||
feedReplicationBacklogWithObject(argv[j]);
|
||||
feedReplicationBacklog(aux+len+1,2);
|
||||
}
|
||||
@@ -1219,7 +1219,7 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||
/* If repl_transfer_size == -1 we still have to read the bulk length
|
||||
* from the master reply. */
|
||||
if (server.repl_transfer_size == -1) {
|
||||
if (syncReadLine(fd,buf,1024,server.repl_syncio_timeout*1000) == -1) {
|
||||
if (syncReadLine(fd,buf,1024,(PORT_LONGLONG)server.repl_syncio_timeout*1000) == -1) { WIN_PORT_FIX /* cast (PORT_LONGLONG) */
|
||||
serverLog(LL_WARNING,
|
||||
"I/O error reading bulk count from MASTER: %s",
|
||||
IF_WIN32(wsa_strerror(errno),strerror(errno)));
|
||||
@@ -1312,6 +1312,9 @@ void readSyncBulkPayload(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||
memmove(lastbytes,lastbytes+nread,rem);
|
||||
memcpy(lastbytes+rem,buf,nread);
|
||||
}
|
||||
#ifdef _WIN32
|
||||
#pragma warning( suppress: 6385 ))
|
||||
#endif
|
||||
if (memcmp(lastbytes,eofmark,CONFIG_RUN_ID_SIZE) == 0) eof_reached = 1;
|
||||
}
|
||||
|
||||
@@ -1467,7 +1470,7 @@ char *sendSynchronousCommand(int flags, int fd, ...) {
|
||||
va_end(ap);
|
||||
|
||||
/* Transfer command to the server. */
|
||||
if (syncWrite(fd,cmd,(ssize_t)sdslen(cmd),server.repl_syncio_timeout*1000) WIN_PORT_FIX /* cast (ssize_t) */
|
||||
if (syncWrite(fd,cmd,(ssize_t)sdslen(cmd),(PORT_LONGLONG)server.repl_syncio_timeout*1000) WIN_PORT_FIX /* cast (ssize_t), cast (PORT_LONGLONG) */
|
||||
== -1)
|
||||
{
|
||||
sdsfree(cmd);
|
||||
@@ -1481,7 +1484,7 @@ char *sendSynchronousCommand(int flags, int fd, ...) {
|
||||
if (flags & SYNC_CMD_READ) {
|
||||
char buf[256];
|
||||
|
||||
if (syncReadLine(fd,buf,sizeof(buf),server.repl_syncio_timeout*1000)
|
||||
if (syncReadLine(fd,buf,sizeof(buf), (PORT_LONGLONG)server.repl_syncio_timeout*1000) WIN_PORT_FIX /* cast (PORT_LONGLONG) */
|
||||
== -1)
|
||||
{
|
||||
return sdscatprintf(sdsempty(),"-Reading from master: %s",
|
||||
@@ -1937,7 +1940,7 @@ void syncWithMaster(aeEventLoop *el, int fd, void *privdata, int mask) {
|
||||
* already populated. */
|
||||
if (psync_result == PSYNC_NOT_SUPPORTED) {
|
||||
serverLog(LL_NOTICE,"Retrying with SYNC...");
|
||||
if (syncWrite(fd,"SYNC\r\n",6,server.repl_syncio_timeout*1000) == -1) {
|
||||
if (syncWrite(fd,"SYNC\r\n",6,(PORT_LONGLONG)server.repl_syncio_timeout*1000) == -1) { WIN_PORT_FIX /* cast (PORT_LONGLONG) */
|
||||
serverLog(LL_WARNING,"I/O error writing to MASTER: %s",
|
||||
IF_WIN32(wsa_strerror(errno),strerror(errno)));
|
||||
goto error;
|
||||
|
||||
@@ -332,26 +332,41 @@ void sdsIncrLen(sds s, ssize_t incr) {
|
||||
unsigned char *fp = ((unsigned char*)s)-1;
|
||||
unsigned char oldlen = SDS_TYPE_5_LEN(flags);
|
||||
assert((incr > 0 && oldlen+incr < 32) || (incr < 0 && oldlen >= (unsigned int)(-incr)));
|
||||
*fp = SDS_TYPE_5 | ((oldlen+incr) << SDS_TYPE_BITS);
|
||||
*fp = SDS_TYPE_5 | (unsigned char)((oldlen+incr) << SDS_TYPE_BITS); WIN_PORT_FIX /* cast (unsigned char) */
|
||||
len = oldlen+incr;
|
||||
break;
|
||||
}
|
||||
case SDS_TYPE_8: {
|
||||
SDS_HDR_VAR(8,s);
|
||||
assert((incr >= 0 && sh->alloc-sh->len >= incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
||||
#ifdef _WIN32
|
||||
sh->len += (uint8_t)incr;
|
||||
len = sh->len;
|
||||
#else
|
||||
len = (sh->len += incr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case SDS_TYPE_16: {
|
||||
SDS_HDR_VAR(16,s);
|
||||
assert((incr >= 0 && sh->alloc-sh->len >= incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
||||
#ifdef _WIN32
|
||||
sh->len += (uint16_t)incr;
|
||||
len = sh->len;
|
||||
#else
|
||||
len = (sh->len += incr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case SDS_TYPE_32: {
|
||||
SDS_HDR_VAR(32,s);
|
||||
assert((incr >= 0 && sh->alloc-sh->len >= (unsigned int)incr) || (incr < 0 && sh->len >= (unsigned int)(-incr)));
|
||||
#ifdef _WIN32
|
||||
sh->len += (uint32_t)incr;
|
||||
len = sh->len;
|
||||
#else
|
||||
len = (sh->len += incr);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
case SDS_TYPE_64: {
|
||||
@@ -822,7 +837,7 @@ sds *sdssplitlen(const char *s, ssize_t len, const char *sep, int seplen, int *c
|
||||
*count = 0;
|
||||
return tokens;
|
||||
}
|
||||
for (j = 0; j < (len-(seplen-1)); j++) {
|
||||
for (j = 0; j < (len-((ssize_t)seplen-1)); j++) { WIN_PORT_FIX /* cast (ssize_t) */
|
||||
/* make sure there is room for the next element and the final one */
|
||||
if (slots < elements+2) {
|
||||
sds *newtokens;
|
||||
@@ -1037,7 +1052,7 @@ sds *sdssplitargs(const char *line, int *argc) {
|
||||
if (*p) p++;
|
||||
}
|
||||
/* add the token to the vector */
|
||||
vector = s_realloc(vector,((*argc)+1)*sizeof(char*));
|
||||
vector = s_realloc(vector,((size_t)(*argc)+1)*sizeof(char*)); WIN_PORT_FIX /* cast (size_t) */
|
||||
vector[*argc] = current;
|
||||
(*argc)++;
|
||||
current = NULL;
|
||||
|
||||
+21
-9
@@ -994,7 +994,7 @@ int serverCron(struct aeEventLoop *eventLoop, PORT_LONGLONG id, void *clientData
|
||||
*
|
||||
* Note that you can change the resolution altering the
|
||||
* LRU_CLOCK_RESOLUTION define. */
|
||||
PORT_ULONG lruclock = getLRUClock();
|
||||
unsigned int lruclock = getLRUClock(); WIN_PORT_FIX /* unsigned int */
|
||||
atomicSet(server.lruclock,lruclock);
|
||||
|
||||
/* Record the max memory used since the server was started. */
|
||||
@@ -1382,8 +1382,17 @@ void createSharedObjects(void) {
|
||||
void initServerConfig(void) {
|
||||
int j;
|
||||
|
||||
#ifdef _WIN32
|
||||
#pragma warning( suppress : 6031 )
|
||||
#endif
|
||||
pthread_mutex_init(&server.next_client_id_mutex,NULL);
|
||||
#ifdef _WIN32
|
||||
#pragma warning( suppress : 6031 )
|
||||
#endif
|
||||
pthread_mutex_init(&server.lruclock_mutex,NULL);
|
||||
#ifdef _WIN32
|
||||
#pragma warning( suppress : 6031 )
|
||||
#endif
|
||||
pthread_mutex_init(&server.unixtime_mutex,NULL);
|
||||
|
||||
getRandomHexChars(server.runid,CONFIG_RUN_ID_SIZE);
|
||||
@@ -2107,7 +2116,7 @@ int redisOpArrayAppend(redisOpArray *oa, struct redisCommand *cmd, int dbid,
|
||||
{
|
||||
redisOp *op;
|
||||
|
||||
oa->ops = zrealloc(oa->ops,sizeof(redisOp)*(oa->numops+1));
|
||||
oa->ops = zrealloc(oa->ops,sizeof(redisOp)*((PORT_ULONG)oa->numops+1)); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
op = oa->ops+oa->numops;
|
||||
op->cmd = cmd;
|
||||
op->dbid = dbid;
|
||||
@@ -2834,7 +2843,7 @@ void commandCommand(client *c) {
|
||||
dictReleaseIterator(di);
|
||||
} else if (!strcasecmp(c->argv[1]->ptr, "info")) {
|
||||
int i;
|
||||
addReplyMultiBulkLen(c, c->argc-2);
|
||||
addReplyMultiBulkLen(c, (PORT_LONG)c->argc-2); WIN_PORT_FIX /* cast (PORT_LONG) */
|
||||
for (i = 2; i < c->argc; i++) {
|
||||
addReplyCommand(c, dictFetchValue(server.commands, c->argv[i]->ptr));
|
||||
}
|
||||
@@ -2877,7 +2886,7 @@ void bytesToHuman(char *s, PORT_ULONGLONG n) {
|
||||
d = (double)n/(1024);
|
||||
sprintf(s,"%.2fK",d);
|
||||
} else if (n < (1024LL*1024*1024)) {
|
||||
d = (double)n/(1024*1024);
|
||||
d = (double)(n/(1024*1024)); WIN_PORT_FIX
|
||||
sprintf(s,"%.2fM",d);
|
||||
} else if (n < (1024LL*1024*1024*1024)) {
|
||||
d = (double)n/(1024LL*1024*1024);
|
||||
@@ -3367,10 +3376,10 @@ sds genRedisInfoString(char *section) {
|
||||
"used_cpu_user:%.2f\r\n"
|
||||
"used_cpu_sys_children:%.2f\r\n"
|
||||
"used_cpu_user_children:%.2f\r\n",
|
||||
(float)self_ru.ru_stime.tv_sec+(float)self_ru.ru_stime.tv_usec/1000000,
|
||||
(float)self_ru.ru_utime.tv_sec+(float)self_ru.ru_utime.tv_usec/1000000,
|
||||
(float)c_ru.ru_stime.tv_sec+(float)c_ru.ru_stime.tv_usec/1000000,
|
||||
(float)c_ru.ru_utime.tv_sec+(float)c_ru.ru_utime.tv_usec/1000000);
|
||||
(IF_WIN32(double,float))self_ru.ru_stime.tv_sec+(float)self_ru.ru_stime.tv_usec/1000000, WIN_PORT_FIX /* warning 26451 */
|
||||
(IF_WIN32(double,float))self_ru.ru_utime.tv_sec+(float)self_ru.ru_utime.tv_usec/1000000, WIN_PORT_FIX /* warning 26451 */
|
||||
(IF_WIN32(double,float))c_ru.ru_stime.tv_sec+(float)c_ru.ru_stime.tv_usec/1000000, WIN_PORT_FIX /* warning 26451 */
|
||||
(IF_WIN32(double,float))c_ru.ru_utime.tv_sec+(float)c_ru.ru_utime.tv_usec/1000000); WIN_PORT_FIX /* warning 26451 */
|
||||
}
|
||||
|
||||
/* Command statistics */
|
||||
@@ -3832,8 +3841,11 @@ int main(int argc, char **argv) {
|
||||
#ifdef _WIN32
|
||||
//"used_memory_mutex" from zmalloc.c is initialized earlier in Win32_QFork.cpp/main(), which later calls this main() function
|
||||
//pthread_mutex_init(&used_memory_mutex, NULL);
|
||||
#pragma warning( suppress : 6031 )
|
||||
pthread_mutex_init(&lazyfree_objects_mutex, NULL);
|
||||
#pragma warning( suppress : 6031 )
|
||||
pthread_mutex_init(&moduleUnblockedClientsMutex, NULL);
|
||||
#pragma warning( suppress : 6031 )
|
||||
pthread_mutex_init(&moduleGIL, NULL);
|
||||
#endif
|
||||
|
||||
@@ -3849,7 +3861,7 @@ int main(int argc, char **argv) {
|
||||
/* Store the executable path and arguments in a safe place in order
|
||||
* to be able to restart the server later. */
|
||||
server.executable = getAbsolutePath(argv[0]);
|
||||
server.exec_argv = zmalloc(sizeof(char*)*(argc+1));
|
||||
server.exec_argv = zmalloc(sizeof(char*)*((PORT_ULONG)argc+1)); WIN_PORT_FIX /* cast (PORT_ULONG) */
|
||||
server.exec_argv[argc] = NULL;
|
||||
for (j = 0; j < argc; j++) server.exec_argv[j] = zstrdup(argv[j]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user