trace(1): resolve all level-5 LLVM warnings

Change-Id: If5ffe97eb0b15387b1ab674657879e13f58fb27e
This commit is contained in:
David van Moolenbroek 2015-12-17 13:50:28 +00:00 committed by Lionel Sambuc
parent 0502421f1b
commit b58e161ccb
11 changed files with 38 additions and 37 deletions

View File

@ -10,6 +10,8 @@ SRCS+= block.o char.o net.o svrctl.o
CPPFLAGS+= -D_MINIX_SYSTEM=1 -I${.CURDIR} -I${NETBSDSRCDIR}/minix CPPFLAGS+= -D_MINIX_SYSTEM=1 -I${.CURDIR} -I${NETBSDSRCDIR}/minix
COPTS.format.c+= -Wno-format-nonliteral
error.c: error.awk ${NETBSDSRCDIR}/sys/sys/errno.h error.c: error.awk ${NETBSDSRCDIR}/sys/sys/errno.h
${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}
@ -18,4 +20,6 @@ signal.c: signal.awk ${NETBSDSRCDIR}/sys/sys/signal.h
CLEANFILES+= error.c signal.c CLEANFILES+= error.c signal.c
WARNS?= 5
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -21,17 +21,17 @@ static const struct calls *call_table[] = {
static const struct call_handler * static const struct call_handler *
find_handler(endpoint_t endpt, int call_nr) find_handler(endpoint_t endpt, int call_nr)
{ {
int i, index; unsigned int i, index;
for (i = 0; i < COUNT(call_table); i++) { for (i = 0; i < COUNT(call_table); i++) {
if (call_table[i]->endpt != ANY && if (call_table[i]->endpt != ANY &&
call_table[i]->endpt != endpt) call_table[i]->endpt != endpt)
continue; continue;
if (call_nr < call_table[i]->base) if ((unsigned int)call_nr < call_table[i]->base)
continue; continue;
index = call_nr - call_table[i]->base; index = (unsigned int)call_nr - call_table[i]->base;
if (index >= call_table[i]->count) if (index >= call_table[i]->count)
continue; continue;

View File

@ -19,7 +19,7 @@ BEGIN {
END { END {
printf("};\n\n"); printf("};\n\n");
printf("const char *\nget_error_name(int err)\n{\n\n"); printf("const char *\nget_error_name(int err)\n{\n\n");
printf("\tif (err >= 0 && err < sizeof(errors) / sizeof(errors[0]) &&\n"); printf("\tif (err >= 0 && (unsigned int)err < __arraycount(errors) &&\n");
printf("\t errors[err] != NULL)\n"); printf("\t errors[err] != NULL)\n");
printf("\t\treturn errors[err];\n"); printf("\t\treturn errors[err];\n");
printf("\telse\n"); printf("\telse\n");

View File

@ -249,7 +249,8 @@ put_buf(struct trace_proc * proc, const char * name, int flags, vir_bytes addr,
{ {
const char *escaped; const char *escaped;
size_t len, off, max, chunk; size_t len, off, max, chunk;
int i, cutoff; unsigned int i;
int cutoff;
char *p; char *p;
if ((flags & PF_FAILED) || valuesonly || addr == 0 || size < 0) { if ((flags & PF_FAILED) || valuesonly || addr == 0 || size < 0) {

View File

@ -26,8 +26,8 @@ put_ioctl_req(struct trace_proc * proc, const char * name, unsigned long req,
{ {
const char *text; const char *text;
size_t size; size_t size;
unsigned int group, cmd; unsigned int i, group, cmd;
int i, r, w, big; int r, w, big;
proc->ioctl_index = -1; proc->ioctl_index = -1;
@ -124,7 +124,7 @@ put_ioctl_arg_out(struct trace_proc * proc, const char * name,
} }
assert(proc->ioctl_index >= 0); assert(proc->ioctl_index >= 0);
assert(proc->ioctl_index < COUNT(ioctl_table)); assert((unsigned int)proc->ioctl_index < COUNT(ioctl_table));
assert(ioctl_table[proc->ioctl_index].is_svrctl == is_svrctl); assert(ioctl_table[proc->ioctl_index].is_svrctl == is_svrctl);
proc->ioctl_flags = proc->ioctl_flags =
@ -193,7 +193,7 @@ put_ioctl_arg_in(struct trace_proc * proc, const char * name, int failed,
} }
assert(proc->ioctl_index >= 0); assert(proc->ioctl_index >= 0);
assert(proc->ioctl_index < COUNT(ioctl_table)); assert((unsigned int)proc->ioctl_index < COUNT(ioctl_table));
assert(ioctl_table[proc->ioctl_index].is_svrctl == is_svrctl); assert(ioctl_table[proc->ioctl_index].is_svrctl == is_svrctl);
assert(proc->ioctl_flags != 0); assert(proc->ioctl_flags != 0);

View File

@ -290,7 +290,7 @@ put_msg_control(struct trace_proc * proc, struct msg_control * ptr)
struct msghdr msg; struct msghdr msg;
struct cmsghdr *cmsg; struct cmsghdr *cmsg;
size_t len; size_t len;
int i; unsigned int i;
if (ptr->msg_controllen > sizeof(ptr->msg_control)) { if (ptr->msg_controllen > sizeof(ptr->msg_control)) {
put_field(proc, NULL, ".."); put_field(proc, NULL, "..");

View File

@ -253,12 +253,12 @@ kernel_get_nextframe(pid_t pid, reg_t fp, reg_t * next_pc, reg_t * next_fp)
* processes being attached to, and not for exec calls using a relative path. * processes being attached to, and not for exec calls using a relative path.
*/ */
void void
kernel_put_stacktrace(struct trace_proc * proc) kernel_put_stacktrace(struct trace_proc * procp)
{ {
unsigned int count, max; unsigned int count, max;
reg_t pc, sp, fp, low, high; reg_t pc, sp, fp, low, high;
if (kernel_get_context(proc->pid, &pc, &sp, &fp) < 0) if (kernel_get_context(procp->pid, &pc, &sp, &fp) < 0)
return; return;
/* /*
@ -275,15 +275,15 @@ kernel_put_stacktrace(struct trace_proc * proc)
* the lines straight into tools such as addr2line. * the lines straight into tools such as addr2line.
*/ */
put_newline(); put_newline();
put_fmt(proc, " 0x%x", pc); put_fmt(procp, " 0x%x", pc);
low = high = fp; low = high = fp;
for (count = 1; count < max && fp != 0; count++) { for (count = 1; count < max && fp != 0; count++) {
if (kernel_get_nextframe(proc->pid, fp, &pc, &fp) < 0) if (kernel_get_nextframe(procp->pid, fp, &pc, &fp) < 0)
break; break;
put_fmt(proc, " 0x%x", pc); put_fmt(procp, " 0x%x", pc);
/* /*
* Stop if we see a frame pointer that falls within the range * Stop if we see a frame pointer that falls within the range
@ -299,6 +299,6 @@ kernel_put_stacktrace(struct trace_proc * proc)
} }
if (fp != 0) if (fp != 0)
put_text(proc, " .."); put_text(procp, " ..");
put_newline(); put_newline();
} }

View File

@ -24,9 +24,9 @@ put_kern_clockrate(struct trace_proc * proc, const char * name,
int type __unused, const void * ptr, vir_bytes addr __unused, int type __unused, const void * ptr, vir_bytes addr __unused,
size_t size __unused) size_t size __unused)
{ {
struct clockinfo *ci; const struct clockinfo *ci;
ci = (struct clockinfo *)ptr; ci = (const struct clockinfo *)ptr;
put_value(proc, "hz", "%d", ci->hz); put_value(proc, "hz", "%d", ci->hz);
put_value(proc, "tick", "%d", ci->tick); put_value(proc, "tick", "%d", ci->tick);
@ -48,7 +48,7 @@ put_kern_proc2(struct trace_proc * proc, const char * name, int type,
{ {
const int *mib; const int *mib;
const char *text; const char *text;
int i; unsigned int i;
if (type == ST_NAME) { if (type == ST_NAME) {
mib = (const int *)ptr; mib = (const int *)ptr;
@ -114,7 +114,8 @@ put_kern_proc_args(struct trace_proc * proc, const char * name, int type,
{ {
const int *mib; const int *mib;
const char *text; const char *text;
int i, v; unsigned int i;
int v;
if (type == ST_NAME) { if (type == ST_NAME) {
mib = (const int *)ptr; mib = (const int *)ptr;
@ -164,7 +165,7 @@ static int
put_kern_cp_time(struct trace_proc * proc, const char * name __unused, put_kern_cp_time(struct trace_proc * proc, const char * name __unused,
int type, const void * ptr, vir_bytes addr __unused, size_t size) int type, const void * ptr, vir_bytes addr __unused, size_t size)
{ {
uint64_t *p; const uint64_t *p;
unsigned int i; unsigned int i;
const int *mib; const int *mib;
@ -176,7 +177,7 @@ put_kern_cp_time(struct trace_proc * proc, const char * name __unused,
return 0; return 0;
} }
p = (uint64_t *)ptr; p = (const uint64_t *)ptr;
/* TODO: support for multi-CPU results */ /* TODO: support for multi-CPU results */
for (i = 0; i < CPUSTATES; i++) for (i = 0; i < CPUSTATES; i++)
@ -194,7 +195,7 @@ put_kern_consdev(struct trace_proc * proc, const char * name,
size_t size __unused) size_t size __unused)
{ {
put_dev(proc, NULL, *(dev_t *)ptr); put_dev(proc, NULL, *(const dev_t *)ptr);
return TRUE; return TRUE;
} }
@ -243,7 +244,7 @@ put_kern_sysvipc_info(struct trace_proc * proc, const char * name,
{ {
const int *mib; const int *mib;
const char *text; const char *text;
int i; unsigned int i;
/* /*
* TODO: print the obtained structure(s). For now we are just * TODO: print the obtained structure(s). For now we are just
@ -302,10 +303,10 @@ put_vm_loadavg(struct trace_proc * proc, const char * name __unused,
int type __unused, const void * ptr, vir_bytes addr __unused, int type __unused, const void * ptr, vir_bytes addr __unused,
size_t size __unused) size_t size __unused)
{ {
struct loadavg *loadavg; const struct loadavg *loadavg;
unsigned int i; unsigned int i;
loadavg = (struct loadavg *)ptr; loadavg = (const struct loadavg *)ptr;
put_open(proc, "ldavg", 0, "{", ", "); put_open(proc, "ldavg", 0, "{", ", ");
@ -374,7 +375,7 @@ static const struct flags sysctl_flags[] = {
static void static void
put_sysctl_imm(struct trace_proc * proc, struct sysctlnode * scn, int use_name) put_sysctl_imm(struct trace_proc * proc, struct sysctlnode * scn, int use_name)
{ {
char *name; const char *name;
name = NULL; name = NULL;
@ -569,9 +570,6 @@ put_sysctl_generic(struct trace_proc * proc, const char * name, int type,
{ {
struct sysctlnode scn; struct sysctlnode scn;
void *ptr; void *ptr;
int i;
bool b;
u_quad_t q;
size_t len; size_t len;
switch (SYSCTL_TYPE(proc->sctl_flags)) { switch (SYSCTL_TYPE(proc->sctl_flags)) {
@ -837,7 +835,6 @@ put_sysctl_name(struct trace_proc * proc, const char * name, int flags,
vir_bytes addr, unsigned int namelen) vir_bytes addr, unsigned int namelen)
{ {
const struct sysctl_tab *sct = NULL; const struct sysctl_tab *sct = NULL;
const char *namestr;
int r, all, namebuf[CTL_MAXNAME]; int r, all, namebuf[CTL_MAXNAME];
unsigned int n; unsigned int n;

View File

@ -596,7 +596,6 @@ put_struct_flock(struct trace_proc * proc, const char * name, int flags,
static int static int
vfs_fcntl_out(struct trace_proc * proc, const message * m_out) vfs_fcntl_out(struct trace_proc * proc, const message * m_out)
{ {
int full;
put_fd(proc, "fd", m_out->m_lc_vfs_fcntl.fd); put_fd(proc, "fd", m_out->m_lc_vfs_fcntl.fd);
put_fcntl_cmd(proc, "cmd", m_out->m_lc_vfs_fcntl.cmd); put_fcntl_cmd(proc, "cmd", m_out->m_lc_vfs_fcntl.cmd);
@ -793,9 +792,9 @@ put_dirent_array(struct trace_proc * proc, const char * name, int flags,
count = 0; count = 0;
for (off = 0; off < size; off += chunk) { for (off = 0; off < size; off += chunk) {
chunk = size - off; chunk = size - off;
if (chunk > sizeof(dirent)) if ((size_t)chunk > sizeof(dirent))
chunk = sizeof(dirent); chunk = (ssize_t)sizeof(dirent);
if (chunk < _DIRENT_MINSIZE(&dirent)) if ((size_t)chunk < _DIRENT_MINSIZE(&dirent))
break; break;
if (mem_get_data(proc->pid, addr + off, &dirent, chunk) < 0) { if (mem_get_data(proc->pid, addr + off, &dirent, chunk) < 0) {

View File

@ -23,7 +23,7 @@ BEGIN {
END { END {
printf("};\n\n"); printf("};\n\n");
printf("const char *\nget_signal_name(int sig)\n{\n\n"); printf("const char *\nget_signal_name(int sig)\n{\n\n");
printf("\tif (sig >= 0 && sig < sizeof(signals) / sizeof(signals[0]) &&\n"); printf("\tif (sig >= 0 && (unsigned int)sig < __arraycount(signals) &&\n");
printf("\t signals[sig] != NULL)\n"); printf("\t signals[sig] != NULL)\n");
printf("\t\treturn signals[sig];\n"); printf("\t\treturn signals[sig];\n");
printf("\telse\n"); printf("\telse\n");

View File

@ -1,5 +1,5 @@
#define COUNT(s) (sizeof(s) / sizeof(s[0])) #define COUNT(s) (__arraycount(s))
struct call_handler { struct call_handler {
const char *name; const char *name;