From f1b874613f69df24039aad544df5641932697b3d Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Tue, 28 Jul 2009 17:11:31 +0200 Subject: [PATCH] truss(1): Raise WARNS to 6 and fix warnings. --- usr.bin/truss/Makefile | 1 - usr.bin/truss/extern.h | 2 ++ usr.bin/truss/i386-fbsd.c | 24 ++++++++++++------------ usr.bin/truss/i386-linux.c | 22 +++++++++++----------- usr.bin/truss/setup.c | 2 -- 5 files changed, 25 insertions(+), 26 deletions(-) diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile index aa28766b38..553f1dacc5 100644 --- a/usr.bin/truss/Makefile +++ b/usr.bin/truss/Makefile @@ -6,7 +6,6 @@ SRCS= main.c setup.c syscalls.c syscalls.h ioctl.c .if (${MACHINE_ARCH} == "i386") SRCS+= i386-fbsd.c i386-linux.c linux_syscalls.h .endif -WARNS?= 1 CFLAGS+= -I${.CURDIR} -I${.CURDIR}/../../sys -I. diff --git a/usr.bin/truss/extern.h b/usr.bin/truss/extern.h index 33fc46ab33..98801f341a 100644 --- a/usr.bin/truss/extern.h +++ b/usr.bin/truss/extern.h @@ -37,6 +37,8 @@ char procfs_path[FILENAME_MAX]; int have_procfs; +extern int Procfd; + extern int setup_and_wait(char **); extern int start_tracing(int, int); extern void restore_proc(int); diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c index 7a6dd8637c..e070779269 100644 --- a/usr.bin/truss/i386-fbsd.c +++ b/usr.bin/truss/i386-fbsd.c @@ -48,6 +48,7 @@ #include #include +#include #include #include #include @@ -61,7 +62,6 @@ static int fd = -1; static int cpid = -1; -extern int Procfd; extern FILE *outfile; #include "syscalls.h" @@ -79,7 +79,7 @@ static int nsyscalls = sizeof(syscallnames) / sizeof(syscallnames[0]); */ static struct freebsd_syscall { struct syscall *sc; - char *name; + const char *name; int number; unsigned long *args; int nargs; /* number of arguments -- *not* number of words! */ @@ -112,8 +112,8 @@ clear_fsc(void) { void i386_syscall_entry(int pid, int nargs) { char *buf; - struct reg regs = { 0 }; - int syscall; + struct reg regs = { .r_err = 0 }; + int syscall_num; int i; unsigned int parm_offset; struct syscall *sc; @@ -141,25 +141,25 @@ i386_syscall_entry(int pid, int nargs) { * SYS_syscall, and SYS___syscall. The former is the old syscall() * routine, basicly; the latter is for quad-aligned arguments. */ - syscall = regs.r_eax; - switch (syscall) { + syscall_num = regs.r_eax; + switch (syscall_num) { case SYS_syscall: lseek(Procfd, parm_offset, SEEK_SET); - read(Procfd, &syscall, sizeof(int)); + read(Procfd, &syscall_num, sizeof(int)); parm_offset += sizeof(int); break; case SYS___syscall: lseek(Procfd, parm_offset, SEEK_SET); - read(Procfd, &syscall, sizeof(int)); + read(Procfd, &syscall_num, sizeof(int)); parm_offset += sizeof(quad_t); break; } - fsc.number = syscall; + fsc.number = syscall_num; fsc.name = - (syscall < 0 || syscall >= nsyscalls) ? NULL : syscallnames[syscall]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : syscallnames[syscall_num]; if (!fsc.name) { - fprintf(outfile, "-- UNKNOWN SYSCALL %d --\n", syscall); + fprintf(outfile, "-- UNKNOWN SYSCALL %d --\n", syscall_num); } if (nargs == 0) @@ -241,7 +241,7 @@ i386_syscall_entry(int pid, int nargs) { */ void -i386_syscall_exit(int pid, int syscall) { +i386_syscall_exit(int pid, int syscall_num __unused) { char *buf; struct reg regs; int retval; diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c index a28c7dfc40..7336aa705f 100644 --- a/usr.bin/truss/i386-linux.c +++ b/usr.bin/truss/i386-linux.c @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -58,7 +59,6 @@ static int fd = -1; static int cpid = -1; -extern int Procfd; extern FILE *outfile; #include "linux_syscalls.h" @@ -69,7 +69,7 @@ static int nsyscalls = /* See the comment in i386-fbsd.c about this structure. */ static struct linux_syscall { struct syscall *sc; - char *name; + const char *name; int number; unsigned long args[5]; int nargs; /* number of arguments -- *not* number of words! */ @@ -91,8 +91,8 @@ clear_lsc(void) { void i386_linux_syscall_entry(int pid, int nargs) { char *buf; - struct reg regs = { 0 }; - int syscall; + struct reg regs = { .r_err = 0 }; + int syscall_num; int i; struct syscall *sc; @@ -112,13 +112,13 @@ i386_linux_syscall_entry(int pid, int nargs) { clear_lsc(); lseek(fd, 0L, 0); i = read(fd, ®s, sizeof(regs)); - syscall = regs.r_eax; + syscall_num = regs.r_eax; - lsc.number = syscall; + lsc.number = syscall_num; lsc.name = - (syscall < 0 || syscall >= nsyscalls) ? NULL : linux_syscallnames[syscall]; + (syscall_num < 0 || syscall_num >= nsyscalls) ? NULL : linux_syscallnames[syscall_num]; if (!lsc.name) { - fprintf (outfile, "-- UNKNOWN SYSCALL %d\n", syscall); + fprintf (outfile, "-- UNKNOWN SYSCALL %d\n", syscall_num); } if (nargs == 0) @@ -198,11 +198,11 @@ const int bsd_to_linux_errno[] = { }; void -i386_linux_syscall_exit(int pid, int syscall) { +i386_linux_syscall_exit(int pid, int syscall_num __unused) { char *buf; struct reg regs; int retval; - int size, i; + int i; int errorp; struct syscall *sc; @@ -247,7 +247,7 @@ i386_linux_syscall_exit(int pid, int syscall) { } } if (errorp) { - for (i = 0; i < sizeof(bsd_to_linux_errno) / sizeof(int); i++) + for (i = 0; i < (int)(sizeof(bsd_to_linux_errno) / sizeof(int)); i++) if (retval == bsd_to_linux_errno[i]) break; } diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 4e6bc44dbe..3e0a4cf969 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -184,8 +184,6 @@ start_tracing(int pid, int flags) { */ void restore_proc(int signo __unused) { - extern int Procfd; - ioctl(Procfd, PIOCBIC, ~0); if (evflags) ioctl(Procfd, PIOCBIS, evflags); -- 2.41.0