git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] block-sha1: put expanded macro parameters in parentheses

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 22, 2012, 23:40 UTC
Message-ID
<20120722234054.GB2012@burratino>
In-Reply-To
<20120722233547.GA1978@burratino>

't' is currently always a numeric constant, but it can't hurt to prepare for the day that it becomes useful for a caller to pass in a more complex expression.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Clarified subject line.  No other change.
Thanks for reading.
 block-sha1/sha1.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
index 10fd94d1..6f885c43 100644
--- a/block-sha1/sha1.c
+++ b/block-sha1/sha1.c
@@ -100,8 +100,8 @@
  * Where do we get the source from? The first 16 iterations get it from
  * the input data, the next mix it from the 512-bit array.
  */
-#define SHA_SRC(t) get_be32((unsigned char *) block + t*4)
-#define SHA_MIX(t) SHA_ROL(W(t+13) ^ W(t+8) ^ W(t+2) ^ W(t), 1)
+#define SHA_SRC(t) get_be32((unsigned char *) block + (t)*4)
+#define SHA_MIX(t) SHA_ROL(W((t)+13) ^ W((t)+8) ^ W((t)+2) ^ W(t), 1);
 
 #define SHA_ROUND(t, input, fn, constant, A, B, C, D, E) do { \
 	unsigned int TEMP = input(t); setW(t, TEMP); \
-- 
1.7.10.4
Previous: Jonathan NiederNext: Junio C Hamano
Message 3 of 9 in “block-sha1: avoid pointer conversion that violates alignment constraints”
  1. 0/2 block-sha1: avoid pointer conversion that violates alignment constraintsJonathan Nieder, Jul 22, 2012
  2. 1/2 block-sha1: avoid pointer conversion that violates alignment constraintsJonathan Nieder, Jul 22, 2012
  3. 2/2 block-sha1: put expanded macro parameters in parenthesesJonathan Nieder, Jul 22, 2012
  4. Junio C HamanoJul 23, 2012
  5. Jonathan NiederJul 23, 2012
  6. Junio C HamanoJul 23, 2012
  7. Jonathan NiederJul 23, 2012
  8. Junio C HamanoJul 23, 2012
  9. 3/1 Makefile: BLK_SHA1 does not require fast htonl() and unaligned loadsJonathan Nieder, Jul 23, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.