static int getDoubleFromObject(robj *o, double *target) {
double value;
- char *eptr = NULL;
+ char *eptr;
if (o == NULL) {
value = 0;
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 {
}
}
- if (eptr != NULL && eptr[0] != '\0') {
- return REDIS_ERR;
- }
-
*target = value;
return REDIS_OK;
}
static int getLongLongFromObject(robj *o, long long *target) {
long long value;
- char *eptr = NULL;
+ char *eptr;
if (o == NULL) {
value = 0;
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 {
}
}
- if (eptr != NULL && eptr[0] != '\0') {
- return REDIS_ERR;
- }
-
*target = value;
return REDIS_OK;
}