[LTP] [PATCH 3/6] safe_macros: add SAFE_SETENV()

Jan Stancek
2017-10-10T15:05:11Z

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
include/tst_safe_macros.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 1e034b8e29d7..5d8952544be3 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -447,5 +447,12 @@ int safe_personality(const char *filename, unsigned int lineno,
unsigned long persona);
#define SAFE_PERSONALITY(persona) safe_personality(__FILE__, __LINE__, persona)

+#define SAFE_SETENV(name, value, overwrite) do { \
+ if (setenv(name, value, overwrite)) { \
+ tst_brk_(__FILE__, __LINE__, TBROK | TERRNO, \
+ "setenv(%s, %s, %d) failed", \
+ name, value, overwrite); \
+ } \
+ } while (0)

#endif /* SAFE_MACROS_H__ */
--
1.8.3.1