aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2020-06-21 12:31:48 +0200
committerMattias Andrée <maandree@kth.se>2020-06-21 12:31:48 +0200
commitb801444251f6c342c3daad2152f9a4f7215ea8ee (patch)
tree1a885c36a5a1fd7ac44b96eb2332434524606c5f
parentFix CASE macro: tprintf is returns void, so return in separate statement (diff)
downloadsctrace-b801444251f6c342c3daad2152f9a4f7215ea8ee.tar.gz
sctrace-b801444251f6c342c3daad2152f9a4f7215ea8ee.tar.bz2
sctrace-b801444251f6c342c3daad2152f9a4f7215ea8ee.tar.xz
Fix some warnings and move include statement to common.h
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r--arg.h4
-rw-r--r--common.h16
-rw-r--r--sctrace.c7
-rw-r--r--util.c5
4 files changed, 27 insertions, 5 deletions
diff --git a/arg.h b/arg.h
index 971fc79..4f35620 100644
--- a/arg.h
+++ b/arg.h
@@ -9,7 +9,7 @@
extern char *argv0;
/* use main(int argc, char *argv[]) */
-#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\
+#define ARGBEGIN do { for (argv0 = *argv, argv++, argc--;\
argv[0] && argv[0][0] && argv[0][1];\
argc--, argv++) {\
char argc_;\
@@ -55,7 +55,7 @@ extern char *argv0;
} else {\
break;\
}\
- }
+ } } while (0)
#define ARGC() argc_
diff --git a/common.h b/common.h
index 672aa37..43edb74 100644
--- a/common.h
+++ b/common.h
@@ -1,4 +1,5 @@
/* See LICENSE file for copyright and license details. */
+#include <asm/unistd.h>
#include <sys/uio.h>
#include <sys/wait.h>
#include <ctype.h>
@@ -12,6 +13,21 @@
#include <string.h>
#include <unistd.h>
+#if defined(__clang__)
+# define FALL_THROUGH __attribute__((fallthrough));
+#else
+# define FALL_THROUGH
+#endif
+
+#if defined(__clang__)
+# pragma clang diagnostic ignored "-Wdisabled-macro-expansion"
+# pragma clang diagnostic ignored "-Wpadded"
+#elif defined(__GNUC__)
+# pragma GCC diagnostic ignored "-Wpadded"
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=pure"
+# pragma GCC diagnostic ignored "-Wsuggest-attribute=format"
+#endif
+
#if defined(__linux__)
# include "linux/os.h"
#else
diff --git a/sctrace.c b/sctrace.c
index d7e1766..c13c5bb 100644
--- a/sctrace.c
+++ b/sctrace.c
@@ -1,14 +1,12 @@
/* See LICENSE file for copyright and license details. */
#include "common.h"
-#include <asm/unistd.h>
-
char *argv0;
static unsigned long int trace_options = PTRACE_O_EXITKILL | PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC;
-static void
+_Noreturn static void
usage(void)
{
fprintf(stderr, "usage: %s [-o trace-output-file] [-ft] (command | -0 command argv0) [argument] ...\n", argv0);
@@ -75,6 +73,7 @@ handle_syscall(struct process *proc)
case Exec:
proc->silent_until_execed -= (proc->silent_until_execed == 2);
+ FALL_THROUGH
/* fall through */
case VforkParent:
if (ptrace(PTRACE_SYSCALL, proc->pid, NULL, 0))
@@ -105,6 +104,7 @@ handle_event(struct process *proc, int status)
case PTRACE_EVENT_VFORK:
tprintf(proc, "\nProcess stopped by vfork until child exits or exec(2)s\n");
+ FALL_THROUGH
/* fall through */
case PTRACE_EVENT_FORK:
case PTRACE_EVENT_CLONE:
@@ -198,6 +198,7 @@ main(int argc, char **argv)
case 'f':
trace_options |= PTRACE_O_TRACEFORK;
trace_options |= PTRACE_O_TRACEVFORK;
+ FALL_THROUGH
/* fall through */
case 't':
trace_options |= PTRACE_O_TRACECLONE;
diff --git a/util.c b/util.c
index b2d8341..7888133 100644
--- a/util.c
+++ b/util.c
@@ -2,6 +2,11 @@
#include "common.h"
+#if defined(__GNUC__) || defined(__clang__)
+# pragma GCC diagnostic ignored "-Wformat-nonliteral"
+#endif
+
+
static FILE *trace_fp;
static char last_char = '\n';
static pid_t last_pid = 0;