summaryrefslogtreecommitdiff
path: root/notes.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-08-26 10:28:01 +0200
committerJunio C Hamano <gitster@pobox.com>2017-08-26 09:21:01 -0700
commit65eb8e0ca79d4a58768f9409b24c48a95d39bc55 (patch)
tree836945d08ff835e5128fa677a796120d53323951 /notes.c
parentedc74bc7f0c6884027e851ef09b2e0c9380dcd45 (diff)
downloadgit-65eb8e0ca79d4a58768f9409b24c48a95d39bc55.tar.gz
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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'notes.c')
-rw-r--r--notes.c2
1 files changed, 1 insertions, 1 deletions
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)