Imported Upstream version 2.14.3
[platform/upstream/git.git] / cache.h
diff --git a/cache.h b/cache.h
index 849bc0d..5cc116b 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1264,8 +1264,8 @@ static inline unsigned int hexval(unsigned char c)
  */
 static inline int hex2chr(const char *s)
 {
-       int val = hexval(s[0]);
-       return (val < 0) ? val : (val << 4) | hexval(s[1]);
+       unsigned int val = hexval(s[0]);
+       return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
 }
 
 /* Convert to/from hex/sha1 representation */