]> granicus.if.org Git - strace/commitdiff
count.c: cleanup types and sizeof usage
authorEugene Syromyatnikov <evgsyr@gmail.com>
Fri, 5 Jan 2018 03:06:58 +0000 (04:06 +0100)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 7 Jan 2018 16:46:32 +0000 (16:46 +0000)
* count.c (call_summary_pers): Change the type of sorted_count
to "unsigned int *".  Replace sizeof(int) with  sizeof(sorted_count[0]).
Change the type of idx to unsigned int.

count.c

diff --git a/count.c b/count.c
index 7bcedf9606f16733304d94164509a290dbf02c62..a374bad024e7d703ac26824bc392059236081b39 100644 (file)
--- a/count.c
+++ b/count.c
@@ -164,14 +164,14 @@ call_summary_pers(FILE *outf)
        struct timeval tv_cum, dtv;
        double  float_tv_cum;
        double  percent;
-       int    *sorted_count;
+       unsigned int *sorted_count;
 
        fprintf(outf, header,
                "% time", "seconds", "usecs/call",
                "calls", "errors", "syscall");
        fprintf(outf, header, dashes, dashes, dashes, dashes, dashes, dashes);
 
-       sorted_count = xcalloc(sizeof(int), nsyscalls);
+       sorted_count = xcalloc(sizeof(sorted_count[0]), nsyscalls);
        call_cum = error_cum = tv_cum.tv_sec = tv_cum.tv_usec = 0;
        if (overhead.tv_sec == -1) {
                tv_mul(&overhead, &shortest, 8);
@@ -190,10 +190,11 @@ call_summary_pers(FILE *outf)
        float_tv_cum = tv_float(&tv_cum);
        if (counts) {
                if (sortfun)
-                       qsort((void *) sorted_count, nsyscalls, sizeof(int), sortfun);
+                       qsort((void *) sorted_count, nsyscalls,
+                             sizeof(sorted_count[0]), sortfun);
                for (i = 0; i < nsyscalls; i++) {
                        double float_syscall_time;
-                       int idx = sorted_count[i];
+                       unsigned int idx = sorted_count[i];
                        struct call_counts *cc = &counts[idx];
                        if (cc->calls == 0)
                                continue;