aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fsbm.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/fsbm.c b/fsbm.c
index 06918c8..5f7d5c1 100644
--- a/fsbm.c
+++ b/fsbm.c
@@ -33,10 +33,11 @@ void endHandler(int signum) {
void print_bps(double bytesPerSecond) {
const char* prefixes[] = { "", "k", "M", "G", "T", "P", "E", "Z", "Y" };
-
- // Calculate the value
double value;
const char* unit;
+ unsigned prefix = 0;
+
+ // Calculate the value
if(use_bits) {
value = bytesPerSecond * 8;
unit = "b/s";
@@ -47,7 +48,6 @@ void print_bps(double bytesPerSecond) {
}
// Choose the prefix
- unsigned prefix = 0;
while (prefix < (sizeof(prefixes) / sizeof(const char*)) && value > 1000.) {
value /= 1000.;
++prefix;
@@ -73,6 +73,7 @@ void print_stats() {
long long unsigned rx_bytes, tx_bytes;
struct timezone unused_timezone;
struct timeval timestamp;
+ ptrdiff_t len = 0;
// Read a line
fgets(buf, sizeof(buf), dev);
@@ -90,7 +91,6 @@ void print_stats() {
// Remove leading whitespace from the name
name = buf;
- ptrdiff_t len = 0;
while (*name == ' ' || *name == '\t') {
++name;
}
@@ -159,21 +159,20 @@ int main(int argc, char **argv) {
// parse the command line
int c;
-
int interval = 10 * 100000;
- while ((c = getopt (argc, argv, "bi:hv")) != -1)
+ while ((c = getopt (argc, argv, "brd:hv")) != -1)
switch (c)
{
case 'b':
use_bits = true;
break;
- case 'i':
+ case 'd':
// Magic numbers? fuck it that's not a magic number, that's a 'real' number.
interval = atoi(optarg) * 100000;
break;
case 'h':
- printf("USAGE: fsbm, -b specifies bits, -i sets interval in 10ths of seconds, 1 sec default\n");
+ printf("USAGE: fsbm, -b specifies bits, -d sets interval in 10ths of seconds, 1 sec default\n");
exit(EXIT_SUCCESS);
break;
case 'v':