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. Found by UBSan. OK'd by kamil.



details:   https://anonhg.NetBSD.org/src/rev/1e272e77b111
branches:  trunk
changeset: 451830:1e272e77b111
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Fri Jun 07 04:39:15 2019 +0000

description:
Use unsigned. Found by UBSan. OK'd by kamil.

diffstat:

 sys/dev/pci/if_wm.c    |  16 ++++++++--------
 sys/dev/pci/if_wmreg.h |  14 +++++++-------
 2 files changed, 15 insertions(+), 15 deletions(-)

diffs (85 lines):

diff -r f0da4ae24eb7 -r 1e272e77b111 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Jun 07 00:18:26 2019 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Jun 07 04:39:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.639 2019/05/28 08:59:35 msaitoh Exp $      */
+/*     $NetBSD: if_wm.c,v 1.640 2019/06/07 04:39:15 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.639 2019/05/28 08:59:35 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.640 2019/06/07 04:39:15 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3541,9 +3541,9 @@
        int rv;
 
        if (enaddr != NULL) {
-               ral_lo = enaddr[0] | (enaddr[1] << 8) | (enaddr[2] << 16) |
-                   (enaddr[3] << 24);
-               ral_hi = enaddr[4] | (enaddr[5] << 8);
+               ral_lo = (uint32_t)enaddr[0] | ((uint32_t)enaddr[1] << 8) |
+                   ((uint32_t)enaddr[2] << 16) | ((uint32_t)enaddr[3] << 24);
+               ral_hi = (uint32_t)enaddr[4] | ((uint32_t)enaddr[5] << 8);
                ral_hi |= RAL_AV;
        } else {
                ral_lo = 0;
@@ -5198,7 +5198,7 @@
        CTASSERT(sizeof(rss_key) == RSS_KEYSIZE);
 
        for (i = 0; i < RETA_NUM_ENTRIES; i++) {
-               int qid, reta_ent;
+               unsigned int qid, reta_ent;
 
                qid  = i % sc->sc_nqueues;
                switch (sc->sc_type) {
@@ -5915,9 +5915,9 @@
 
        /* Set registers about MSI-X */
        if (wm_is_using_msix(sc)) {
-               uint32_t ivar;
+               uint32_t ivar, qintr_idx;
                struct wm_queue *wmq;
-               int qid, qintr_idx;
+               unsigned int qid;
 
                if (sc->sc_type == WM_T_82575) {
                        /* Interrupt control */
diff -r f0da4ae24eb7 -r 1e272e77b111 sys/dev/pci/if_wmreg.h
--- a/sys/dev/pci/if_wmreg.h    Fri Jun 07 00:18:26 2019 +0000
+++ b/sys/dev/pci/if_wmreg.h    Fri Jun 07 04:39:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wmreg.h,v 1.113 2019/02/28 16:56:35 khorben Exp $   */
+/*     $NetBSD: if_wmreg.h,v 1.114 2019/06/07 04:39:15 msaitoh Exp $   */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -720,17 +720,17 @@
 #define IVAR_VALID       __BIT(7)
 /* IVAR definitions for 82580 and newer */
 #define WMREG_IVAR_Q(x)        (WMREG_IVAR0 + ((x) / 2) * 4)
-#define IVAR_TX_MASK_Q(x) (0x000000ff << (((x) % 2) == 0 ? 8 : 24))
-#define IVAR_RX_MASK_Q(x) (0x000000ff << (((x) % 2) == 0 ? 0 : 16))
+#define IVAR_TX_MASK_Q(x) (0x000000ffUL << (((x) % 2) == 0 ? 8 : 24))
+#define IVAR_RX_MASK_Q(x) (0x000000ffUL << (((x) % 2) == 0 ? 0 : 16))
 /* IVAR definitions for 82576 */
 #define WMREG_IVAR_Q_82576(x)  (WMREG_IVAR0 + ((x) & 0x7) * 4)
-#define IVAR_TX_MASK_Q_82576(x) (0x000000ff << (((x) / 8) == 0 ? 8 : 24))
-#define IVAR_RX_MASK_Q_82576(x) (0x000000ff << (((x) / 8) == 0 ? 0 : 16))
+#define IVAR_TX_MASK_Q_82576(x) (0x000000ffUL << (((x) / 8) == 0 ? 8 : 24))
+#define IVAR_RX_MASK_Q_82576(x) (0x000000ffUL << (((x) / 8) == 0 ? 0 : 16))
 /* IVAR definitions for 82574 */
 #define IVAR_ALLOC_MASK_82574  __BITS(0, 2)
 #define IVAR_VALID_82574       __BIT(3)
-#define IVAR_TX_MASK_Q_82574(x) (0x0000000f << ((x) == 0 ? 8 : 12))
-#define IVAR_RX_MASK_Q_82574(x) (0x0000000f << ((x) == 0 ? 0 : 4))
+#define IVAR_TX_MASK_Q_82574(x) (0x0000000fUL << ((x) == 0 ? 8 : 12))
+#define IVAR_RX_MASK_Q_82574(x) (0x0000000fUL << ((x) == 0 ? 0 : 4))
 #define IVAR_OTHER_MASK                __BITS(16, 19)
 #define IVAR_INT_ON_ALL_WB     __BIT(31)
 



Home | Main Index | Thread Index | Old Index