svn commit: trunk/busybox/miscutils

vda at busybox.net vda at busybox.net
Fri Sep 28 13:41:42 UTC 2007


Author: vda
Date: 2007-09-28 06:41:41 -0700 (Fri, 28 Sep 2007)
New Revision: 20084

Log:
hdparm: paranoia-induced fix against theoretical div-by-0 case



Modified:
   trunk/busybox/miscutils/hdparm.c


Changeset:
Modified: trunk/busybox/miscutils/hdparm.c
===================================================================
--- trunk/busybox/miscutils/hdparm.c	2007-09-28 13:38:08 UTC (rev 20083)
+++ trunk/busybox/miscutils/hdparm.c	2007-09-28 13:41:41 UTC (rev 20084)
@@ -1378,8 +1378,8 @@
 
 	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
 	);




More information about the busybox-cvs mailing list