Permalink
Browse files

check eptr inline

  • Loading branch information...
1 parent bd79a6b commit 682c73e87e6edfdfe76b9bb4b3d66ce39465b359 @pietern pietern committed Apr 16, 2010
Showing with 4 additions and 10 deletions.
  1. +4 −10 redis.c
View
14 redis.c
@@ -3106,25 +3106,22 @@ static size_t stringObjectLen(robj *o) {
static int getDoubleFromObject(robj *o, double *target) {
double value;
- char *eptr = NULL;
+ char *eptr;
if (o == NULL) {
value = 0;
} else {
redisAssert(o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_RAW) {
value = strtod(o->ptr, &eptr);
+ if (eptr[0] != '\0') return REDIS_ERR;
} else if (o->encoding == REDIS_ENCODING_INT) {
value = (long)o->ptr;
} else {
redisAssert(1 != 1);
}
}
- if (eptr != NULL && eptr[0] != '\0') {
- return REDIS_ERR;
- }
-
*target = value;
return REDIS_OK;
}
@@ -3146,25 +3143,22 @@ static int getDoubleFromObjectOrReply(redisClient *c, robj *o, double *target, c
static int getLongLongFromObject(robj *o, long long *target) {
long long value;
- char *eptr = NULL;
+ char *eptr;
if (o == NULL) {
value = 0;
} else {
redisAssert(o->type == REDIS_STRING);
if (o->encoding == REDIS_ENCODING_RAW) {
value = strtoll(o->ptr, &eptr, 10);
+ if (eptr[0] != '\0') return REDIS_ERR;
} else if (o->encoding == REDIS_ENCODING_INT) {
value = (long)o->ptr;
} else {
redisAssert(1 != 1);
}
}
- if (eptr != NULL && eptr[0] != '\0') {
- return REDIS_ERR;
- }
-
*target = value;
return REDIS_OK;
}

0 comments on commit 682c73e

Please sign in to comment.