summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorFlavio Cruz <flaviocruz@gmail.com>2015-12-29 23:15:01 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2015-12-29 23:24:59 +0100
commit5089d4a559eb3a0a0f008ad00ba8c5ed8bbc94c6 (patch)
tree5b5dd54ee2a2c0b96e59164d84e050160bc17b3b /utils
parentfd0f30ca23e685f56578bebd08b666be0287d59e (diff)
fix compiler warnings in hurd/utils
utils: Fix compiler warnings. * utils/rpcscan.c (setup_extract_target): Remove name variable. * utils/rpcscan.c (setup_extract_target): Fix bad initializer. * utils/rpctrace.c (new_send_wrapper, wrap_all_threads, wrap_new_thread, wrap_new_task, traced_spawn): Fix format strings. * utils/rpctrace.c (trace_and_forward): Cast to unsigned int. * utils/rpctrace.c (trace_and_forward): Use memcmp instead of pointer dereferencing to compare structures. * utils/rpctrace.c (wrap_all_threads): Cast to vm_address_t. * utils/rpctrace.c (main): Fix bad initializer. * utils/shd.c (run): Initialize save0. * utils/vminfo.c: Fix format strings. * utils/vmstat.c: Remove PSEP macro and expand the code. * utils/w.c (add_utmp_procs): Remove unused pos variable.
Diffstat (limited to 'utils')
-rw-r--r--utils/rpcscan.c3
-rw-r--r--utils/rpctrace.c23
-rw-r--r--utils/shd.c3
-rw-r--r--utils/vminfo.c22
-rw-r--r--utils/vmstat.c22
-rw-r--r--utils/w.c3
6 files changed, 42 insertions, 34 deletions
diff --git a/utils/rpcscan.c b/utils/rpcscan.c
index 2270ea8a..3ddf791a 100644
--- a/utils/rpcscan.c
+++ b/utils/rpcscan.c
@@ -201,7 +201,6 @@ error_t
setup_extract_target (void)
{
error_t err;
- char *name = (char *) setup_argument;
mach_port_t request;
mach_msg_type_name_t requestType;
@@ -337,7 +336,7 @@ const struct argp_child children[] =
{ 0 }
};
-const struct argp argp = { options, parse_opt, args_doc, doc, &children };
+const struct argp argp = { options, parse_opt, args_doc, doc, children };
void
format_msgid (char *buf, size_t len, mach_msg_id_t id)
diff --git a/utils/rpctrace.c b/utils/rpctrace.c
index d53b510f..276377c0 100644
--- a/utils/rpctrace.c
+++ b/utils/rpctrace.c
@@ -353,7 +353,7 @@ new_send_wrapper (struct receiver_info *receive, task_t task,
assert_perror (err);
TRACED_INFO (info)->name = 0;
- asprintf (&TRACED_INFO (info)->name, " %d<--%d(pid%d)",
+ asprintf (&TRACED_INFO (info)->name, " %lu<--%lu(pid%d)",
receive->forward, TRACED_INFO (info)->pi.port_right, task2pid (task));
TRACED_INFO (info)->type = MACH_MSG_TYPE_MOVE_SEND;
info->task = task;
@@ -979,7 +979,7 @@ wrap_all_threads (task_t task)
task, &new_thread_port);
free (TRACED_INFO (thread_send_wrapper)->name);
asprintf (&TRACED_INFO (thread_send_wrapper)->name,
- "thread%d(pid%d)", threads[i], task2pid (task));
+ "thread%lu(pid%d)", threads[i], task2pid (task));
err = mach_port_insert_right (mach_task_self (),
new_thread_port, new_thread_port,
@@ -994,7 +994,8 @@ wrap_all_threads (task_t task)
mach_port_deallocate (mach_task_self (), new_thread_port);
}
}
- vm_deallocate (mach_task_self (), threads, nthreads * sizeof (thread_t));
+ vm_deallocate (mach_task_self (), (vm_address_t) threads,
+ nthreads * sizeof (thread_t));
}
/* Wrap the new thread port that is in the message. */
@@ -1030,7 +1031,7 @@ wrap_new_thread (mach_msg_header_t *inp, struct req_info *req)
mach_port_deallocate (mach_task_self (), reply->child_thread);
free (TRACED_INFO (send_wrapper)->name);
- asprintf (&TRACED_INFO (send_wrapper)->name, "thread%d(pid%d)",
+ asprintf (&TRACED_INFO (send_wrapper)->name, "thread%lu(pid%d)",
thread_port, task2pid (req->from));
ports_port_deref (send_wrapper);
}
@@ -1077,10 +1078,10 @@ wrap_new_task (mach_msg_header_t *inp, struct req_info *req)
pid = task2pid (task_port);
free (TRACED_INFO (task_wrapper1)->name);
- asprintf (&TRACED_INFO (task_wrapper1)->name, "task%d(pid%d)",
+ asprintf (&TRACED_INFO (task_wrapper1)->name, "task%lu(pid%d)",
task_port, task2pid (req->from));
free (TRACED_INFO (task_wrapper2)->name);
- asprintf (&TRACED_INFO (task_wrapper2)->name, "task%d(pid%d)",
+ asprintf (&TRACED_INFO (task_wrapper2)->name, "task%lu(pid%d)",
task_port, pid);
ports_port_deref (task_wrapper1);
}
@@ -1131,7 +1132,7 @@ trace_and_forward (mach_msg_header_t *inp, mach_msg_header_t *outp)
MACH_MSGH_BITS_REMOTE (inp->msgh_bits),
is_notification (inp)? MACH_MSG_TYPE_MOVE_SEND_ONCE: info->type)
| MACH_MSGH_BITS_OTHER (inp->msgh_bits);
- inp->msgh_local_port = ports_payload_get_name (info);
+ inp->msgh_local_port = ports_payload_get_name ((unsigned int) info);
}
}
else
@@ -1276,8 +1277,8 @@ trace_and_forward (mach_msg_header_t *inp, mach_msg_header_t *outp)
&& inp->msgh_size >= sizeof (mig_reply_header_t)
/* The notification message is considered as a request. */
&& (inp->msgh_id > 72 || inp->msgh_id < 64)
- && (*(int *) &((mig_reply_header_t *) inp)->RetCodeType
- == *(int *)&RetCodeType))
+ && !memcmp(&((mig_reply_header_t *) inp)->RetCodeType,
+ &RetCodeType, sizeof (RetCodeType)))
{
struct req_info *req = remove_request (inp->msgh_id - 100,
inp->msgh_remote_port);
@@ -1645,7 +1646,7 @@ traced_spawn (char **argv, char **envp)
ti = new_send_wrapper (receive_ti, traced_task, &task_wrapper);
ti->task = traced_task;
free (TRACED_INFO (ti)->name);
- asprintf (&TRACED_INFO (ti)->name, "task%d(pid%d)", traced_task, pid);
+ asprintf (&TRACED_INFO (ti)->name, "task%lu(pid%d)", traced_task, pid);
/* Replace the task's kernel port with the wrapper. When this task calls
`mach_task_self ()', it will get our wrapper send right instead of its
@@ -1741,7 +1742,7 @@ main (int argc, char **argv, char **envp)
{ .argp=&msgid_argp, },
{ 0 }
};
- const struct argp argp = { options, parse_opt, args_doc, doc, &children };
+ const struct argp argp = { options, parse_opt, args_doc, doc, children };
/* Parse our arguments. */
argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, 0);
diff --git a/utils/shd.c b/utils/shd.c
index a1a4b26b..feff6135 100644
--- a/utils/shd.c
+++ b/utils/shd.c
@@ -106,7 +106,8 @@ run (char **argv, int fd0, int fd1)
}
else
{
- int save0, save1;
+ int save0 = -1;
+ int save1;
inline int movefd (int from, int to, int *save)
{
diff --git a/utils/vminfo.c b/utils/vminfo.c
index 6ead677e..2718591d 100644
--- a/utils/vminfo.c
+++ b/utils/vminfo.c
@@ -182,29 +182,29 @@ main (int argc, char **argv)
if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES))
{
if (hex)
- printf (" [%#zx] (hole)\n", addr - hole_addr);
+ printf (" [%#lx] (hole)\n", addr - hole_addr);
else
- printf (" [%zd] (hole)\n", addr - hole_addr);
+ printf (" [%lu] (hole)\n", addr - hole_addr);
}
else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES)
{
if (hex)
- printf ("%#10zx (hole)\n", addr - hole_addr);
+ printf ("%#10lx (hole)\n", addr - hole_addr);
else
- printf ("%10zu (hole)\n", addr - hole_addr);
+ printf ("%10lu (hole)\n", addr - hole_addr);
}
}
if ((what & (W_ADDRS|W_SIZES)) == (W_ADDRS|W_SIZES))
if (hex)
- printf ("%#10zx[%#zx]", addr, size);
+ printf ("%#10lx[%#zx]", addr, size);
else
- printf ("%10zu[%zd]", addr, size);
+ printf ("%10lu[%zd]", addr, size);
else if ((what & (W_ADDRS|W_SIZES)) == W_ADDRS)
if (hex)
- printf ("%#10zx", addr);
+ printf ("%#10lx", addr);
else
- printf ("%10zu", addr);
+ printf ("%10lu", addr);
else if ((what & (W_ADDRS|W_SIZES)) == W_SIZES)
{
if (hex)
@@ -222,13 +222,13 @@ main (int argc, char **argv)
if (shared)
printf (", shared");
if (obj != MACH_PORT_NULL)
- printf (", mem_obj=%d", obj);
+ printf (", mem_obj=%lu", obj);
if (offs != 0)
{
if (hex)
- printf (", offs=%#zx", offs);
+ printf (", offs=%#lx", offs);
else
- printf (", offs=%zd", offs);
+ printf (", offs=%lu", offs);
}
putchar (')');
}
diff --git a/utils/vmstat.c b/utils/vmstat.c
index 92a36726..bdd1d812 100644
--- a/utils/vmstat.c
+++ b/utils/vmstat.c
@@ -477,10 +477,6 @@ main (int argc, char **argv)
? size_units \
: ((field)->type == PAGESZ ? 0 : state.vmstats.pagesize))
- /* Prints SEP if the variable FIRST is 0, otherwise, prints START (if
- it's non-zero), and sets first to 0. */
-#define PSEP(sep, start) \
- (first ? (first = 0, (start && fputs (start, stdout))) : fputs (sep, stdout))
#define PVAL(val, field, width, sign) \
print_val (val, (field)->type, SIZE_UNITS (field), width, sign)
/* Intuit the likely maximum field width of FIELD. */
@@ -539,7 +535,13 @@ main (int argc, char **argv)
const_fields &= ~(1 << (field - fields));
else
{
- PSEP (", ", "(");
+ if (first)
+ {
+ first = 0;
+ fputs("(", stdout);
+ }
+ else
+ fputs(",", stdout);
printf ("%s: ", field->name);
PVAL (val, field, 0, 0);
}
@@ -570,7 +572,10 @@ main (int argc, char **argv)
for (field = fields, num = 0, first = 1; field->name; field++, num++)
if (output_fields & (1 << (field - fields)))
{
- PSEP (" ", 0);
+ if (first)
+ first = 0;
+ else
+ fputs (" ", stdout);
fprintf (stdout, "%*s", fwidths[num], field->hdr);
}
putchar ('\n');
@@ -601,7 +606,10 @@ main (int argc, char **argv)
val -= vm_state_get_field (&prev_state, field);
}
- PSEP (" ", 0);
+ if (first)
+ first = 0;
+ else
+ fputs (" ", stdout);
PVAL (val, field, fwidths[num], sign);
}
}
diff --git a/utils/w.c b/utils/w.c
index 37555088..ac5e36f8 100644
--- a/utils/w.c
+++ b/utils/w.c
@@ -258,7 +258,6 @@ add_utmp_procs (struct proc_stat_list *procs, struct utmp *u)
io_t tty_node;
error_t err;
pid_t pid;
- int pos;
struct proc_stat *ps;
switch (u->ut_type)
@@ -300,7 +299,7 @@ add_utmp_procs (struct proc_stat_list *procs, struct utmp *u)
}
/* The new process will get added at the end, so look for it there. */
- pos = proc_stat_list_num_procs (procs);
+ (void) proc_stat_list_num_procs (procs);
if (pid >= 0)
err = proc_stat_list_add_pid (procs, pid, &ps);
else