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 switch pmc_ncounters to unsigned int.



details:   https://anonhg.NetBSD.org/src/rev/6ea2819f10a9
branches:  trunk
changeset: 823295:6ea2819f10a9
user:      maya <maya%NetBSD.org@localhost>
date:      Tue Apr 18 15:14:28 2017 +0000

description:
switch pmc_ncounters to unsigned int.

matches userland pmc, makes it clear to static analyzers that if the loop
in pmc_nmi (for (i = 0; i < pmc_ncounters; i++) ) is not entered, then the
condition i == pmc_ncounters (== 0) is satisfied and no null derefs occur

this change only helps analyzers read the code, null deref was not possible
before.

diffstat:

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

diffs (27 lines):

diff -r 9459c78d68e6 -r 6ea2819f10a9 sys/arch/x86/x86/pmc.c
--- a/sys/arch/x86/x86/pmc.c    Tue Apr 18 14:11:42 2017 +0000
+++ b/sys/arch/x86/x86/pmc.c    Tue Apr 18 15:14:28 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmc.c,v 1.5 2017/03/24 19:21:06 maxv Exp $     */
+/*     $NetBSD: pmc.c,v 1.6 2017/04/18 15:14:28 maya Exp $     */
 
 /*
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.5 2017/03/24 19:21:06 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmc.c,v 1.6 2017/04/18 15:14:28 maya Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -106,7 +106,7 @@
 static kmutex_t pmc_lock;
 
 static pmc_state_t pmc_state[PMC_NCOUNTERS];
-static int pmc_ncounters __read_mostly;
+static uint32_t pmc_ncounters __read_mostly;
 static int pmc_type __read_mostly;
 
 static int



Home | Main Index | Thread Index | Old Index