Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Move the timeout check out of the loop, otherwise...



details:   https://anonhg.NetBSD.org/src/rev/2fce33b91008
branches:  trunk
changeset: 454643:2fce33b91008
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Sep 23 17:37:04 2019 +0000

description:
Move the timeout check out of the loop, otherwise it is never reached.
Found by the lgtm bot.

diffstat:

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

diffs (35 lines):

diff -r d208578cc6e5 -r 2fce33b91008 sys/dev/ic/an.c
--- a/sys/dev/ic/an.c   Mon Sep 23 17:20:41 2019 +0000
+++ b/sys/dev/ic/an.c   Mon Sep 23 17:37:04 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: an.c,v 1.71 2019/09/20 11:29:47 maxv Exp $     */
+/*     $NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $     */
 /*
  * Copyright (c) 1997, 1998, 1999
  *     Bill Paul <wpaul%ctr.columbia.edu@localhost>.  All rights reserved.
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.71 2019/09/20 11:29:47 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: an.c,v 1.72 2019/09/23 17:37:04 maxv Exp $");
 
 
 #include <sys/param.h>
@@ -1796,12 +1796,12 @@
        for (i = 0; i < AN_TIMEOUT; i++) {
                if (CSR_READ_2(sc, AN_EVENT_STAT) & AN_EV_ALLOC)
                        break;
-               if (i == AN_TIMEOUT) {
-                       printf("%s: timeout in alloc\n", device_xname(sc->sc_dev));
-                       return ETIMEDOUT;
-               }
                DELAY(10);
        }
+       if (i == AN_TIMEOUT) {
+               printf("%s: timeout in alloc\n", device_xname(sc->sc_dev));
+               return ETIMEDOUT;
+       }
 
        *idp = CSR_READ_2(sc, AN_ALLOC_FID);
        CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_ALLOC);



Home | Main Index | Thread Index | Old Index