]> granicus.if.org Git - strace/blobdiff - count.c
Update NEWS
[strace] / count.c
diff --git a/count.c b/count.c
index e41994d3715a9728c7cf1070da9b85d6caed2925..1393b6e4eddb019cab2da685dee07b0098b24b30 100644 (file)
--- a/count.c
+++ b/count.c
@@ -58,11 +58,8 @@ count_syscall(struct tcb *tcp, const struct timeval *syscall_exiting_tv)
        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++;
@@ -115,8 +112,9 @@ time_cmp(void *a, void *b)
 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
@@ -143,7 +141,7 @@ set_sortby(const char *sortby)
        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);
        }
 }
 
@@ -156,7 +154,7 @@ void set_overhead(int n)
 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;
@@ -171,9 +169,7 @@ call_summary_pers(FILE *outf)
        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);
@@ -230,7 +226,7 @@ call_summary_pers(FILE *outf)
 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])