PERFORCE change 140880 for review
Sam Leffler
sam at FreeBSD.org
Tue Apr 29 19:23:33 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=140880
Change 140880 by sam at sam_ebb on 2008/04/29 19:23:27
there are now >127 stat entries so need to introduce an indirect
array of indices since the compiled format is encoded in an uint8_t
as ix | 0x80
Affected files ...
.. //depot/projects/vap/tools/tools/net80211/wlanstats/statfoo.c#4 edit
.. //depot/projects/vap/tools/tools/net80211/wlanstats/statfoo.h#4 edit
Differences ...
==== //depot/projects/vap/tools/tools/net80211/wlanstats/statfoo.c#4 (text+ko) ====
@@ -40,9 +40,9 @@
#define N(a) (sizeof(a)/sizeof(a[0]))
char fmt[4096];
char *fp, *tok;
- int i, j;
+ int i, j, field;
- j = 0;
+ j = field = 0;
strlcpy(fmt, fmt0, sizeof(fmt));
for (fp = fmt; (tok = strsep(&fp, ", ")) != NULL;) {
for (i = 0; i < sf->nstats; i++)
@@ -58,9 +58,15 @@
"stopped at %s\n", sf->name, tok);
break;
}
+ if (field > 127) {
+ fprintf(stderr, "%s: too many fields; "
+ "stopped at %s\n", sf->name, tok);
+ break;
+ }
if (j != 0)
sf->fmts[j++] = ' ';
- sf->fmts[j++] = 0x80 | i;
+ sf->fmts[j++] = 0x80 | field;
+ sf->fields[field++] = i;
}
sf->fmts[j] = '\0';
#undef N
@@ -92,7 +98,8 @@
for (cp = sf->fmts; *cp != '\0'; cp++) {
if (*cp & 0x80) {
- const struct fmt *f = &sf->stats[*cp &~ 0x80];
+ int six = sf->fields[*cp &~ 0x80];
+ const struct fmt *f = &sf->stats[six];
fprintf(fd, "%*s", f->width, f->label);
} else
putc(*cp, fd);
@@ -108,8 +115,9 @@
for (cp = sf->fmts; *cp != '\0'; cp++) {
if (*cp & 0x80) {
- const struct fmt *f = &sf->stats[*cp &~ 0x80];
- if (sf->get_curstat(sf, *cp &~ 0x80, buf, sizeof(buf)))
+ int six = sf->fields[*cp &~ 0x80];
+ const struct fmt *f = &sf->stats[six];
+ if (sf->get_curstat(sf, six, buf, sizeof(buf)))
fprintf(fd, "%*s", f->width, buf);
} else
putc(*cp, fd);
@@ -125,8 +133,9 @@
for (cp = sf->fmts; *cp != '\0'; cp++) {
if (*cp & 0x80) {
- const struct fmt *f = &sf->stats[*cp &~ 0x80];
- if (sf->get_totstat(sf, *cp &~ 0x80, buf, sizeof(buf)))
+ int six = sf->fields[*cp &~ 0x80];
+ const struct fmt *f = &sf->stats[six];
+ if (sf->get_totstat(sf, six, buf, sizeof(buf)))
fprintf(fd, "%*s", f->width, buf);
} else
putc(*cp, fd);
==== //depot/projects/vap/tools/tools/net80211/wlanstats/statfoo.h#4 (text+ko) ====
@@ -79,6 +79,7 @@
const char *name; /* statistics name, e.g. wlanstats */
const struct fmt *stats; /* statistics in class */
int nstats; /* number of stats */
+ int fields[128]; /* index of field referenced in fmts */
unsigned char fmts[4096]; /* private: compiled stats to display */
STATFOO_DECL_METHODS(struct statfoo *);
More information about the p4-projects
mailing list