bug-time
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: time-aux: fix unintented expression grouping


From: Andreas Schwab
Subject: [PATCH] tests: time-aux: fix unintented expression grouping
Date: Thu, 30 Mar 2023 11:42:08 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

The compiler warns about a likely unintented expression grouping:

tests/time-aux.c:245:21: warning: suggest parentheses around '+' in operand of 
'&' [-Wparentheses]
  245 |     getcwd (buf, 10 + (pid+ppid+uid+euid+gid+egid)&0xF);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Given how the expression is formatted, it is more likely the author
intented the '&' operator to only apply to the parenthesized
subexpression.
---
 tests/time-aux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/time-aux.c b/tests/time-aux.c
index 5ed77fe..ddee1d0 100644
--- a/tests/time-aux.c
+++ b/tests/time-aux.c
@@ -274,7 +274,7 @@ busy_sys_sleep (const struct timespec *sleep)
     euid = geteuid();
     gid = getgid();
     egid = getegid();
-    getcwd (buf, 10 + (pid+ppid+uid+euid+gid+egid)&0xF);
+    getcwd (buf, 10 + ((pid+ppid+uid+euid+gid+egid)&0xF));
   }
 }
 
-- 
2.40.0


-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]