Source-Changes-HG archive

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

[src/trunk]: src/sys/net Change used from int to bool.



details:   https://anonhg.NetBSD.org/src/rev/f6a709b76d75
branches:  trunk
changeset: 814950:f6a709b76d75
user:      roy <roy%NetBSD.org@localhost>
date:      Fri Apr 22 00:25:42 2016 +0000

description:
Change used from int to bool.
If used, abort the loop because we think we're already at the end.

diffstat:

 sys/net/if_bridge.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (53 lines):

diff -r 86a8efcb4397 -r f6a709b76d75 sys/net/if_bridge.c
--- a/sys/net/if_bridge.c       Thu Apr 21 23:14:25 2016 +0000
+++ b/sys/net/if_bridge.c       Fri Apr 22 00:25:42 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bridge.c,v 1.117 2016/04/20 09:01:04 knakahara Exp $        */
+/*     $NetBSD: if_bridge.c,v 1.118 2016/04/22 00:25:42 roy Exp $      */
 
 /*
  * Copyright 2001 Wasabi Systems, Inc.
@@ -80,7 +80,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.117 2016/04/20 09:01:04 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.118 2016/04/22 00:25:42 roy Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bridge_ipf.h"
@@ -1453,7 +1453,7 @@
        if (dst_if == NULL) {
                struct bridge_iflist *bif;
                struct mbuf *mc;
-               int used = 0;
+               bool used = false;
 
                BRIDGE_PSZ_RENTER(s);
                BRIDGE_IFLIST_READER_FOREACH(bif, sc) {
@@ -1484,7 +1484,7 @@
 
                        if (PSLIST_READER_NEXT(bif, struct bridge_iflist,
                            bif_next) == NULL) {
-                               used = 1;
+                               used = true;
                                mc = m;
                        } else {
                                mc = m_copym(m, 0, M_COPYALL, M_NOWAIT);
@@ -1504,10 +1504,15 @@
 next:
                        BRIDGE_PSZ_RENTER(s);
                        bridge_release_member(sc, bif, &psref);
+
+                       /* Guarantee we don't re-enter the loop as we already
+                        * decided we're at the end. */
+                       if (used)
+                               break;
                }
                BRIDGE_PSZ_REXIT(s);
 
-               if (used == 0)
+               if (!used)
                        m_freem(m);
                return (0);
        }



Home | Main Index | Thread Index | Old Index