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

Guangwen Feng fenggw-fnst@cn.fujitsu.com
Thu Dec 15 11:49:55 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 32b2556..59973b6 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -471,6 +471,11 @@ 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))
+
 int safe_setxattr(const char *file, const int lineno, const char *path,
             const char *name, const void *value, size_t size, int flags);
 #define SAFE_SETXATTR(path, name, value, size, flags) \
diff --git a/lib/safe_macros.c b/lib/safe_macros.c
index d5c8753..65fe27c 100644
--- a/lib/safe_macros.c
+++ b/lib/safe_macros.c
@@ -780,6 +780,21 @@ int safe_getpriority(const char *file, const int lineno, int which, id_t who)
 	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;
+}
+
 int safe_setxattr(const char *file, const int lineno, const char *path,
 		  const char *name, const void *value, size_t size, int flags)
 {
-- 
1.8.4.2





More information about the ltp mailing list