Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x86/x86 Avoid the 1<<31 construct



details:   https://anonhg.NetBSD.org/src/rev/a7b532575ed2
branches:  trunk
changeset: 451596:a7b532575ed2
user:      kamil <kamil%NetBSD.org@localhost>
date:      Tue May 28 16:43:24 2019 +0000

description:
Avoid the 1<<31 construct

Shift unsigned int rather than signed one.

Detected with kUBSan when reading /proc/cpuinfo.

diffstat:

 sys/arch/x86/x86/procfs_machdep.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r fd7030bdeac4 -r a7b532575ed2 sys/arch/x86/x86/procfs_machdep.c
--- a/sys/arch/x86/x86/procfs_machdep.c Tue May 28 15:30:39 2019 +0000
+++ b/sys/arch/x86/x86/procfs_machdep.c Tue May 28 16:43:24 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs_machdep.c,v 1.31 2019/05/16 04:26:13 msaitoh Exp $ */
+/*     $NetBSD: procfs_machdep.c,v 1.32 2019/05/28 16:43:24 kamil Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.31 2019/05/16 04:26:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_machdep.c,v 1.32 2019/05/28 16:43:24 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -235,7 +235,7 @@
        size_t l;
 
        for (size_t i = 0; i < 32; i++) {
-               if ((reg & (1 << i)) && table[i]) {
+               if ((reg & (1U << i)) && table[i]) {
                        l = snprintf(p, *left, "%s ", table[i]);
                        if (l < *left) {
                                *left -= l;



Home | Main Index | Thread Index | Old Index