[RFC,2/9] tst_safe_sysv_ipc: SAFE_{SHMCTL, MSGCTL} return retval

Message ID 20180612154631.435-3-chrubis@suse.cz
State Accepted
Headers show
Series
  • Rewrite msgctl testcases
Related show

Commit Message

Cyril Hrubis June 12, 2018, 3:46 p.m.
These calls do return index into kernel internal array or IPC id for
Linux specific cmds, hence we need to propagate the return value.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/tst_safe_sysv_ipc.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Petr Vorel June 13, 2018, 10:49 a.m. | #1
Hi Cyril,

> These calls do return index into kernel internal array or IPC id for
> Linux specific cmds, hence we need to propagate the return value.

> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> ---


Kind regards,
Petr

Patch

diff --git a/include/tst_safe_sysv_ipc.h b/include/tst_safe_sysv_ipc.h
index e01957f75..4c7500531 100644
--- a/include/tst_safe_sysv_ipc.h
+++ b/include/tst_safe_sysv_ipc.h
@@ -39,10 +39,10 @@  ssize_t safe_msgrcv(const char *file, const int lineno, int msqid, void *msgp,
 
 int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
 		struct msqid_ds *buf);
-#define SAFE_MSGCTL(msqid, cmd, buf) do { \
-	safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf)); \
+#define SAFE_MSGCTL(msqid, cmd, buf) ({ \
+	int tst_ret_ = safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf)); \
 	(msqid) = ((cmd) == IPC_RMID ? -1 : (msqid)); \
-	} while (0)
+	tst_ret_;})
 
 int safe_shmget(const char *file, const int lineno, key_t key, size_t size,
 		int shmflg);
@@ -59,9 +59,9 @@  int safe_shmdt(const char *file, const int lineno, const void *shmaddr);
 
 int safe_shmctl(const char *file, const int lineno, int shmid, int cmd,
 		struct shmid_ds *buf);
-#define SAFE_SHMCTL(shmid, cmd, buf) do { \
-	safe_shmctl(__FILE__, __LINE__, (shmid), (cmd), (buf)); \
+#define SAFE_SHMCTL(shmid, cmd, buf) ({ \
+	int tst_ret_ = safe_shmctl(__FILE__, __LINE__, (shmid), (cmd), (buf)); \
 	(shmid) = ((cmd) == IPC_RMID ? -1 : (shmid)); \
-	} while (0)
+	tst_ret_;})
 
 #endif /* TST_SAFE_SYSV_IPC_H__ */