From 1ec3fc44a3294702ce2f62657a3447294ed16b41 Mon Sep 17 00:00:00 2001 From: elad Date: Sat, 15 Apr 2006 00:34:42 +0000 Subject: [PATCH] Coverity CID 1050, 1051: Correct NULL guards. --- sys/kern/kern_clock.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/kern/kern_clock.c b/sys/kern/kern_clock.c index a8bda6f72af1..f9890b89a282 100644 --- a/sys/kern/kern_clock.c +++ b/sys/kern/kern_clock.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_clock.c,v 1.96 2005/12/11 12:24:29 christos Exp $ */ +/* $NetBSD: kern_clock.c,v 1.97 2006/04/15 00:34:42 elad Exp $ */ /*- * Copyright (c) 2000, 2004 The NetBSD Foundation, Inc. @@ -76,7 +76,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.96 2005/12/11 12:24:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_clock.c,v 1.97 2006/04/15 00:34:42 elad Exp $"); #include "opt_ntp.h" #include "opt_multiprocessor.h" @@ -991,7 +991,7 @@ proftick(struct clockframe *frame) } #endif #ifdef PROC_PC - if (p && p->p_flag & P_PROFIL) + if (p && (p->p_flag & P_PROFIL)) addupc_intr(p, PROC_PC(p)); #endif } @@ -1011,7 +1011,6 @@ statclock(struct clockframe *frame) #endif struct cpu_info *ci = curcpu(); struct schedstate_percpu *spc = &ci->ci_schedstate; - struct lwp *l; struct proc *p; /* @@ -1027,10 +1026,11 @@ statclock(struct clockframe *frame) setstatclockrate(profhz); } } - l = curlwp; - p = (l ? l->l_proc : 0); + p = (curlwp ? curlwp->l_proc : NULL); if (CLKF_USERMODE(frame)) { - if (p->p_flag & P_PROFIL && profsrc == PROFSRC_CLOCK) + KASSERT(p != NULL); + + if ((p->p_flag & P_PROFIL) && profsrc == PROFSRC_CLOCK) addupc_intr(p, CLKF_PC(frame)); if (--spc->spc_pscnt > 0) return; @@ -1058,7 +1058,7 @@ statclock(struct clockframe *frame) } #endif #ifdef LWP_PC - if (p && profsrc == PROFSRC_CLOCK && p->p_flag & P_PROFIL) + if (p && profsrc == PROFSRC_CLOCK && (p->p_flag & P_PROFIL)) addupc_intr(p, LWP_PC(l)); #endif if (--spc->spc_pscnt > 0) @@ -1087,7 +1087,7 @@ statclock(struct clockframe *frame) } spc->spc_pscnt = psdiv; - if (l != NULL) { + if (p != NULL) { ++p->p_cpticks; /* * If no separate schedclock is provided, call it here