All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Cervesato via ltp <ltp@lists.linux.it>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 1/7] Add more safe macros for mqueue API
Date: Fri, 22 Jul 2022 14:04:55 +0200	[thread overview]
Message-ID: <20220722120501.28670-2-andrea.cervesato@suse.com> (raw)
In-Reply-To: <20220722120501.28670-1-andrea.cervesato@suse.com>

Added SAFE_MQ_UNLINK and SAFE_MQ_CLOSE in tst_safe_posix_ipc.h

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 include/tst_safe_posix_ipc.h | 45 ++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/include/tst_safe_posix_ipc.h b/include/tst_safe_posix_ipc.h
index b60c12c9e..5bfef03a9 100644
--- a/include/tst_safe_posix_ipc.h
+++ b/include/tst_safe_posix_ipc.h
@@ -12,6 +12,12 @@
 #define SAFE_MQ_OPEN(pathname, oflags, ...) \
 	safe_mq_open(__FILE__, __LINE__, (pathname), (oflags), ##__VA_ARGS__)
 
+#define SAFE_MQ_CLOSE(__mqdes) \
+	safe_mq_close(__FILE__, __LINE__, (__mqdes))
+
+#define SAFE_MQ_UNLINK(name) \
+	safe_mq_unlink(__FILE__, __LINE__, (name))
+
 static inline int safe_mq_open(const char *file, const int lineno,
 			       const char *pathname, int oflags, ...)
 {
@@ -41,6 +47,45 @@ static inline int safe_mq_open(const char *file, const int lineno,
 		tst_brk_(file, lineno, TBROK | TERRNO,
 			"mq_open(%s,%d,%04o,%p) failed", pathname, oflags,
 			mode, attr);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_open(%s) return value %d", pathname, rval);
+	}
+
+	return rval;
+}
+
+static inline int safe_mq_close(const char *file, const int lineno,
+				mqd_t __mqdes)
+{
+	int rval;
+
+	rval = mq_close(__mqdes);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"mq_close(%d) failed", __mqdes);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_close(%d) return value %d", __mqdes, rval);
+	}
+
+	return rval;
+}
+
+static inline int safe_mq_unlink(const char *file, const int lineno,
+				const char* name)
+{
+	int rval;
+
+	rval = mq_unlink(name);
+
+	if (rval == -1) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"mq_unlink(%s) failed", name);
+	} else if (rval < 0) {
+		tst_brk_(file, lineno, TBROK | TERRNO,
+			"Invalid mq_unlink(%s) return value %d", name, rval);
 	}
 
 	return rval;
-- 
2.35.3


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2022-07-22 12:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-22 12:04 [LTP] [PATCH v3 0/7] Refactor mqns testing suite Andrea Cervesato via ltp
2022-07-22 12:04 ` Andrea Cervesato via ltp [this message]
2022-07-26  6:50   ` [LTP] [PATCH v3 1/7] Add more safe macros for mqueue API Petr Vorel
2022-11-01 11:36   ` Richard Palethorpe
2022-07-22 12:04 ` [LTP] [PATCH v3 2/7] Refactor mqns_01 using new LTP API Andrea Cervesato via ltp
2022-08-11  9:53   ` Richard Palethorpe
2022-08-11 11:13     ` Andrea Cervesato via ltp
2022-09-02  9:05       ` Richard Palethorpe
2022-10-11  9:17         ` Richard Palethorpe
2022-10-11  9:42           ` Andrea Cervesato via ltp
2022-10-11 10:49             ` Richard Palethorpe
2022-10-11 11:19               ` Andrea Cervesato via ltp
2022-07-22 12:04 ` [LTP] [PATCH v3 3/7] Refactor mqns_02 " Andrea Cervesato via ltp
2022-07-22 12:04 ` [LTP] [PATCH v3 4/7] Refactor mqns_03 " Andrea Cervesato via ltp
2022-07-22 12:04 ` [LTP] [PATCH v3 5/7] Refactor mqns_04 " Andrea Cervesato via ltp
2022-07-22 12:05 ` [LTP] [PATCH v3 6/7] Delete deprecated mqns header files Andrea Cervesato via ltp
2022-07-22 12:05 ` [LTP] [PATCH v3 7/7] Rename common.h into mqns.h for mqns suite Andrea Cervesato via ltp
2022-07-26  7:00   ` Petr Vorel
2022-07-26 11:52     ` [LTP] [PATCH] tools: Check headers with checkpatch.pl Richard Palethorpe via ltp
2022-07-26 12:03       ` Petr Vorel
2022-07-26 12:53         ` Richard Palethorpe
2022-07-26 14:05           ` Petr Vorel
2022-10-11 10:15 ` [LTP] [PATCH v3 0/7] Refactor mqns testing suite Richard Palethorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220722120501.28670-2-andrea.cervesato@suse.com \
    --to=ltp@lists.linux.it \
    --cc=andrea.cervesato@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.