summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-25 20:53:29 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-25 21:50:48 -0400
commit2a371001f8d23533a339a150eeffa3215773058d (patch)
tree158295689f5a089c643f6bee57cc1ee9fa9a78b3 /src/test
parente0a974b471cced122a91f03b3f635a6dd89e1499 (diff)
Use attribute(unused) in PROTECT_ERRNO
clang emits warnings about unused attribute _saved_errno_, which drown out other—potentially useful—warnings. gcc documentation is not exactly verbose about the effects of __attribute__((unused)) on variables, but let's assume that it works if the unit test passes.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-util.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/test/test-util.c b/src/test/test-util.c
index 66a10ead46..4c3a8a6b88 100644
--- a/src/test/test-util.c
+++ b/src/test/test-util.c
@@ -24,6 +24,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <locale.h>
+#include <errno.h>
#include "util.h"
@@ -429,6 +430,15 @@ static void test_get_process_comm(void) {
log_info("pid1 $PATH: '%s'", strna(i));
}
+static void test_protect_errno(void) {
+ errno = 12;
+ {
+ PROTECT_ERRNO;
+ errno = 11;
+ }
+ assert(errno == 12);
+}
+
int main(int argc, char *argv[]) {
test_streq_ptr();
test_first_word();
@@ -456,6 +466,7 @@ int main(int argc, char *argv[]) {
test_hostname_is_valid();
test_u64log2();
test_get_process_comm();
+ test_protect_errno();
return 0;
}