[CRIU] [PATCH 2/2] util: add parameter parenthesis to __open_proc statement in expr

Dmitry Safonov dsafonov at virtuozzo.com
Thu Apr 21 04:27:31 PDT 2016


Fixes small bug:
__open_proc() macro is called from parse_pid_loginuid as:
>	fd = __open_proc(pid, (ignore_noent) ? ENOENT : 0,
>			O_RDONLY, "loginuid");

So, ier parameter is badly expanded with current version:
>	if (__fd < 0 && (errno != (ignore_noent) ? ENOENT : 0)

Which in result does not hide "No such file" error on feature
test (at least with arm-gcc). Not a big deal, tho.

Reported-by: alex vk <avankemp at gmail.com>
Signed-off-by: Dmitry Safonov <dsafonov at virtuozzo.com>
---
 criu/include/util.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/criu/include/util.h b/criu/include/util.h
index 2d6fa590e7ab..8efa1a849bb7 100644
--- a/criu/include/util.h
+++ b/criu/include/util.h
@@ -79,7 +79,7 @@ extern int do_open_proc(pid_t pid, int flags, const char *fmt, ...);
 	({								\
 		int __fd = do_open_proc(pid, flags,			\
 					fmt, ##__VA_ARGS__);		\
-		if (__fd < 0 && (errno != ier))				\
+		if (__fd < 0 && (errno != (ier)))			\
 			pr_perror("Can't open %d/" fmt " on procfs",	\
 					pid, ##__VA_ARGS__);		\
 									\
-- 
2.8.0



More information about the CRIU mailing list