Commit graph

5 commits

Author SHA1 Message Date
Carlos R. Mafra 49944a01ae wmnet: simplify updateStats_dev() a bit
There is no need to have a variable holding the interface name and
doing the exercise of stripping the trailing colon. It is enough
to just compare the line to check whether it contains the device
name. And only if it does we sscanf() its contents.
2015-01-11 21:04:02 +00:00
Carlos R. Mafra cd4947f139 wmnet: Cope with interface name longer than 6 characters
After a recent change in the kernel (their commit 6e094bd) my
wireless interface name is 8 characters long, wlp3s0b1. But
the wmnet code to read the received bytes

	totalbytes_in = strtoul(&buffer[7], NULL, 10);

assumed that the interface name in /proc/net/dev would be 6 characters
long (and would start reading at position 7).

In the linux kernel mailing list I reported the regression and none
other than Al Viro replied,

> I am not sure if 'wmnet' could do this better (any suggestions?),

*snort*

well, yes - it's called scanf().  And if one is really, really nervous
about the overhead of <gasp> parsing a bunch of integers (as if fopen/
fgets/fclose alone won't cost enough to make constantly calling that
sucker a bad idea), just use ptr + <something> - 6 instead of
&buffer[<something>] in there.  That thing has just found where the
colon was (and replaced it with NUL), so dealing with "the first field
turned out to be too long and shifted everything past it" isn't hard.

******

I also took the oportunity to remove the unused variables diffpackets_{in,out}
2015-01-11 13:16:40 +00:00
Doug Torrance 612921ae43 Remove trailing whitespace. 2014-10-05 19:18:49 +01:00
Alexey I. Froloff 792a5d290a Mass update FSF address
Signed-off-by: Alexey I. Froloff <raorn@raorn.name>
2012-06-05 20:50:13 +01:00
Carlos R. Mafra eea379d833 Strip off version numbers from dir name 2012-02-12 22:50:31 +00:00