提交 682c73e8 编写于 作者: P Pieter Noordhuis

check eptr inline

上级 bd79a6bd
......@@ -3106,7 +3106,7 @@ 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;
......@@ -3114,6 +3114,7 @@ static int getDoubleFromObject(robj *o, double *target) {
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 {
......@@ -3121,10 +3122,6 @@ static int getDoubleFromObject(robj *o, double *target) {
}
}
if (eptr != NULL && eptr[0] != '\0') {
return REDIS_ERR;
}
*target = value;
return REDIS_OK;
}
......@@ -3146,7 +3143,7 @@ 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;
......@@ -3154,6 +3151,7 @@ static int getLongLongFromObject(robj *o, long long *target) {
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 {
......@@ -3161,10 +3159,6 @@ static int getLongLongFromObject(robj *o, long long *target) {
}
}
if (eptr != NULL && eptr[0] != '\0') {
return REDIS_ERR;
}
*target = value;
return REDIS_OK;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册