diff options
| -rw-r--r-- | fsbm.c | 19 | 
1 files changed, 10 insertions, 9 deletions
| @@ -50,7 +50,7 @@ void print_bps(double bytesPerSecond) {  	// Choose the prefix  	while (prefix < (sizeof(prefixes) / sizeof(const char*)) && value > 1000.) {  		value /= 1000.; -		++prefix; +		prefix++;  	}  	// Format the string @@ -69,7 +69,7 @@ void print_stats() {  	// Read /proc/dev/net  	while (!feof(dev)) {  		char buf[512]; -		char *name, *statistics_string; +		char *name, *stats;  		long long unsigned rx_bytes, tx_bytes;  		struct timezone unused_timezone;  		struct timeval timestamp; @@ -82,22 +82,23 @@ void print_stats() {  		gettimeofday(×tamp, &unused_timezone);  		// Find the colon separating the name from the statistics -		statistics_string = strchr(buf, ':'); -		if (!statistics_string) continue; +		stats = strchr(buf, ':'); +		if (!stats) +			continue;  		// Get a pointer to the statistics -		*statistics_string = 0; -		++statistics_string; +		*stats = 0; +		stats++;  		// Remove leading whitespace from the name  		name = buf;  		while (*name == ' ' || *name == '\t') { -			++name; +			name++;  		}  		len = name - buf;  		// Parse the statistics, alls well, then get this shit going, otherwise f it. -		if (sscanf(statistics_string, "%Lu %*Lu %*Lu %*Lu %*Lu %*Lu %*Lu %*Lu %Lu", +		if (sscanf(stats, "%Lu %*Lu %*Lu %*Lu %*Lu %*Lu %*Lu %*Lu %Lu",  					&rx_bytes, &tx_bytes) == 2) {  			size_t i = 0; @@ -112,7 +113,7 @@ void print_stats() {  					break;  				}  			} -skip: +			skip:  			if(found) {  				double timeDelta, rx_speed, tx_speed = 0; | 
