Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Use unsigned to avoid undefined behavior in wm_i...



details:   https://anonhg.NetBSD.org/src/rev/5bb412042822
branches:  trunk
changeset: 458577:5bb412042822
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Aug 01 14:28:33 2019 +0000

description:
Use unsigned to avoid undefined behavior in wm_i82543_mii_sendbits().
Found by kUBSan.

diffstat:

 sys/dev/pci/if_wm.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r f217a9062bd3 -r 5bb412042822 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Thu Aug 01 13:45:54 2019 +0000
+++ b/sys/dev/pci/if_wm.c       Thu Aug 01 14:28:33 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.645 2019/07/30 04:42:29 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.646 2019/08/01 14:28:33 msaitoh Exp $      */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.645 2019/07/30 04:42:29 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.646 2019/08/01 14:28:33 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -10413,7 +10413,7 @@
        v &= ~(MDI_IO | MDI_CLK | (CTRL_SWDPIO_MASK << CTRL_SWDPIO_SHIFT));
        v |= MDI_DIR | CTRL_SWDPIO(3);
 
-       for (i = 1 << (nbits - 1); i != 0; i >>= 1) {
+       for (i = __BIT(nbits - 1); i != 0; i >>= 1) {
                if (data & i)
                        v |= MDI_IO;
                else



Home | Main Index | Thread Index | Old Index