tst_safe_sysv_ipc: Set msqid to -1 on IPC_RMID
We do the same for the fd on SAFE_CLOSE() as well.
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
diff --git a/include/tst_safe_sysv_ipc.h b/include/tst_safe_sysv_ipc.h
index 5bb836a..cbdefb9 100644
--- a/include/tst_safe_sysv_ipc.h
+++ b/include/tst_safe_sysv_ipc.h
@@ -34,7 +34,9 @@
int safe_msgctl(const char *file, const int lineno, int msqid, int cmd,
struct msqid_ds *buf);
-#define SAFE_MSGCTL(msqid, cmd, buf) \
- safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf))
+#define SAFE_MSGCTL(msqid, cmd, buf) do { \
+ safe_msgctl(__FILE__, __LINE__, (msqid), (cmd), (buf)); \
+ (msqid) = ((cmd) == IPC_RMID ? -1 : (msqid)); \
+ } while (0)
#endif /* TST_SAFE_SYSV_IPC_H__ */