Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ic Use unsigned to avoid undefined behavior. Found b...



details:   https://anonhg.NetBSD.org/src/rev/941eec1c09f1
branches:  trunk
changeset: 463673:941eec1c09f1
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Tue Sep 03 14:26:55 2019 +0000

description:
Use unsigned to avoid undefined behavior. Found by kUBSan.

diffstat:

 sys/dev/ic/rt2860.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r 0fd0eebe93d0 -r 941eec1c09f1 sys/dev/ic/rt2860.c
--- a/sys/dev/ic/rt2860.c       Tue Sep 03 14:18:32 2019 +0000
+++ b/sys/dev/ic/rt2860.c       Tue Sep 03 14:26:55 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rt2860.c,v 1.33 2018/09/03 16:29:31 riastradh Exp $    */
+/*     $NetBSD: rt2860.c,v 1.34 2019/09/03 14:26:55 msaitoh Exp $      */
 /*     $OpenBSD: rt2860.c,v 1.90 2016/04/13 10:49:26 mpi Exp $ */
 /*     $FreeBSD: head/sys/dev/ral/rt2860.c 306591 2016-10-02 20:35:55Z avos $ */
 
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.33 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rt2860.c,v 1.34 2019/09/03 14:26:55 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/sockio.h>
@@ -2233,7 +2233,7 @@
 rt2860_enable_mrr(struct rt2860_softc *sc)
 {
 #define CCK(mcs)       (mcs)
-#define OFDM(mcs)      (1 << 3 | (mcs))
+#define OFDM(mcs)      (1U << 3 | (mcs))
        RAL_WRITE(sc, RT2860_LG_FBK_CFG0,
            OFDM(6) << 28 |     /* 54->48 */
            OFDM(5) << 24 |     /* 48->36 */
@@ -3294,7 +3294,7 @@
                        b4 = 0;
                else if (b4 > 0xf)
                        b4 = 0xf;
-               b32 = b32 >> 4 | b4 << 28;
+               b32 = b32 >> 4 | (uint32_t)b4 << 28;
        }
        return b32;
 }



Home | Main Index | Thread Index | Old Index