/* Per-syscall stats structure */
struct call_counts {
- /* system time spent in syscall (not wall clock time) */
+ /* time may be total latency or system time */
struct timeval time;
int calls, errors;
};
if (!SCNO_IN_RANGE(scno))
return;
- if (!counts) {
- counts = calloc(nsyscalls, sizeof(*counts));
- if (!counts)
- die_out_of_memory();
- }
+ if (!counts)
+ counts = xcalloc(nsyscalls, sizeof(*counts));
cc = &counts[scno];
cc->calls++;
}
if (tv_cmp(tv, &shortest) < 0)
shortest = *tv;
- tv_add(&cc->time, &cc->time, tv);
+ tv_add(&cc->time, &cc->time, count_wallclock ? &wtv : tv);
}
static int
static int
syscall_cmp(void *a, void *b)
{
- return strcmp(sysent[*((int *) a)].sys_name,
- sysent[*((int *) b)].sys_name);
+ const char *a_name = sysent[*((int *) a)].sys_name;
+ const char *b_name = sysent[*((int *) b)].sys_name;
+ return strcmp(a_name ? a_name : "", b_name ? b_name : "");
}
static int
else if (strcmp(sortby, "nothing") == 0)
sortfun = NULL;
else {
- error_msg_and_die("invalid sortby: '%s'", sortby);
+ error_msg_and_help("invalid sortby: '%s'", sortby);
}
}
static void
call_summary_pers(FILE *outf)
{
- int i;
+ unsigned int i;
int call_cum, error_cum;
struct timeval tv_cum, dtv;
double float_tv_cum;
fprintf(outf, "%6.6s %11.11s %11.11s %9.9s %9.9s %s\n",
dashes, dashes, dashes, dashes, dashes, dashes);
- sorted_count = calloc(sizeof(int), nsyscalls);
- if (!sorted_count)
- die_out_of_memory();
+ sorted_count = xcalloc(sizeof(int), nsyscalls);
call_cum = error_cum = tv_cum.tv_sec = tv_cum.tv_usec = 0;
if (overhead.tv_sec == -1) {
tv_mul(&overhead, &shortest, 8);
void
call_summary(FILE *outf)
{
- int i, old_pers = current_personality;
+ unsigned int i, old_pers = current_personality;
for (i = 0; i < SUPPORTED_PERSONALITIES; ++i) {
if (!countv[i])