Fix compile errors on GCC v5

Former-commit-id: 1f08a0efb33511ddc75c2acc62199bfcd0860137
This commit is contained in:
John Sully 2019-07-11 20:20:01 -04:00
parent 3498002d9e
commit 2a1d7890f6
8 changed files with 21 additions and 21 deletions

View File

@ -623,7 +623,7 @@ void setDeferredPushLen(client *c, void *node, long length) {
/* Add a double as a bulk reply */ /* Add a double as a bulk reply */
void addReplyDoubleCore(client *c, double d, bool fAsync) { void addReplyDoubleCore(client *c, double d, bool fAsync) {
if (isinf(d)) { if (std::isinf(d)) {
/* Libc in odd systems (Hi Solaris!) will format infinite in a /* Libc in odd systems (Hi Solaris!) will format infinite in a
* different way, so better to handle it in an explicit way. */ * different way, so better to handle it in an explicit way. */
if (c->resp == 2) { if (c->resp == 2) {

View File

@ -624,7 +624,7 @@ int getDoubleFromObject(const robj *o, double *target) {
(size_t)(eptr-(char*)szFromObj(o)) != sdslen(szFromObj(o)) || (size_t)(eptr-(char*)szFromObj(o)) != sdslen(szFromObj(o)) ||
(errno == ERANGE && (errno == ERANGE &&
(value == HUGE_VAL || value == -HUGE_VAL || value == 0)) || (value == HUGE_VAL || value == -HUGE_VAL || value == 0)) ||
isnan(value)) std::isnan(value))
return C_ERR; return C_ERR;
} else if (o->encoding == OBJ_ENCODING_INT) { } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)ptrFromObj(o); value = (long)ptrFromObj(o);
@ -666,7 +666,7 @@ int getLongDoubleFromObject(robj *o, long double *target) {
(size_t)(eptr-(char*)szFromObj(o)) != sdslen(szFromObj(o)) || (size_t)(eptr-(char*)szFromObj(o)) != sdslen(szFromObj(o)) ||
(errno == ERANGE && (errno == ERANGE &&
(value == HUGE_VAL || value == -HUGE_VAL || value == 0)) || (value == HUGE_VAL || value == -HUGE_VAL || value == 0)) ||
isnan(value)) std::isnan(value))
return C_ERR; return C_ERR;
} else if (o->encoding == OBJ_ENCODING_INT) { } else if (o->encoding == OBJ_ENCODING_INT) {
value = (long)szFromObj(o); value = (long)szFromObj(o);

View File

@ -543,10 +543,10 @@ int rdbSaveDoubleValue(rio *rdb, double val) {
unsigned char buf[128]; unsigned char buf[128];
int len; int len;
if (isnan(val)) { if (std::isnan(val)) {
buf[0] = 253; buf[0] = 253;
len = 1; len = 1;
} else if (!isfinite(val)) { } else if (!std::isfinite(val)) {
len = 1; len = 1;
buf[0] = (val < 0) ? 255 : 254; buf[0] = (val < 0) ? 255 : 254;
} else { } else {

View File

@ -40,7 +40,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <cmath>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <limits.h> #include <limits.h>

View File

@ -475,7 +475,7 @@ void sortCommand(client *c) {
vector[j].u.score = strtod(szFromObj(byval),&eptr); vector[j].u.score = strtod(szFromObj(byval),&eptr);
if (eptr[0] != '\0' || errno == ERANGE || if (eptr[0] != '\0' || errno == ERANGE ||
isnan(vector[j].u.score)) std::isnan(vector[j].u.score))
{ {
int_conversion_error = 1; int_conversion_error = 1;
} }

View File

@ -615,7 +615,7 @@ void hincrbyfloatCommand(client *c) {
} }
value += incr; value += incr;
if (isnan(value) || isinf(value)) { if (std::isnan(value) || std::isinf(value)) {
addReplyError(c,"increment would produce NaN or Infinity"); addReplyError(c,"increment would produce NaN or Infinity");
return; return;
} }

View File

@ -28,7 +28,7 @@
*/ */
#include "server.h" #include "server.h"
#include <math.h> /* isnan(), isinf() */ #include <cmath> /* isnan(), isinf() */
/*----------------------------------------------------------------------------- /*-----------------------------------------------------------------------------
* String Commands * String Commands
@ -408,7 +408,7 @@ void incrbyfloatCommand(client *c) {
return; return;
value += incr; value += incr;
if (isnan(value) || isinf(value)) { if (std::isnan(value) || std::isinf(value)) {
addReplyError(c,"increment would produce NaN or Infinity"); addReplyError(c,"increment would produce NaN or Infinity");
return; return;
} }

View File

@ -134,7 +134,7 @@ zskiplistNode *zslInsert(zskiplist *zsl, double score, sds ele) {
unsigned int rank[ZSKIPLIST_MAXLEVEL]; unsigned int rank[ZSKIPLIST_MAXLEVEL];
int i, level; int i, level;
serverAssert(!isnan(score)); serverAssert(!std::isnan(score));
x = zsl->header; x = zsl->header;
for (i = zsl->level-1; i >= 0; i--) { for (i = zsl->level-1; i >= 0; i--) {
/* store rank that is crossed to reach the insert position */ /* store rank that is crossed to reach the insert position */
@ -530,11 +530,11 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
} else { } else {
if (((char*)ptrFromObj(min))[0] == '(') { if (((char*)ptrFromObj(min))[0] == '(') {
spec->min = strtod((char*)ptrFromObj(min)+1,&eptr); spec->min = strtod((char*)ptrFromObj(min)+1,&eptr);
if (eptr[0] != '\0' || isnan(spec->min)) return C_ERR; if (eptr[0] != '\0' || std::isnan(spec->min)) return C_ERR;
spec->minex = 1; spec->minex = 1;
} else { } else {
spec->min = strtod((char*)ptrFromObj(min),&eptr); spec->min = strtod((char*)ptrFromObj(min),&eptr);
if (eptr[0] != '\0' || isnan(spec->min)) return C_ERR; if (eptr[0] != '\0' || std::isnan(spec->min)) return C_ERR;
} }
} }
if (max->encoding == OBJ_ENCODING_INT) { if (max->encoding == OBJ_ENCODING_INT) {
@ -542,11 +542,11 @@ static int zslParseRange(robj *min, robj *max, zrangespec *spec) {
} else { } else {
if (((char*)ptrFromObj(max))[0] == '(') { if (((char*)ptrFromObj(max))[0] == '(') {
spec->max = strtod((char*)ptrFromObj(max)+1,&eptr); spec->max = strtod((char*)ptrFromObj(max)+1,&eptr);
if (eptr[0] != '\0' || isnan(spec->max)) return C_ERR; if (eptr[0] != '\0' || std::isnan(spec->max)) return C_ERR;
spec->maxex = 1; spec->maxex = 1;
} else { } else {
spec->max = strtod((char*)ptrFromObj(max),&eptr); spec->max = strtod((char*)ptrFromObj(max),&eptr);
if (eptr[0] != '\0' || isnan(spec->max)) return C_ERR; if (eptr[0] != '\0' || std::isnan(spec->max)) return C_ERR;
} }
} }
@ -1320,7 +1320,7 @@ int zsetAdd(robj *zobj, double score, sds ele, int *flags, double *newscore) {
double curscore; double curscore;
/* NaN as input is an error regardless of all the other parameters. */ /* NaN as input is an error regardless of all the other parameters. */
if (isnan(score)) { if (std::isnan(score)) {
*flags = ZADD_NAN; *flags = ZADD_NAN;
return 0; return 0;
} }
@ -1339,7 +1339,7 @@ int zsetAdd(robj *zobj, double score, sds ele, int *flags, double *newscore) {
/* Prepare the score for the increment if needed. */ /* Prepare the score for the increment if needed. */
if (incr) { if (incr) {
score += curscore; score += curscore;
if (isnan(score)) { if (std::isnan(score)) {
*flags |= ZADD_NAN; *flags |= ZADD_NAN;
return 0; return 0;
} }
@ -1385,7 +1385,7 @@ int zsetAdd(robj *zobj, double score, sds ele, int *flags, double *newscore) {
/* Prepare the score for the increment if needed. */ /* Prepare the score for the increment if needed. */
if (incr) { if (incr) {
score += curscore; score += curscore;
if (isnan(score)) { if (std::isnan(score)) {
*flags |= ZADD_NAN; *flags |= ZADD_NAN;
return 0; return 0;
} }
@ -2150,7 +2150,7 @@ inline static void zunionInterAggregate(double *target, double val, int aggregat
/* The result of adding two doubles is NaN when one variable /* The result of adding two doubles is NaN when one variable
* is +inf and the other is -inf. When these numbers are added, * is +inf and the other is -inf. When these numbers are added,
* we maintain the convention of the result being 0.0. */ * we maintain the convention of the result being 0.0. */
if (isnan(*target)) *target = 0.0; if (std::isnan(*target)) *target = 0.0;
} else if (aggregate == REDIS_AGGR_MIN) { } else if (aggregate == REDIS_AGGR_MIN) {
*target = val < *target ? val : *target; *target = val < *target ? val : *target;
} else if (aggregate == REDIS_AGGR_MAX) { } else if (aggregate == REDIS_AGGR_MAX) {
@ -2283,7 +2283,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
double score, value; double score, value;
score = src[0].weight * zval.score; score = src[0].weight * zval.score;
if (isnan(score)) score = 0; if (std::isnan(score)) score = 0;
for (j = 1; j < setnum; j++) { for (j = 1; j < setnum; j++) {
/* It is not safe to access the zset we are /* It is not safe to access the zset we are
@ -2330,7 +2330,7 @@ void zunionInterGenericCommand(client *c, robj *dstkey, int op) {
while (zuiNext(&src[i],&zval)) { while (zuiNext(&src[i],&zval)) {
/* Initialize value */ /* Initialize value */
score = src[i].weight * zval.score; score = src[i].weight * zval.score;
if (isnan(score)) score = 0; if (std::isnan(score)) score = 0;
/* Search for this element in the accumulating dictionary. */ /* Search for this element in the accumulating dictionary. */
de = dictAddRaw(accumulator,zuiSdsFromValue(&zval),&existing); de = dictAddRaw(accumulator,zuiSdsFromValue(&zval),&existing);