From: Denis Vlasenko Date: Fri, 28 Sep 2007 13:41:41 +0000 (-0000) Subject: hdparm: paranoia-induced fix against theoretical div-by-0 case X-Git-Tag: 1_8_0~124 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=0afdfdf649005b50c1fffd663537b405129ae4d1;p=oweals%2Fbusybox.git hdparm: paranoia-induced fix against theoretical div-by-0 case --- 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) printf("%5u MB in %u.%02u seconds = %u kB/s\n", m, sec, hs, - /* + 1 prevents div-by-0 */ - (unsigned) ((unsigned long long)m * (1024 * 1000000) / (elapsed_us + 1)) + /* "| 1" prevents div-by-0 */ + (unsigned) ((unsigned long long)m * (1024 * 1000000) / (elapsed_us | 1)) // ~= (m * 1024) / (elapsed_us / 1000000) // = kb / elapsed_sec );