summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2017-12-05 15:28:08 +0100
committerGitHub <noreply@github.com>2017-12-05 15:28:08 +0100
commite4903ce586c191fe4699913a5e360e12812024a3 (patch)
tree2957a412e6fc7a8a9626f6a4dbbb62e3d797f1be
parente6c3bcf9e072c8c40814577f2421b5d5184b2243 (diff)
parent42387d6c1a3bf14baa70f811a79f20b439b58c12 (diff)
downloadredis-e4903ce586c191fe4699913a5e360e12812024a3.tar.gz
Merge pull request #4509 from soloestoy/set-int-problem
Set int problem
-rw-r--r--src/t_set.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/t_set.c b/src/t_set.c
index d5a801e11..8f21f71b1 100644
--- a/src/t_set.c
+++ b/src/t_set.c
@@ -407,7 +407,7 @@ void spopWithCountCommand(client *c) {
/* Get the count argument */
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
if (l >= 0) {
- count = (unsigned) l;
+ count = (unsigned long) l;
} else {
addReply(c,shared.outofrangeerr);
return;
@@ -626,7 +626,7 @@ void srandmemberWithCountCommand(client *c) {
if (getLongFromObjectOrReply(c,c->argv[2],&l,NULL) != C_OK) return;
if (l >= 0) {
- count = (unsigned) l;
+ count = (unsigned long) l;
} else {
/* A negative count means: return the same elements multiple times
* (i.e. don't remove the extracted element after every extraction). */
@@ -774,15 +774,21 @@ void srandmemberCommand(client *c) {
}
int qsortCompareSetsByCardinality(const void *s1, const void *s2) {
- return setTypeSize(*(robj**)s1)-setTypeSize(*(robj**)s2);
+ if (setTypeSize(*(robj**)s1) > setTypeSize(*(robj**)s2)) return 1;
+ if (setTypeSize(*(robj**)s1) < setTypeSize(*(robj**)s2)) return -1;
+ return 0;
}
/* This is used by SDIFF and in this case we can receive NULL that should
* be handled as empty sets. */
int qsortCompareSetsByRevCardinality(const void *s1, const void *s2) {
robj *o1 = *(robj**)s1, *o2 = *(robj**)s2;
+ unsigned long first = o1 ? setTypeSize(o1) : 0;
+ unsigned long second = o2 ? setTypeSize(o2) : 0;
- return (o2 ? setTypeSize(o2) : 0) - (o1 ? setTypeSize(o1) : 0);
+ if (first < second) return 1;
+ if (first > second) return -1;
+ return 0;
}
void sinterGenericCommand(client *c, robj **setkeys,