Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Properly fill the struct timeval before using it:...



details:   https://anonhg.NetBSD.org/src/rev/ba665e50f731
branches:  trunk
changeset: 781133:ba665e50f731
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Tue Aug 21 15:53:07 2012 +0000

description:
Properly fill the struct timeval before using it: a timeout in microseconds has
to be converted to seconds and microseconds.
Fix KASSERT("usec >= 0 && usec < 1000000") in tvtohz().
While there, simplify computation of to (avoids a timersub() in tvhzto()
and directly call tvtohz() with the interval).

diffstat:

 sys/dev/ic/isp_netbsd.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (37 lines):

diff -r 41e47b9f197e -r ba665e50f731 sys/dev/ic/isp_netbsd.c
--- a/sys/dev/ic/isp_netbsd.c   Tue Aug 21 14:19:02 2012 +0000
+++ b/sys/dev/ic/isp_netbsd.c   Tue Aug 21 15:53:07 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: isp_netbsd.c,v 1.85 2011/12/12 18:28:34 jdc Exp $ */
+/* $NetBSD: isp_netbsd.c,v 1.86 2012/08/21 15:53:07 bouyer Exp $ */
 /*
  * Platform (NetBSD) dependent common attachment code for Qlogic adapters.
  */
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.85 2011/12/12 18:28:34 jdc Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isp_netbsd.c,v 1.86 2012/08/21 15:53:07 bouyer Exp $");
 
 #include <dev/ic/isp_netbsd.h>
 #include <dev/ic/isp_ioctl.h>
@@ -1603,14 +1603,14 @@
                tv.tv_sec = 0;
                tv.tv_usec = 0;
                for (olim = 0; olim < maxc; olim++) {
-                       utv.tv_sec = 0;
-                       utv.tv_usec = usecs;
+                       utv.tv_sec = usecs / 1000000;
+                       utv.tv_usec = usecs % 1000000;
                        timeradd(&tv, &utv, &tv);
                }
-               timeradd(&tv, &start, &tv);
-               to = tvhzto(&tv);
+               to = tvtohz(&tv);
                if (to == 0)
                        to = 1;
+               timeradd(&tv, &start, &tv);
 
                isp->isp_osinfo.mbox_sleep_ok = 0;
                isp->isp_osinfo.mbox_sleeping = 1;



Home | Main Index | Thread Index | Old Index