-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix sign error, int/size_t discrepancies, warnings on windows builds. #936
base: master
Are you sure you want to change the base?
Conversation
@@ -516,7 +516,7 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) { | |||
|
|||
hi_free(curargv); | |||
*target = cmd; | |||
return totlen; | |||
return (int)totlen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These commands really should return a ssize_t
result to be consistent with the use of size_t
, but I didn't want to modify their signature since they are a public API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since then, have updated to reflect the new api which returns long long
. Why that was chosen instead of size_t
or ssize_t
is unclear.
@@ -516,7 +516,7 @@ int redisvFormatCommand(char **target, const char *format, va_list ap) { | |||
|
|||
hi_free(curargv); | |||
*target = cmd; | |||
return totlen; | |||
return (int)totlen; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These commands really should return a ssize_t
result to be consistent with the use of size_t
, but I didn't want to modify their signature since they are a public API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this comment was written, the API has been updated to return long long
. Why that was chosen instead of the more standard ssize_t
remains unclear.
@@ -457,7 +457,7 @@ static int _redisContextConnectTcp(redisContext *c, const char *addr, int port, | |||
} | |||
|
|||
for (b = bservinfo; b != NULL; b = b->ai_next) { | |||
if (bind(s,b->ai_addr,b->ai_addrlen) != -1) { | |||
if (bind(s,b->ai_addr,(socklen_t)b->ai_addrlen) != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Windows has ai_addren
as size_t
rather than socklen_t
. explicitly cast it to silence warning.
@@ -600,13 +600,13 @@ int redisContextConnectUnix(redisContext *c, const char *path, const struct time | |||
|
|||
c->flags |= REDIS_CONNECTED; | |||
return REDIS_OK; | |||
oom: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix error about unused label (windows)
@@ -213,7 +216,7 @@ static int string2ll(const char *s, size_t slen, long long *value) { | |||
if (negative) { | |||
if (v > ((unsigned long long)(-(LLONG_MIN+1))+1)) /* Overflow. */ | |||
return REDIS_ERR; | |||
if (value != NULL) *value = -v; | |||
if (value != NULL) *value = -(long long)v; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning on windows. Negation of an unsigned variable is shaky ground in C, better to be explicit.
read.c
Outdated
@@ -536,7 +540,7 @@ static int processAggregateItem(redisReader *r) { | |||
if (r->fn && r->fn->createArray) | |||
obj = r->fn->createArray(cur,elements); | |||
else | |||
obj = (void*)(long)cur->type; | |||
obj = (void*)(intptr_t)cur->type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must use an integral type of the same size as pointer to avoid the (sensible) warning here.
d518279
to
f995a71
Compare
Any news here? |
In the meantime, there have been some slight fixes upstream. Curiosly, the authors have decided to use |
Would it be possible to get some sort of review on ths PR please? |
This PR fixes a lot of internal type discrepancies within functions, using return (long long) totlen; /* api really should use ssize_t */ I'll be happy to remove those, since they reflect my personal opinion :) |
83fb1a1
to
d7341ca
Compare
I've squashed and rebased this on top of current
and for amd64
|
A lot of discrepancies with int vs size_t were visible when building on windows.
This PR fixes those.