From: Michael Haggerty Date: Sat, 26 Aug 2017 08:28:01 +0000 (+0200) Subject: notes: make GET_NIBBLE macro more robust X-Git-Tag: v2.15.0-rc0~94^2~12 X-Git-Url: http://git.bitbasher.net/?a=commitdiff_plain;h=65eb8e0ca79d4a58768f9409b24c48a95d39bc55;p=git.git notes: make GET_NIBBLE macro more robust Put parentheses around sha1. Otherwise it could fail for something like GET_NIBBLE(n, (unsigned char *)data); Signed-off-by: Michael Haggerty Signed-off-by: Junio C Hamano --- diff --git a/notes.c b/notes.c index 8f47c202c5..71cc664b50 100644 --- a/notes.c +++ b/notes.c @@ -64,7 +64,7 @@ struct non_note { #define CLR_PTR_TYPE(ptr) ((void *) ((uintptr_t) (ptr) & ~3)) #define SET_PTR_TYPE(ptr, type) ((void *) ((uintptr_t) (ptr) | (type))) -#define GET_NIBBLE(n, sha1) (((sha1[(n) >> 1]) >> ((~(n) & 0x01) << 2)) & 0x0f) +#define GET_NIBBLE(n, sha1) ((((sha1)[(n) >> 1]) >> ((~(n) & 0x01) << 2)) & 0x0f) #define KEY_INDEX (GIT_SHA1_RAWSZ - 1) #define FANOUT_PATH_SEPARATORS ((GIT_SHA1_HEXSZ / 2) - 1)