summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2021-09-10 14:22:25 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2021-09-10 14:22:25 +0000
commit75f928b821c6a7bb4152c20e3b1d347b8f012311 (patch)
tree7c2e539d64d14421ac8f364afc86fe32e5fdbf25
parentf76dc856f469562a4d80451668390a941e069cbc (diff)
Get rid of the last two warnings by turning them off around the problem
statements, if the compiler supports it.
-rw-r--r--usr.bin/tmux/log.c6
-rw-r--r--usr.bin/tmux/tmux.h16
2 files changed, 18 insertions, 4 deletions
diff --git a/usr.bin/tmux/log.c b/usr.bin/tmux/log.c
index f65f618a9a5..2784db6e716 100644
--- a/usr.bin/tmux/log.c
+++ b/usr.bin/tmux/log.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: log.c,v 1.28 2021/08/25 07:09:30 nicm Exp $ */
+/* $OpenBSD: log.c,v 1.29 2021/09/10 14:22:24 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -147,7 +147,7 @@ fatal(const char *msg, ...)
va_start(ap, msg);
if (asprintf(&fmt, "fatal: %s: %s", msg, strerror(errno)) == -1)
exit(1);
- log_vwrite(fmt, ap);
+ no_format_nonliteral(log_vwrite(fmt, ap));
va_end(ap);
exit(1);
}
@@ -162,7 +162,7 @@ fatalx(const char *msg, ...)
va_start(ap, msg);
if (asprintf(&fmt, "fatal: %s", msg) == -1)
exit(1);
- log_vwrite(fmt, ap);
+ no_format_nonliteral(log_vwrite(fmt, ap));
va_end(ap);
exit(1);
}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 0902718aef1..0f43de41428 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.1140 2021/09/09 13:38:32 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.1141 2021/09/10 14:22:24 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -93,6 +93,20 @@ struct winlink;
#define DEFAULT_XPIXEL 16
#define DEFAULT_YPIXEL 32
+/* Don't complain about format arguments. */
+#if __clang__ || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#define no_format_nonliteral(x) do { \
+ _Pragma ("GCC diagnostic push") \
+ _Pragma ("GCC diagnostic ignored \"-Wformat-nonliteral\"") \
+ x; \
+ _Pragma ("GCC diagnostic pop") \
+} while (0)
+#else
+#define no_format_nonliteral(x) do { \
+ x; \
+} while (0)
+#endif
+
/* Attribute to make GCC check printf-like arguments. */
#define printflike(a, b) __attribute__ ((format (printf, a, b)))