diff options
author | Eitan Adler <eadler@FreeBSD.org> | 2018-06-08 01:55:47 +0000 |
---|---|---|
committer | Eitan Adler <eadler@FreeBSD.org> | 2018-06-08 01:55:47 +0000 |
commit | d408c8f74274995869872c24411f61f1c9d0fdcc (patch) | |
tree | 5007a756138756d5599d28fde03e50e05d738a81 /usr.bin/top/display.c | |
parent | bd60b9b4993e823fc857f03f7f11c9ad1204ba2e (diff) | |
download | src-test2-d408c8f74274995869872c24411f61f1c9d0fdcc.tar.gz src-test2-d408c8f74274995869872c24411f61f1c9d0fdcc.zip |
top(1): fix several style & const related issues
- use parens for return
- put function names on newline
- sprinkle const where possible
Notes
Notes:
svn path=/head/; revision=334822
Diffstat (limited to 'usr.bin/top/display.c')
-rw-r--r-- | usr.bin/top/display.c | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/usr.bin/top/display.c b/usr.bin/top/display.c index 76b596693792..490844f996f5 100644 --- a/usr.bin/top/display.c +++ b/usr.bin/top/display.c @@ -464,8 +464,8 @@ void u_cpustates(int *states) { int value; - char **names; - char *thisname; + const char * const *names; + const char *thisname; int *lp; int *colp; int cpu; @@ -514,40 +514,34 @@ void z_cpustates(void) { int i = 0; - char **names; + const char **names; char *thisname; - int *lp; int cpu, value; -for (cpu = 0; cpu < num_cpus; cpu++) { - names = cpustate_names; + for (cpu = 0; cpu < num_cpus; cpu++) { + names = cpustate_names; - /* show tag and bump lastline */ - if (num_cpus == 1) - printf("\nCPU: "); - else { - value = printf("\nCPU %d: ", cpu); - while (value++ <= cpustates_column) - printf(" "); - } - lastline++; + /* show tag and bump lastline */ + if (num_cpus == 1) + printf("\nCPU: "); + else { + value = printf("\nCPU %d: ", cpu); + while (value++ <= cpustates_column) + printf(" "); + } + lastline++; - while ((thisname = *names++) != NULL) - { - if (*thisname != '\0') - { - printf("%s %% %s", (i++ % num_cpustates) == 0 ? "" : ", ", thisname); - } + while ((thisname = *names++) != NULL) + { + if (*thisname != '\0') + { + printf("%s %% %s", (i++ % num_cpustates) == 0 ? "" : ", ", thisname); + } + } } -} /* fill the "last" array with all -1s, to insure correct updating */ - lp = lcpustates; - i = num_cpustates * num_cpus; - while (--i >= 0) - { - *lp++ = -1; - } + memset(lcpustates, -1, num_cpustates * num_cpus); } /* |