aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-09-28 13:41:41 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-09-28 13:41:41 +0000
commit0afdfdf649005b50c1fffd663537b405129ae4d1 (patch)
tree0b39935bb8aa9d5aacc570879963643f4e288227
parent920c52a5c80969ab0c831e56cb26971e83942f0a (diff)
downloadbusybox-w32-0afdfdf649005b50c1fffd663537b405129ae4d1.tar.gz
busybox-w32-0afdfdf649005b50c1fffd663537b405129ae4d1.tar.bz2
busybox-w32-0afdfdf649005b50c1fffd663537b405129ae4d1.zip
hdparm: paranoia-induced fix against theoretical div-by-0 case
-rw-r--r--miscutils/hdparm.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/miscutils/hdparm.c b/miscutils/hdparm.c
index 906dd7a0c..cb6db78cd 100644
--- a/miscutils/hdparm.c
+++ b/miscutils/hdparm.c
@@ -1378,8 +1378,8 @@ static void print_timing(unsigned m, unsigned elapsed_us)
1378 1378
1379 printf("%5u MB in %u.%02u seconds = %u kB/s\n", 1379 printf("%5u MB in %u.%02u seconds = %u kB/s\n",
1380 m, sec, hs, 1380 m, sec, hs,
1381 /* + 1 prevents div-by-0 */ 1381 /* "| 1" prevents div-by-0 */
1382 (unsigned) ((unsigned long long)m * (1024 * 1000000) / (elapsed_us + 1)) 1382 (unsigned) ((unsigned long long)m * (1024 * 1000000) / (elapsed_us | 1))
1383 // ~= (m * 1024) / (elapsed_us / 1000000) 1383 // ~= (m * 1024) / (elapsed_us / 1000000)
1384 // = kb / elapsed_sec 1384 // = kb / elapsed_sec
1385 ); 1385 );