summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2017-09-03 11:58:12 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2017-09-03 11:58:12 -0400
commite12334d3d277855d5ea0c75a83be6b8659feadc0 (patch)
treec6c5e19bafbf2e3078848fd50fa30f5daf5355a2
parent7d83c476e68e81e28f527cea7acb5f7c01dfe068 (diff)
nshd-tester: help GCC out a bit by defining assert_not_reached()
-Werror=implicit-fallthrough was tripping up on the case that ended with error(EXIT_FAILURE, ...).
-rw-r--r--bin/nshd-tester.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/bin/nshd-tester.c b/bin/nshd-tester.c
index 260bce7..6e52166 100644
--- a/bin/nshd-tester.c
+++ b/bin/nshd-tester.c
@@ -30,6 +30,13 @@
#define _(s) s
+#define assert_not_reached() \
+ do { \
+ error(0, 0, _("Code should not be reached at %s:%u, function %s(). Aborting."), \
+ __FILE__, __LINE__, (__extension__ __PRETTY_FUNCTION__)); \
+ abort(); \
+ } while (0)
+
const char *xgetenv(const char *name, const char *unset) {
const char *val = getenv(name);
if (!val)
@@ -127,6 +134,7 @@ int main(int argc, char *argv[]) {
switch (pid) {
case -1:
error(EXIT_FAILURE, errno, "fork");
+ assert_not_reached();
case 0:
close(notify_sock);
dup2(nslcd_sock, 3);
@@ -163,6 +171,5 @@ int main(int argc, char *argv[]) {
if (bytes_written < 0)
error(EXIT_FAILURE, errno, "write");
}
- error(EXIT_FAILURE, 0, "not reached");
- return EXIT_FAILURE;
+ assert_not_reached();
}