]> git.saurik.com Git - redis.git/commitdiff
check eptr inline
authorPieter Noordhuis <pcnoordhuis@gmail.com>
Fri, 16 Apr 2010 12:42:14 +0000 (14:42 +0200)
committerPieter Noordhuis <pcnoordhuis@gmail.com>
Sat, 17 Apr 2010 11:06:49 +0000 (13:06 +0200)
redis.c

diff --git a/redis.c b/redis.c
index 39296e9141dd27000ea4cc89a6fba6c12ad5ab76..b926e5a48f30112a3c9bab72b738900c66f9e9c9 100644 (file)
--- a/redis.c
+++ b/redis.c
@@ -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;
 }