From 153929b11e2d1545d61fdfe85dec5e7883679f3e Mon Sep 17 00:00:00 2001 From: "Anthony G. Basile" Date: Fri, 21 Feb 2014 12:11:59 -0500 Subject: Add missing REENABLE_WARNING and unlink_noerrno() Signed-off-by: Anthony G. Basile --- src/libudev/macro.h | 3 +++ src/libudev/util.c | 11 +++++++++++ src/libudev/util.h | 1 + 3 files changed, 15 insertions(+) (limited to 'src') diff --git a/src/libudev/macro.h b/src/libudev/macro.h index 088fcd2640..ac2a23f6aa 100644 --- a/src/libudev/macro.h +++ b/src/libudev/macro.h @@ -44,6 +44,9 @@ _Pragma("GCC diagnostic push"); \ _Pragma("GCC diagnostic ignored \"-Wformat-nonliteral\"") +#define REENABLE_WARNING \ + _Pragma("GCC diagnostic pop") + /* Rounds up */ #define ALIGN4(l) (((l) + 3) & ~3) diff --git a/src/libudev/util.c b/src/libudev/util.c index 93f60b8ec4..a0d7cac697 100644 --- a/src/libudev/util.c +++ b/src/libudev/util.c @@ -284,6 +284,17 @@ void close_nointr_nofail(int fd) { assert_se(close_nointr(fd) == 0); } +int unlink_noerrno(const char *path) { + PROTECT_ERRNO; + int r; + + r = unlink(path); + if (r < 0) + return -errno; + + return 0; +} + int safe_atou(const char *s, unsigned *ret_u) { char *x = NULL; unsigned long l; diff --git a/src/libudev/util.h b/src/libudev/util.h index 60ef764d97..33e9efbfab 100644 --- a/src/libudev/util.h +++ b/src/libudev/util.h @@ -328,6 +328,7 @@ static inline void _reset_errno_(int *saved_errno) { #define PROTECT_ERRNO _cleanup_(_reset_errno_) __attribute__((unused)) int _saved_errno_ = errno +int unlink_noerrno(const char *path); static inline void qsort_safe(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *)) { if (nmemb) { -- cgit v1.2.3-54-g00ecf