From acf41c96cbeb9fcbaefc321b65a6a7c3053be75e Mon Sep 17 00:00:00 2001
From: antirez <antirez@gmail.com>
Date: Wed, 18 Apr 2012 11:37:14 +0200
Subject: [PATCH] Marginally cleaner lookupKeyByPattern() implementation.

just fieldobj itself as sentinel of the fact a field object is used or
not, instead of using the filed length, that may be confusing both for
people and for the compiler emitting a warning.
---
 src/sort.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/sort.c b/src/sort.c
index ff655c7e..c1ed5517 100644
--- a/src/sort.c
+++ b/src/sort.c
@@ -28,7 +28,7 @@ redisSortOperation *createSortOperation(int type, robj *pattern) {
 robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
     char *p, *f, *k;
     sds spat, ssub;
-    robj *keyobj, *fieldobj, *o;
+    robj *keyobj, *fieldobj = NULL, *o;
     int prefixlen, sublen, postfixlen, fieldlen;
 
     /* If the pattern is "#" return the substitution object itself in order
@@ -76,7 +76,7 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
     o = lookupKeyRead(db,keyobj);
     if (o == NULL) goto noobj;
 
-    if (fieldlen > 0) {
+    if (fieldobj) {
         if (o->type != REDIS_HASH) goto noobj;
 
         /* Retrieve value from hash by the field name. This operation
@@ -90,7 +90,7 @@ robj *lookupKeyByPattern(redisDb *db, robj *pattern, robj *subst) {
         incrRefCount(o);
     }
     decrRefCount(keyobj);
-    if (fieldlen) decrRefCount(fieldobj);
+    if (fieldobj) decrRefCount(fieldobj);
     return o;
 
 noobj: