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
${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET}
CLEANFILES+= error.c signal.c
+WARNS?= 5
+
.include <bsd.prog.mk>
static const struct call_handler *
find_handler(endpoint_t endpt, int call_nr)
{
- int i, index;
+ unsigned int i, index;
for (i = 0; i < COUNT(call_table); i++) {
if (call_table[i]->endpt != ANY &&
call_table[i]->endpt != endpt)
continue;
- if (call_nr < call_table[i]->base)
+ if ((unsigned int)call_nr < call_table[i]->base)
continue;
- index = call_nr - call_table[i]->base;
+ index = (unsigned int)call_nr - call_table[i]->base;
if (index >= call_table[i]->count)
continue;
END {
printf("};\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\treturn errors[err];\n");
printf("\telse\n");
{
const char *escaped;
size_t len, off, max, chunk;
- int i, cutoff;
+ unsigned int i;
+ int cutoff;
char *p;
if ((flags & PF_FAILED) || valuesonly || addr == 0 || size < 0) {
{
const char *text;
size_t size;
- unsigned int group, cmd;
- int i, r, w, big;
+ unsigned int i, group, cmd;
+ int r, w, big;
proc->ioctl_index = -1;
}
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);
proc->ioctl_flags =
}
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(proc->ioctl_flags != 0);
struct msghdr msg;
struct cmsghdr *cmsg;
size_t len;
- int i;
+ unsigned int i;
if (ptr->msg_controllen > sizeof(ptr->msg_control)) {
put_field(proc, NULL, "..");
* processes being attached to, and not for exec calls using a relative path.
*/
void
-kernel_put_stacktrace(struct trace_proc * proc)
+kernel_put_stacktrace(struct trace_proc * procp)
{
unsigned int count, max;
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;
/*
* the lines straight into tools such as addr2line.
*/
put_newline();
- put_fmt(proc, " 0x%x", pc);
+ put_fmt(procp, " 0x%x", pc);
low = high = fp;
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;
- put_fmt(proc, " 0x%x", pc);
+ put_fmt(procp, " 0x%x", pc);
/*
* Stop if we see a frame pointer that falls within the range
}
if (fp != 0)
- put_text(proc, " ..");
+ put_text(procp, " ..");
put_newline();
}
int type __unused, const void * ptr, vir_bytes addr __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, "tick", "%d", ci->tick);
{
const int *mib;
const char *text;
- int i;
+ unsigned int i;
if (type == ST_NAME) {
mib = (const int *)ptr;
{
const int *mib;
const char *text;
- int i, v;
+ unsigned int i;
+ int v;
if (type == ST_NAME) {
mib = (const int *)ptr;
put_kern_cp_time(struct trace_proc * proc, const char * name __unused,
int type, const void * ptr, vir_bytes addr __unused, size_t size)
{
- uint64_t *p;
+ const uint64_t *p;
unsigned int i;
const int *mib;
return 0;
}
- p = (uint64_t *)ptr;
+ p = (const uint64_t *)ptr;
/* TODO: support for multi-CPU results */
for (i = 0; i < CPUSTATES; i++)
size_t size __unused)
{
- put_dev(proc, NULL, *(dev_t *)ptr);
+ put_dev(proc, NULL, *(const dev_t *)ptr);
return TRUE;
}
{
const int *mib;
const char *text;
- int i;
+ unsigned int i;
/*
* TODO: print the obtained structure(s). For now we are just
int type __unused, const void * ptr, vir_bytes addr __unused,
size_t size __unused)
{
- struct loadavg *loadavg;
+ const struct loadavg *loadavg;
unsigned int i;
- loadavg = (struct loadavg *)ptr;
+ loadavg = (const struct loadavg *)ptr;
put_open(proc, "ldavg", 0, "{", ", ");
static void
put_sysctl_imm(struct trace_proc * proc, struct sysctlnode * scn, int use_name)
{
- char *name;
+ const char *name;
name = NULL;
{
struct sysctlnode scn;
void *ptr;
- int i;
- bool b;
- u_quad_t q;
size_t len;
switch (SYSCTL_TYPE(proc->sctl_flags)) {
vir_bytes addr, unsigned int namelen)
{
const struct sysctl_tab *sct = NULL;
- const char *namestr;
int r, all, namebuf[CTL_MAXNAME];
unsigned int n;
static int
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_fcntl_cmd(proc, "cmd", m_out->m_lc_vfs_fcntl.cmd);
count = 0;
for (off = 0; off < size; off += chunk) {
chunk = size - off;
- if (chunk > sizeof(dirent))
- chunk = sizeof(dirent);
- if (chunk < _DIRENT_MINSIZE(&dirent))
+ if ((size_t)chunk > sizeof(dirent))
+ chunk = (ssize_t)sizeof(dirent);
+ if ((size_t)chunk < _DIRENT_MINSIZE(&dirent))
break;
if (mem_get_data(proc->pid, addr + off, &dirent, chunk) < 0) {
END {
printf("};\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\treturn signals[sig];\n");
printf("\telse\n");
-#define COUNT(s) (sizeof(s) / sizeof(s[0]))
+#define COUNT(s) (__arraycount(s))
struct call_handler {
const char *name;