summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authormsaitoh <msaitoh@NetBSD.org>2019-07-25 11:56:09 +0000
committermsaitoh <msaitoh@NetBSD.org>2019-07-25 11:56:09 +0000
commit93a6825f07ba74a1d7ffa2eed494a2f16060b6c8 (patch)
tree3da7472a03061f1dd14c238a01c59734bfbe911e /sys/dev
parentbad3f6b6c4f215e90ebe4287f48bd4a5e7551968 (diff)
Avoid undefined behavior. Found by KUBSan. Some of errors are still remaining.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/arn9285.c8
-rw-r--r--sys/dev/ic/athn.c6
-rw-r--r--sys/dev/ic/athnreg.h6
3 files changed, 10 insertions, 10 deletions
diff --git a/sys/dev/ic/arn9285.c b/sys/dev/ic/arn9285.c
index 69790ae7448..2751d993e14 100644
--- a/sys/dev/ic/arn9285.c
+++ b/sys/dev/ic/arn9285.c
@@ -1,4 +1,4 @@
-/* $NetBSD: arn9285.c,v 1.3 2013/10/17 21:24:24 christos Exp $ */
+/* $NetBSD: arn9285.c,v 1.4 2019/07/25 11:56:09 msaitoh Exp $ */
/* $OpenBSD: ar9285.c,v 1.19 2012/06/10 21:23:36 kettenis Exp $ */
/*-
@@ -24,7 +24,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arn9285.c,v 1.3 2013/10/17 21:24:24 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arn9285.c,v 1.4 2019/07/25 11:56:09 msaitoh Exp $");
#ifndef _MODULE
#include "athn_usb.h"
@@ -320,7 +320,7 @@ ar9285_init_from_rom(struct athn_softc *sc, struct ieee80211_channel *c,
AR_WRITE_BARRIER(sc);
DELAY(100);
reg = AR_READ(sc, AR9285_AN_RF2G4);
- reg = RW(reg, AR9271_AN_RF2G4_DB2, db2[0]);
+ reg = RW(reg, AR9271_AN_RF2G4_DB2, (uint32_t)db2[0]);
AR_WRITE(sc, AR9285_AN_RF2G4, reg);
AR_WRITE_BARRIER(sc);
DELAY(100);
@@ -784,7 +784,7 @@ ar9285_set_power_calib(struct athn_softc *sc, struct ieee80211_channel *c)
pdadcs[i + 0] << 0 |
pdadcs[i + 1] << 8 |
pdadcs[i + 2] << 16 |
- pdadcs[i + 3] << 24);
+ (uint32_t)pdadcs[i + 3] << 24);
}
AR_WRITE_BARRIER(sc);
}
diff --git a/sys/dev/ic/athn.c b/sys/dev/ic/athn.c
index 6a1326fc1c3..0d1a0401d98 100644
--- a/sys/dev/ic/athn.c
+++ b/sys/dev/ic/athn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: athn.c,v 1.21 2019/05/28 07:41:48 msaitoh Exp $ */
+/* $NetBSD: athn.c,v 1.22 2019/07/25 11:56:09 msaitoh Exp $ */
/* $OpenBSD: athn.c,v 1.83 2014/07/22 13:12:11 mpi Exp $ */
/*-
@@ -23,7 +23,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.21 2019/05/28 07:41:48 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: athn.c,v 1.22 2019/07/25 11:56:09 msaitoh Exp $");
#ifndef _MODULE
#include "athn_usb.h" /* for NATHN_USB */
@@ -1021,7 +1021,7 @@ athn_get_delta_slope(uint32_t coeff, uint32_t *exponent, uint32_t *mantissa)
/* exponent = 14 - floor(log2(coeff)) */
for (exp = 31; exp > 0; exp--)
- if (coeff & (1 << exp))
+ if (coeff & (1U << exp))
break;
exp = 14 - (exp - COEFF_SCALE_SHIFT);
diff --git a/sys/dev/ic/athnreg.h b/sys/dev/ic/athnreg.h
index 0070de4aa5b..ab81371ac52 100644
--- a/sys/dev/ic/athnreg.h
+++ b/sys/dev/ic/athnreg.h
@@ -1,4 +1,4 @@
-/* $NetBSD: athnreg.h,v 1.1 2013/03/30 02:53:02 christos Exp $ */
+/* $NetBSD: athnreg.h,v 1.2 2019/07/25 11:56:09 msaitoh Exp $ */
/* $OpenBSD: athnreg.h,v 1.18 2012/06/10 21:23:36 kettenis Exp $ */
/*-
@@ -851,12 +851,12 @@
#define AR_INTR_SPURIOUS 0xffffffff
/* Bits for AR_GPIO_OE_OUT. */
-#define AR_GPIO_OE_OUT_DRV_M 0x00000003
+#define AR_GPIO_OE_OUT_DRV_M 0x00000003UL
#define AR_GPIO_OE_OUT_DRV_S 0
#define AR_GPIO_OE_OUT_DRV_NO 0
#define AR_GPIO_OE_OUT_DRV_LOW 1
#define AR_GPIO_OE_OUT_DRV_HI 2
-#define AR_GPIO_OE_OUT_DRV_ALL 3
+#define AR_GPIO_OE_OUT_DRV_ALL 3UL
/* Bits for AR_GPIO_INTR_POL. */
#define AR_GPIO_INTR_POL_PIN(i) (1 << (i))