[LTP] [PATCH 2/5] SAFE_MACROS: Add SAFE_SETPRIORITY()

Guangwen Feng fenggw-fnst@cn.fujitsu.com
Wed Nov 30 13:12:32 CET 2016


Signed-off-by: Guangwen Feng <fenggw-fnst@cn.fujitsu.com>
---
 include/tst_safe_macros.h |  5 +++++
 lib/safe_macros.c         | 15 +++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index ffb5446..9fa0e17 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -471,4 +471,9 @@ int safe_getpriority(const char *file, const int lineno, int which, id_t who);
 #define SAFE_GETPRIORITY(which, who) \
 	safe_getpriority(__FILE__, __LINE__, (which), (who))
 
+int safe_setpriority(const char *file, const int lineno, int which, id_t who,
+	int prio);
+#define SAFE_SETPRIORITY(which, who, prio) \
+	safe_setpriority(__FILE__, __LINE__, (which), (who), (prio))
+
 #endif /* SAFE_MACROS_H__ */
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index 2db362f..a109270 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -778,3 +778,18 @@ int safe_getpriority(const char *file, const int lineno, int which, id_t who)
 	errno = err;
 	return rval;
 }
+
+int safe_setpriority(const char *file, const int lineno, int which, id_t who,
+	int prio)
+{
+	int rval;
+
+	rval = setpriority(which, who, prio);
+	if (rval) {
+		tst_brkm(TBROK | TERRNO, NULL,
+			 "%s:%d setpriority(%i, %i, %i) failed",
+			 file, lineno, which, who, prio);
+	}
+
+	return rval;
+}
-- 
1.8.4.2





More information about the ltp mailing list