git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] block-sha1: drop trailing semicolon from macro definition
@ 2021-03-13 16:17 René Scharfe.
  2021-03-15 23:07 ` Jonathan Nieder
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe. @ 2021-03-13 16:17 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano, Jonathan Nieder

23119ffb4e (block-sha1: put expanded macro parameters in parentheses,
2012-07-22) added a trailing semicolon to the definition of SHA_MIX
without explanation.  It doesn't matter with the current code, but make
sure to avoid potential surprises by removing it again.

This allows the macro to be used almost like a function: Users can
combine it with operators of their choice, but still must not pass an
expression with side-effects as a parameter, as it would be evaluated
multiple times.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 block-sha1/sha1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block-sha1/sha1.c b/block-sha1/sha1.c
index 8681031402..1bb6e7c069 100644
--- a/block-sha1/sha1.c
+++ b/block-sha1/sha1.c
@@ -70,7 +70,7 @@
  * 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_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); \
--
2.30.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] block-sha1: drop trailing semicolon from macro definition
  2021-03-13 16:17 [PATCH] block-sha1: drop trailing semicolon from macro definition René Scharfe.
@ 2021-03-15 23:07 ` Jonathan Nieder
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Nieder @ 2021-03-15 23:07 UTC (permalink / raw)
  To: René Scharfe.; +Cc: Git List, Junio C Hamano

René Scharfe. wrote:

> 23119ffb4e (block-sha1: put expanded macro parameters in parentheses,
> 2012-07-22) added a trailing semicolon to the definition of SHA_MIX
> without explanation.  It doesn't matter with the current code, but make
> sure to avoid potential surprises by removing it again.
>
> This allows the macro to be used almost like a function: Users can
> combine it with operators of their choice, but still must not pass an
> expression with side-effects as a parameter, as it would be evaluated
> multiple times.
>
> Signed-off-by: René Scharfe <l.s.r@web.de>
> ---
>  block-sha1/sha1.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
Yes, it was just a typo.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-15 23:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-13 16:17 [PATCH] block-sha1: drop trailing semicolon from macro definition René Scharfe.
2021-03-15 23:07 ` Jonathan Nieder

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).