hdparm: paranoia-induced fix against theoretical div-by-0 case
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Fri, 28 Sep 2007 13:41:41 +0000 (13:41 +0000)
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>
Fri, 28 Sep 2007 13:41:41 +0000 (13:41 +0000)
git-svn-id: svn://busybox.net/trunk/busybox@20084 69ca8d6d-28ef-0310-b511-8ec308f3f277

miscutils/hdparm.c

index 906dd7a..cb6db78 100644 (file)
@@ -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
        );