Minor /proc/net/dev parsing updates; has nothing to do with latest
compilation problems.
This commit is contained in:
@@ -258,13 +258,13 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
|||||||
|
|
||||||
fields = 0;
|
fields = 0;
|
||||||
while (*p != '|') {
|
while (*p != '|') {
|
||||||
if (isspace (*p))
|
if (!isspace (*p++)) continue;
|
||||||
fields++;
|
while (isspace (*p++)) ;
|
||||||
p++;
|
fields++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Should never happen. */
|
/* Should never happen. */
|
||||||
if (!fields) return;
|
if (fields < 2) return;
|
||||||
fields--;
|
fields--;
|
||||||
|
|
||||||
while (fgets (buffer, BUFSIZ-1, f)) {
|
while (fgets (buffer, BUFSIZ-1, f)) {
|
||||||
@@ -287,8 +287,10 @@ glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
|
|||||||
|
|
||||||
/* Only read byte counts if we really have them. */
|
/* Only read byte counts if we really have them. */
|
||||||
|
|
||||||
if (have_bytes)
|
if (have_bytes) {
|
||||||
buf->bytes_in = strtoul (p, &p, 0);
|
buf->bytes_in = strtoul (p, &p, 0);
|
||||||
|
fields--;
|
||||||
|
}
|
||||||
|
|
||||||
buf->packets_in = strtoul (p, &p, 0);
|
buf->packets_in = strtoul (p, &p, 0);
|
||||||
buf->errors_in = strtoul (p, &p, 0);
|
buf->errors_in = strtoul (p, &p, 0);
|
||||||
|
Reference in New Issue
Block a user