diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/systat/cache.c | 4 | ||||
-rw-r--r-- | usr.bin/systat/engine.c | 73 | ||||
-rw-r--r-- | usr.bin/systat/engine.h | 26 | ||||
-rw-r--r-- | usr.bin/systat/iostat.c | 6 | ||||
-rw-r--r-- | usr.bin/systat/netstat.c | 14 | ||||
-rw-r--r-- | usr.bin/systat/pigs.c | 18 | ||||
-rw-r--r-- | usr.bin/systat/sensors.c | 4 | ||||
-rw-r--r-- | usr.bin/systat/swap.c | 24 | ||||
-rw-r--r-- | usr.bin/systat/vmstat.c | 56 |
9 files changed, 111 insertions, 114 deletions
diff --git a/usr.bin/systat/cache.c b/usr.bin/systat/cache.c index 38c931920af..f199919df75 100644 --- a/usr.bin/systat/cache.c +++ b/usr.bin/systat/cache.c @@ -1,4 +1,4 @@ -/* $Id: cache.c,v 1.2 2008/07/16 10:23:39 canacar Exp $ */ +/* $Id: cache.c,v 1.3 2008/12/07 02:56:06 canacar Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org> * @@ -45,7 +45,7 @@ static __inline int sc_cmp(struct sc_ent *s1, struct sc_ent *s2); /* initialize the tree and queue */ RB_HEAD(sc_tree, sc_ent) sctree; TAILQ_HEAD(sc_queue, sc_ent) scq1, scq2, scq_free; -RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp); +RB_GENERATE(sc_tree, sc_ent, tlink, sc_cmp) struct sc_queue *scq_act = NULL; struct sc_queue *scq_exp = NULL; diff --git a/usr.bin/systat/engine.c b/usr.bin/systat/engine.c index 79c0c7c6a99..57a82876fbe 100644 --- a/usr.bin/systat/engine.c +++ b/usr.bin/systat/engine.c @@ -1,4 +1,4 @@ -/* $Id: engine.c,v 1.6 2008/12/01 18:03:06 naddy Exp $ */ +/* $Id: engine.c,v 1.7 2008/12/07 02:56:06 canacar Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org> * @@ -203,7 +203,7 @@ rawaddstr(char *s) void print_fld_str(field_def *fld, const char *str) { - int len, move; + int len, offset; char *cpos; if (str == NULL || fld == NULL) @@ -227,15 +227,15 @@ print_fld_str(field_def *fld, const char *str) break; case FLD_ALIGN_COLUMN: if ((cpos = strchr(str, ':')) == NULL) { - move = (fld->width - len) / 2; + offset = (fld->width - len) / 2; } else { - move = (fld->width / 2) - (cpos - str); - if (move < 0) - move = 0; - else if (move > (fld->width - len)) - move = fld->width - len; + offset = (fld->width / 2) - (cpos - str); + if (offset < 0) + offset = 0; + else if (offset > (fld->width - len)) + offset = fld->width - len; } - move_horiz(fld->start + move); + move_horiz(fld->start + offset); break; default: move_horiz(fld->start); @@ -249,7 +249,7 @@ void print_bar_title(field_def *fld) { char buf[16]; - int len, div, i, tr, tw, val, pos, cur; + int len, i, d, tr, tw, val, pos, cur; int divs[] = {20, 10, 5, 4, 3, 2, 1, 0}; @@ -269,26 +269,26 @@ print_bar_title(field_def *fld) return; } - div = divs[i]; + d = divs[i]; val = 0; pos = 0; - tr = fld->arg % div; - tw = fld->width % div; + tr = fld->arg % d; + tw = fld->width % d; tb_start(); cur = 0; - for(i = 0; i < div; i++) { + for(i = 0; i < d; i++) { tw += fld->width; tr += fld->arg; - while (tr >= div) { + while (tr >= d) { val++; - tr -= div; + tr -= d; } - while (tw >= div) { + while (tw >= d) { pos++; - tw -= div; + tw -= d; } len = snprintf(buf, sizeof(buf), "%d\\", val); @@ -658,7 +658,7 @@ print_fld_age(field_def *fld, unsigned int age) } void -print_fld_sdiv(field_def *fld, u_int64_t size, int div) +print_fld_sdiv(field_def *fld, u_int64_t size, int d) { int len; @@ -674,28 +674,28 @@ print_fld_sdiv(field_def *fld, u_int64_t size, int div) goto ok; tb_start(); - size /= div; + size /= d; if (tbprintf("%lluK", size) <= len) goto ok; if (size == 0) goto err; tb_start(); - size /= div; + size /= d; if (tbprintf("%lluM", size) <= len) goto ok; if (size == 0) goto err; tb_start(); - size /= div; + size /= d; if (tbprintf("%lluG", size) <= len) goto ok; if (size == 0) goto err; tb_start(); - size /= div; + size /= d; if (tbprintf("%lluT", size) <= len) goto ok; @@ -715,7 +715,7 @@ print_fld_size(field_def *fld, u_int64_t size) } void -print_fld_ssdiv(field_def *fld, int64_t size, int div) +print_fld_ssdiv(field_def *fld, int64_t size, int d) { int len; @@ -731,28 +731,28 @@ print_fld_ssdiv(field_def *fld, int64_t size, int div) goto ok; tb_start(); - size /= div; + size /= d; if (tbprintf("%lldK", size) <= len) goto ok; if (size == 0) goto err; tb_start(); - size /= div; + size /= d; if (tbprintf("%lldM", size) <= len) goto ok; if (size == 0) goto err; tb_start(); - size /= div; + size /= d; if (tbprintf("%lldG", size) <= len) goto ok; if (size == 0) goto err; tb_start(); - size /= div; + size /= d; if (tbprintf("%lldT", size) <= len) goto ok; @@ -933,7 +933,7 @@ read_view(void) int disp_update(void) { - int lines; + int li; if (maxprint < 0) dispstart = 0; @@ -950,12 +950,11 @@ disp_update(void) curr_line = 0; if (curr_mgr->header_fn != NULL) { - lines = curr_mgr->header_fn(); - if (lines < 0) + li = curr_mgr->header_fn(); + if (li < 0) return (1); -// home_line = lines++; - curr_line = ++lines; - home_line = lines + maxprint + 1; + curr_line = ++li; + home_line = li + maxprint + 1; } print_title(); @@ -976,19 +975,19 @@ sort_view(void) } void -sig_close(int signal) +sig_close(int sig) { gotsig_close = 1; } void -sig_resize(int signal) +sig_resize(int sig) { gotsig_resize = 1; } void -sig_alarm(int signal) +sig_alarm(int sig) { gotsig_alarm = 1; } diff --git a/usr.bin/systat/engine.h b/usr.bin/systat/engine.h index 8aef3485ff3..d34eb1d48e0 100644 --- a/usr.bin/systat/engine.h +++ b/usr.bin/systat/engine.h @@ -1,4 +1,4 @@ -/* $Id: engine.h,v 1.4 2008/12/01 18:03:06 naddy Exp $ */ +/* $Id: engine.h,v 1.5 2008/12/07 02:56:06 canacar Exp $ */ /* * Copyright (c) 2001, 2007 Can Erkin Acar <canacar@openbsd.org> * @@ -105,18 +105,18 @@ int tbprintf(char *format, ...) GCC_PRINTFLIKE(1,2); void end_line(void); void end_page(void); -void print_fld_str(field_def *fld, const char *str); -void print_fld_age(field_def *fld, unsigned int age); -void print_fld_sdiv(field_def *fld, u_int64_t size, int div); -void print_fld_size(field_def *fld, u_int64_t size); -void print_fld_ssdiv(field_def *fld, int64_t size, int div); -void print_fld_ssize(field_def *fld, int64_t size); -void print_fld_bw(field_def *fld, double bw); -void print_fld_rate(field_def *fld, double rate); -void print_fld_uint(field_def *fld, unsigned int size); -void print_fld_float(field_def *fld, double f, int prec); -void print_fld_bar(field_def *fld, int value); -void print_fld_tb(field_def *fld); +void print_fld_str(field_def *, const char *); +void print_fld_age(field_def *, unsigned int); +void print_fld_sdiv(field_def *, u_int64_t, int); +void print_fld_size(field_def *, u_int64_t); +void print_fld_ssdiv(field_def *, int64_t, int); +void print_fld_ssize(field_def *, int64_t); +void print_fld_bw(field_def *, double); +void print_fld_rate(field_def *, double); +void print_fld_uint(field_def *, unsigned int); +void print_fld_float(field_def *, double, int); +void print_fld_bar(field_def *, int); +void print_fld_tb(field_def *); void print_title(void); diff --git a/usr.bin/systat/iostat.c b/usr.bin/systat/iostat.c index 8d779b88fcf..00126b0bbf2 100644 --- a/usr.bin/systat/iostat.c +++ b/usr.bin/systat/iostat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iostat.c,v 1.34 2008/12/01 18:03:06 naddy Exp $ */ +/* $OpenBSD: iostat.c,v 1.35 2008/12/07 02:56:06 canacar Exp $ */ /* $NetBSD: iostat.c,v 1.5 1996/05/10 23:16:35 thorpej Exp $ */ /* @@ -141,7 +141,7 @@ print_io(void) { int n, count = 0; - int i, curr; + int curr; etime = naptime; /* XXX engine internals: save and restore curr_line for bcache */ @@ -227,8 +227,6 @@ showdrive(int dn) void showbcache(void) { - int count = 0; - print_fld_str(FLD_IO_SSTR, "numbufs"); print_fld_ssize(FLD_IO_SVAL, bccur.numbufs); end_line(); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index 62052910532..06a41e35e35 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.c,v 1.31 2008/06/12 22:26:01 canacar Exp $ */ +/* $OpenBSD: netstat.c,v 1.32 2008/12/07 02:56:06 canacar Exp $ */ /* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */ /*- @@ -450,19 +450,19 @@ static const char * inetname(struct in_addr in) { static char line[NI_MAXHOST]; - struct sockaddr_in sin; + struct sockaddr_in si; int flags, e; flags = nflag ? NI_NUMERICHOST : 0; if (in.s_addr == INADDR_ANY) return "*"; - memset(&sin, 0, sizeof(sin)); - sin.sin_family = AF_INET; - sin.sin_len = sizeof(struct sockaddr_in); - sin.sin_addr = in; + memset(&si, 0, sizeof(si)); + si.sin_family = AF_INET; + si.sin_len = sizeof(struct sockaddr_in); + si.sin_addr = in; - e = getnameinfo((struct sockaddr *)&sin, sin.sin_len, + e = getnameinfo((struct sockaddr *)&si, si.sin_len, line, sizeof(line), NULL, 0, flags); if (e == 0) diff --git a/usr.bin/systat/pigs.c b/usr.bin/systat/pigs.c index 0d57af6a476..0685528c96b 100644 --- a/usr.bin/systat/pigs.c +++ b/usr.bin/systat/pigs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pigs.c,v 1.22 2008/06/12 22:26:01 canacar Exp $ */ +/* $OpenBSD: pigs.c,v 1.23 2008/12/07 02:56:06 canacar Exp $ */ /* $NetBSD: pigs.c,v 1.3 1995/04/29 05:54:50 cgd Exp $ */ /*- @@ -155,7 +155,7 @@ int read_pg(void) { static int cp_time_mib[] = { CTL_KERN, KERN_CPTIME }; - long ctime[CPUSTATES]; + long ctimes[CPUSTATES]; double t; int i, k; size_t size; @@ -186,25 +186,25 @@ read_pg(void) /* * and for the imaginary "idle" process */ - size = sizeof(ctime); - sysctl(cp_time_mib, 2, &ctime, &size, NULL, 0); + size = sizeof(ctimes); + sysctl(cp_time_mib, 2, &ctimes, &size, NULL, 0); t = 0; for (i = 0; i < CPUSTATES; i++) - t += ctime[i] - stime[i]; + t += ctimes[i] - stime[i]; if (t == 0.0) t = 1.0; - procbase[nproc].p_pctcpu = (ctime[CP_IDLE] - stime[CP_IDLE]) / t / pctdouble(1); + procbase[nproc].p_pctcpu = (ctimes[CP_IDLE] - stime[CP_IDLE]) / t / pctdouble(1); for (i = 0; i < CPUSTATES; i++) - stime[i] = ctime[i]; + stime[i] = ctimes[i]; qsort(pb_indices, nproc + 1, sizeof (int), compar); pigs_cnt = 0; for (k = 0; k < nproc + 1; k++) { - int i = pb_indices[k]; - if (pctdouble(procbase[i].p_pctcpu) < 0.01) + int j = pb_indices[k]; + if (pctdouble(procbase[j].p_pctcpu) < 0.01) break; pigs_cnt++; } diff --git a/usr.bin/systat/sensors.c b/usr.bin/systat/sensors.c index 65c0c28f3d4..d12c0dbd644 100644 --- a/usr.bin/systat/sensors.c +++ b/usr.bin/systat/sensors.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sensors.c,v 1.13 2008/06/12 22:26:01 canacar Exp $ */ +/* $OpenBSD: sensors.c,v 1.14 2008/12/07 02:56:06 canacar Exp $ */ /* * Copyright (c) 2007 Deanna Phillips <deanna@openbsd.org> @@ -333,7 +333,7 @@ fmttime(double in) } snprintf(outbuf, LEN, - tiny ? "%s%lf %s" : "%s%.3lf %s", + tiny ? "%s%f %s" : "%s%.3f %s", signbit == -1 ? "-" : "", in, unit); return outbuf; diff --git a/usr.bin/systat/swap.c b/usr.bin/systat/swap.c index 1d8fb80c481..8d5de7f7e47 100644 --- a/usr.bin/systat/swap.c +++ b/usr.bin/systat/swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: swap.c,v 1.21 2008/06/12 22:26:01 canacar Exp $ */ +/* $OpenBSD: swap.c,v 1.22 2008/12/07 02:56:06 canacar Exp $ */ /* $NetBSD: swap.c,v 1.9 1998/12/26 07:05:08 marc Exp $ */ /*- @@ -176,11 +176,11 @@ initswap(void) static void showswap(int i) { - int div, used, xsize; + int d, used, xsize; struct swapent *sep; char *p; - div = blocksize / 512; + d = blocksize / 512; sep = &swap_devices[i]; @@ -192,8 +192,8 @@ showswap(int i) xsize = sep->se_nblks; used = sep->se_inuse; - print_fld_uint(FLD_SW_BLOCKS, xsize / div); - print_fld_uint(FLD_SW_USED, used / div); + print_fld_uint(FLD_SW_BLOCKS, xsize / d); + print_fld_uint(FLD_SW_USED, used / d); print_fld_bar(FLD_SW_BAR, 100 * used / xsize); end_line(); @@ -203,22 +203,22 @@ static void showtotal(void) { struct swapent *sep; - int div, i, avail, used, xsize, free; + int d, i, avail, used, xsize, mfree; - div = blocksize / 512; - free = avail = 0; + d = blocksize / 512; + mfree = avail = 0; for (sep = swap_devices, i = 0; i < nswap; i++, sep++) { xsize = sep->se_nblks; used = sep->se_inuse; avail += xsize; - free += xsize - used; + mfree += xsize - used; } - used = avail - free; + used = avail - mfree; print_fld_str(FLD_SW_NAME, "Total"); - print_fld_uint(FLD_SW_BLOCKS, avail / div); - print_fld_uint(FLD_SW_USED, used / div); + print_fld_uint(FLD_SW_BLOCKS, avail / d); + print_fld_uint(FLD_SW_USED, used / d); print_fld_bar(FLD_SW_BAR, 100 * used / avail); end_line(); diff --git a/usr.bin/systat/vmstat.c b/usr.bin/systat/vmstat.c index cac7dc5118c..afb4fe80c56 100644 --- a/usr.bin/systat/vmstat.c +++ b/usr.bin/systat/vmstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmstat.c,v 1.66 2008/11/01 00:56:25 canacar Exp $ */ +/* $OpenBSD: vmstat.c,v 1.67 2008/12/07 02:56:06 canacar Exp $ */ /* $NetBSD: vmstat.c,v 1.5 1996/05/10 23:16:40 thorpej Exp $ */ /*- @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)vmstat.c 8.2 (Berkeley) 1/12/94"; #endif -static char rcsid[] = "$OpenBSD: vmstat.c,v 1.66 2008/11/01 00:56:25 canacar Exp $"; +static char rcsid[] = "$OpenBSD: vmstat.c,v 1.67 2008/12/07 02:56:06 canacar Exp $"; #endif /* not lint */ /* @@ -493,15 +493,15 @@ vm_keyboard_callback(int ch) static float cputime(int indx) { - double t; + double tm; int i; - t = 0; + tm = 0; for (i = 0; i < CPUSTATES; i++) - t += s.time[i]; - if (t == 0.0) - t = 1.0; - return (s.time[indx] * 100.0 / t); + tm += s.time[i]; + if (tm == 0.0) + tm = 1.0; + return (s.time[indx] * 100.0 / tm); } void @@ -565,7 +565,7 @@ putfloat(double f, int l, int c, int w, int d, int nz) } static void -getinfo(struct Info *s) +getinfo(struct Info *si) { static int cp_time_mib[] = { CTL_KERN, KERN_CPTIME }; static int nchstats_mib[2] = { CTL_KERN, KERN_NCHSTATS }; @@ -581,43 +581,43 @@ getinfo(struct Info *s) mib[1] = KERN_INTRCNT; mib[2] = KERN_INTRCNT_CNT; mib[3] = i; - size = sizeof(s->intrcnt[i]); - if (sysctl(mib, 4, &s->intrcnt[i], &size, NULL, 0) < 0) { - s->intrcnt[i] = 0; + size = sizeof(si->intrcnt[i]); + if (sysctl(mib, 4, &si->intrcnt[i], &size, NULL, 0) < 0) { + si->intrcnt[i] = 0; } } - size = sizeof(s->time); - if (sysctl(cp_time_mib, 2, &s->time, &size, NULL, 0) < 0) { + size = sizeof(si->time); + if (sysctl(cp_time_mib, 2, &si->time, &size, NULL, 0) < 0) { error("Can't get KERN_CPTIME: %s\n", strerror(errno)); - bzero(&s->time, sizeof(s->time)); + bzero(&si->time, sizeof(si->time)); } - size = sizeof(s->nchstats); - if (sysctl(nchstats_mib, 2, &s->nchstats, &size, NULL, 0) < 0) { + size = sizeof(si->nchstats); + if (sysctl(nchstats_mib, 2, &si->nchstats, &size, NULL, 0) < 0) { error("Can't get KERN_NCHSTATS: %s\n", strerror(errno)); - bzero(&s->nchstats, sizeof(s->nchstats)); + bzero(&si->nchstats, sizeof(si->nchstats)); } - size = sizeof(s->uvmexp); - if (sysctl(uvmexp_mib, 2, &s->uvmexp, &size, NULL, 0) < 0) { + size = sizeof(si->uvmexp); + if (sysctl(uvmexp_mib, 2, &si->uvmexp, &size, NULL, 0) < 0) { error("Can't get VM_UVMEXP: %s\n", strerror(errno)); - bzero(&s->uvmexp, sizeof(s->uvmexp)); + bzero(&si->uvmexp, sizeof(si->uvmexp)); } - size = sizeof(s->Total); - if (sysctl(vmtotal_mib, 2, &s->Total, &size, NULL, 0) < 0) { + size = sizeof(si->Total); + if (sysctl(vmtotal_mib, 2, &si->Total, &size, NULL, 0) < 0) { error("Can't get VM_METER: %s\n", strerror(errno)); - bzero(&s->Total, sizeof(s->Total)); + bzero(&si->Total, sizeof(si->Total)); } } static void -allocinfo(struct Info *s) +allocinfo(struct Info *si) { - memset(s, 0, sizeof(*s)); - s->intrcnt = (u_quad_t *) calloc(nintr, sizeof(u_quad_t)); - if (s->intrcnt == NULL) + memset(si, 0, sizeof(*si)); + si->intrcnt = (u_quad_t *) calloc(nintr, sizeof(u_quad_t)); + if (si->intrcnt == NULL) errx(2, "out of memory"); } |