Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/rockchip Use unsigned to avoid undefined behavi...



details:   https://anonhg.NetBSD.org/src/rev/6e8d2ef38861
branches:  trunk
changeset: 983274:6e8d2ef38861
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu May 13 06:15:41 2021 +0000

description:
Use unsigned to avoid undefined behavior in GRF_GPIO_P_{CTL,WRITE_EN}.
Found by kUBSan.

diffstat:

 sys/arch/arm/rockchip/rk3399_iomux.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (29 lines):

diff -r 65a1ff0ed225 -r 6e8d2ef38861 sys/arch/arm/rockchip/rk3399_iomux.c
--- a/sys/arch/arm/rockchip/rk3399_iomux.c      Thu May 13 06:15:29 2021 +0000
+++ b/sys/arch/arm/rockchip/rk3399_iomux.c      Thu May 13 06:15:41 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rk3399_iomux.c,v 1.11 2021/04/24 23:36:28 thorpej Exp $ */
+/* $NetBSD: rk3399_iomux.c,v 1.12 2021/05/13 06:15:41 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 //#define RK3399_IOMUX_DEBUG
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.11 2021/04/24 23:36:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rk3399_iomux.c,v 1.12 2021/05/13 06:15:41 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -45,8 +45,8 @@
 #include <dev/fdt/syscon.h>
 
 /* PU/PD control */
-#define         GRF_GPIO_P_CTL(_idx)           (0x3 << (((_idx) & 7) * 2))
-#define         GRF_GPIO_P_WRITE_EN(_idx)      (0x3 << (((_idx) & 7) * 2 + 16))
+#define         GRF_GPIO_P_CTL(_idx)           (0x3U << (((_idx) & 7) * 2))
+#define         GRF_GPIO_P_WRITE_EN(_idx)      (0x3U << (((_idx) & 7) * 2 + 16))
 /* Different bias value mapping based on pull type of pin */
 #define          IO_DEF_GPIO_P_CTL_Z           0
 #define          IO_DEF_GPIO_P_CTL_PULLUP      1



Home | Main Index | Thread Index | Old Index