From dshadow@zort.net Tue Aug 22 11:27:54 2000 Date: Tue, 22 Aug 2000 11:24:07 -0400 (EDT) From: John Bafford To: reed@wingeer.org Cc: mhaque@haque.net Subject: WMND Hey..found and fixed another WMND bug for you. /proc/net/dev's values are actually unsigned longs and will contain values outside the range of an "int" (which is actually the same as a signed long on most platforms). Since WMND is using atoi(), it gets confused and doesn't update the display when the values go outside the range of an int. The solution is to change the types of input_* and output_* to unsigned long and use the function strtoul() to get the correct value. I've included a patch that fixes this. You may wish to rewrite a portion of this function, since -1 is an invalid value for an unsigned long, and while it works (sets it to the maximum possible value), it's not really good style to be setting a variable outside its range. -John ---BEGIN PACH *** wmnd.c-old Tue Aug 22 11:05:39 2000 --- wmnd.c Tue Aug 22 11:05:42 2000 *************** int get_statistics(char *devname, long * *** 989,996 **** char temp[PROC_NET_DEV_LINE_SIZE]; char *p; char *tokens = " |:\n"; ! int input_b, output_b; /* bytes */ ! int input_p, output_p; /* packets */ int i; int found; struct ppp_stats ppp_cur, ppp_old; --- 989,996 ---- char temp[PROC_NET_DEV_LINE_SIZE]; char *p; char *tokens = " |:\n"; ! unsigned long input_b, output_b; /* bytes */ ! unsigned long input_p, output_p; /* packets */ int i; int found; struct ppp_stats ppp_cur, ppp_old; *************** int get_statistics(char *devname, long * *** 1069,1084 **** i = 0; do { if (i == input_b) { /* read incoming bytes */ ! *is = atoi(p); input_b = -1; } else if (i == output_b) { /* read outgoing bytes */ ! *os = atoi(p); output_b = -1; } else if (i == input_p) { /* read incoming packets */ ! *ip = atoi(p); input_p = -1; } else if (i == output_p) { /* read outgoing packets */ ! *op = atoi(p); output_p = -1; } i++; --- 1069,1084 ---- i = 0; do { if (i == input_b) { /* read incoming bytes */ ! *is = strtoul(p, 0, 0); input_b = -1; } else if (i == output_b) { /* read outgoing bytes */ ! *os = strtoul(p, 0, 0); output_b = -1; } else if (i == input_p) { /* read incoming packets */ ! *ip = strtoul(p, 0, 0); input_p = -1; } else if (i == output_p) { /* read outgoing packets */ ! *op = strtoul(p, 0, 0); output_p = -1; } i++; ---END PATCH -- John Bafford dshadow@zort.net http://www.dshadow.com/