Source-Changes-HG archive

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

[src/trunk]: src/sys/kern kern: KASSERT(A && B) -> KASSERT(A); KASSERT(B)



details:   https://anonhg.NetBSD.org/src/rev/0c6f6be215e7
branches:  trunk
changeset: 374187:0c6f6be215e7
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Apr 09 09:18:09 2023 +0000

description:
kern: KASSERT(A && B) -> KASSERT(A); KASSERT(B)

diffstat:

 sys/kern/exec_subr.c      |   7 ++++---
 sys/kern/kern_event.c     |  11 ++++++-----
 sys/kern/kern_lwp.c       |   7 ++++---
 sys/kern/kern_proc.c      |   7 ++++---
 sys/kern/kern_sig.c       |  10 ++++++----
 sys/kern/kern_sleepq.c    |   7 ++++---
 sys/kern/kern_softint.c   |  10 ++++++----
 sys/kern/kern_sysctl.c    |  10 +++++-----
 sys/kern/kern_turnstile.c |  14 ++++++++------
 sys/kern/kern_veriexec.c  |  11 +++++++----
 sys/kern/subr_asan.c      |   7 ++++---
 sys/kern/subr_cpufreq.c   |   7 ++++---
 sys/kern/subr_kcpuset.c   |   7 ++++---
 sys/kern/subr_pcu.c       |  13 ++++++++-----
 sys/kern/subr_pool.c      |  10 ++++++----
 sys/kern/subr_prf.c       |   7 ++++---
 sys/kern/subr_time.c      |   7 ++++---
 sys/kern/subr_vmem.c      |  13 ++++++++-----
 sys/kern/subr_xcall.c     |  13 ++++++++-----
 sys/kern/sys_sched.c      |   7 ++++---
 sys/kern/tty_ptm.c        |   7 ++++---
 sys/kern/vfs_cache.c      |  13 ++++++++-----
 sys/kern/vfs_lookup.c     |   7 ++++---
 sys/kern/vfs_syscalls.c   |  11 ++++++-----
 24 files changed, 130 insertions(+), 93 deletions(-)

diffs (truncated from 832 to 300 lines):

diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/exec_subr.c
--- a/sys/kern/exec_subr.c      Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/exec_subr.c      Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_subr.c,v 1.84 2020/04/13 19:23:18 ad Exp $        */
+/*     $NetBSD: exec_subr.c,v 1.85 2023/04/09 09:18:09 riastradh Exp $ */
 
 /*
  * Copyright (c) 1993, 1994, 1996 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exec_subr.c,v 1.84 2020/04/13 19:23:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_subr.c,v 1.85 2023/04/09 09:18:09 riastradh Exp $");
 
 #include "opt_pax.h"
 
@@ -460,7 +460,8 @@ exec_setup_stack(struct lwp *l, struct e
                NEW_VMCMD2(&epp->ep_vmcmds, vmcmd_map_zero, noaccess_size,
                    noaccess_linear_min, NULL, 0, VM_PROT_NONE, VMCMD_STACK);
        }
-       KASSERT(access_size > 0 && access_size <= MAXSSIZ);
+       KASSERT(access_size > 0);
+       KASSERT(access_size <= MAXSSIZ);
        NEW_VMCMD2(&epp->ep_vmcmds, vmcmd_map_zero, access_size,
            access_linear_min, NULL, 0, VM_PROT_READ | VM_PROT_WRITE,
            VMCMD_STACK);
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_event.c
--- a/sys/kern/kern_event.c     Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_event.c     Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_event.c,v 1.146 2022/07/24 19:23:44 riastradh Exp $       */
+/*     $NetBSD: kern_event.c,v 1.147 2023/04/09 09:18:09 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #endif /* _KERNEL_OPT */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.146 2022/07/24 19:23:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.147 2023/04/09 09:18:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1400,7 +1400,8 @@ filt_timerexpire(void *knx)
        kn->kn_data++;
        knote_activate_locked(kn);
        if (kn->kn_sdata != FILT_TIMER_NOSCHED) {
-               KASSERT(kn->kn_sdata > 0 && kn->kn_sdata <= INT_MAX);
+               KASSERT(kn->kn_sdata > 0);
+               KASSERT(kn->kn_sdata <= INT_MAX);
                callout_schedule((callout_t *)kn->kn_hook,
                    (int)kn->kn_sdata);
        }
@@ -2448,8 +2449,8 @@ relock:
                        kn->kn_status &= ~KN_BUSY;
                        kq->kq_count--;
                        KASSERT(kn_in_flux(kn) == false);
-                       KASSERT((kn->kn_status & KN_WILLDETACH) != 0 &&
-                               kn->kn_kevent.udata == curlwp);
+                       KASSERT((kn->kn_status & KN_WILLDETACH) != 0);
+                       KASSERT(kn->kn_kevent.udata == curlwp);
                        mutex_spin_exit(&kq->kq_lock);
                        knote_detach(kn, fdp, true);
                        mutex_enter(&fdp->fd_lock);
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c       Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_lwp.c       Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lwp.c,v 1.251 2022/07/01 01:06:04 riastradh Exp $ */
+/*     $NetBSD: kern_lwp.c,v 1.252 2023/04/09 09:18:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
@@ -217,7 +217,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.251 2022/07/01 01:06:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.252 2023/04/09 09:18:09 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -1075,7 +1075,8 @@ lwp_exit(struct lwp *l)
 
        current = (l == curlwp);
 
-       KASSERT(current || (l->l_stat == LSIDL && l->l_target_cpu == NULL));
+       KASSERT(current || l->l_stat == LSIDL);
+       KASSERT(current || l->l_target_cpu == NULL);
        KASSERT(p == curproc);
 
        SDT_PROBE(proc, kernel, , lwp__exit, l, 0, 0, 0, 0);
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c      Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_proc.c      Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_proc.c,v 1.269 2022/10/26 23:20:36 riastradh Exp $        */
+/*     $NetBSD: kern_proc.c,v 1.270 2023/04/09 09:18:09 riastradh Exp $        */
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.269 2022/10/26 23:20:36 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.270 2023/04/09 09:18:09 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -2044,7 +2044,8 @@ proc_active_lwp(struct proc *p)
 
        struct lwp *l, *lp = NULL;
        LIST_FOREACH(l, &p->p_lwps, l_sibling) {
-               KASSERT(l->l_stat >= 0 && l->l_stat < __arraycount(ostat));
+               KASSERT(l->l_stat >= 0);
+               KASSERT(l->l_stat < __arraycount(ostat));
                if (lp == NULL ||
                    ostat[l->l_stat] > ostat[lp->l_stat] ||
                    (ostat[l->l_stat] == ostat[lp->l_stat] &&
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_sig.c
--- a/sys/kern/kern_sig.c       Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_sig.c       Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sig.c,v 1.404 2022/04/09 23:38:33 riastradh Exp $ */
+/*     $NetBSD: kern_sig.c,v 1.405 2023/04/09 09:18:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.404 2022/04/09 23:38:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.405 2023/04/09 09:18:09 riastradh Exp $");
 
 #include "opt_execfmt.h"
 #include "opt_ptrace.h"
@@ -1316,7 +1316,8 @@ kpsignal2(struct proc *p, ksiginfo_t *ks
        KASSERT(mutex_owned(&proc_lock));
        KASSERT(mutex_owned(p->p_lock));
        KASSERT((ksi->ksi_flags & KSI_QUEUED) == 0);
-       KASSERT(signo > 0 && signo < NSIG);
+       KASSERT(signo > 0);
+       KASSERT(signo < NSIG);
 
        /*
         * If the process is being created by fork, is a zombie or is
@@ -1571,7 +1572,8 @@ proc_stop_done(struct proc *p, int ppmas
        KASSERT(mutex_owned(&proc_lock));
        KASSERT(mutex_owned(p->p_lock));
        KASSERT((p->p_sflag & PS_STOPPING) != 0);
-       KASSERT(p->p_nrlwps == 0 || (p->p_nrlwps == 1 && p == curproc));
+       KASSERT(p->p_nrlwps == 0 || p->p_nrlwps == 1);
+       KASSERT(p->p_nrlwps == 0 || p == curproc);
 
        p->p_sflag &= ~PS_STOPPING;
        p->p_stat = SSTOP;
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_sleepq.c
--- a/sys/kern/kern_sleepq.c    Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_sleepq.c    Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sleepq.c,v 1.73 2022/06/29 22:27:01 riastradh Exp $       */
+/*     $NetBSD: kern_sleepq.c,v 1.74 2023/04/09 09:18:09 riastradh Exp $       */
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.73 2022/06/29 22:27:01 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.74 2023/04/09 09:18:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -225,7 +225,8 @@ sleepq_enqueue(sleepq_t *sq, wchan_t wch
 
        KASSERT(lwp_locked(l, NULL));
        KASSERT(l->l_stat == LSONPROC);
-       KASSERT(l->l_wchan == NULL && l->l_sleepq == NULL);
+       KASSERT(l->l_wchan == NULL);
+       KASSERT(l->l_sleepq == NULL);
        KASSERT((l->l_flag & LW_SINTR) == 0);
 
        l->l_syncobj = sobj;
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_softint.c
--- a/sys/kern/kern_softint.c   Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_softint.c   Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_softint.c,v 1.72 2022/10/28 21:52:02 riastradh Exp $      */
+/*     $NetBSD: kern_softint.c,v 1.73 2023/04/09 09:18:09 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.72 2022/10/28 21:52:02 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.73 2023/04/09 09:18:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -433,7 +433,8 @@ softint_disestablish(void *arg)
        uintptr_t offset;
 
        offset = (uintptr_t)arg;
-       KASSERTMSG(offset != 0 && offset < softint_bytes, "%"PRIuPTR" %u",
+       KASSERT(offset != 0);
+       KASSERTMSG(offset < softint_bytes, "%"PRIuPTR" %u",
            offset, softint_bytes);
 
        /*
@@ -496,7 +497,8 @@ softint_schedule(void *arg)
 
        /* Find the handler record for this CPU. */
        offset = (uintptr_t)arg;
-       KASSERTMSG(offset != 0 && offset < softint_bytes, "%"PRIuPTR" %u",
+       KASSERT(offset != 0);
+       KASSERTMSG(offset < softint_bytes, "%"PRIuPTR" %u",
            offset, softint_bytes);
        sh = (softhand_t *)((uint8_t *)curcpu()->ci_data.cpu_softcpu + offset);
 
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c    Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_sysctl.c    Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_sysctl.c,v 1.268 2023/02/17 06:20:31 skrll Exp $  */
+/*     $NetBSD: kern_sysctl.c,v 1.269 2023/04/09 09:18:09 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2003, 2007, 2008 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
 #define __COMPAT_SYSCTL
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.268 2023/02/17 06:20:31 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sysctl.c,v 1.269 2023/04/09 09:18:09 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_defcorename.h"
@@ -2517,9 +2517,9 @@ sysctl_teardown(struct sysctllog **logp)
        memset(&node, 0, sizeof(node));
 
        while (log->log_left < log->log_size) {
-               KASSERT((log->log_left + 3 < log->log_size) &&
-                       (log->log_left + log->log_num[log->log_left + 2] <=
-                        log->log_size));
+               KASSERT(log->log_left + 3 < log->log_size);
+               KASSERT(log->log_left + log->log_num[log->log_left + 2] <=
+                   log->log_size);
                v = log->log_num[log->log_left++];
                t = log->log_num[log->log_left++];
                namelen = log->log_num[log->log_left++];
diff -r 00236b6b8d6b -r 0c6f6be215e7 sys/kern/kern_turnstile.c
--- a/sys/kern/kern_turnstile.c Sun Apr 09 09:00:56 2023 +0000
+++ b/sys/kern/kern_turnstile.c Sun Apr 09 09:18:09 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_turnstile.c,v 1.45 2022/10/26 23:27:16 riastradh Exp $    */
+/*     $NetBSD: kern_turnstile.c,v 1.46 2023/04/09 09:18:09 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2009, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.45 2022/10/26 23:27:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.46 2023/04/09 09:18:09 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/lockdebug.h>
@@ -385,7 +385,8 @@ turnstile_block(turnstile_t *ts, int q, 
 
        KASSERT(q == TS_READER_Q || q == TS_WRITER_Q);
        KASSERT(mutex_owned(lock));
-       KASSERT(l != NULL && l->l_ts != NULL);
+       KASSERT(l != NULL);
+       KASSERT(l->l_ts != NULL);
 
        if (ts == NULL) {
                /*
@@ -394,8 +395,8 @@ turnstile_block(turnstile_t *ts, int q, 
                 */
                ts = l->l_ts;
                KASSERT(TS_ALL_WAITERS(ts) == 0);
-               KASSERT(LIST_EMPTY(&ts->ts_sleepq[TS_READER_Q]) &&
-                       LIST_EMPTY(&ts->ts_sleepq[TS_WRITER_Q]));
+               KASSERT(LIST_EMPTY(&ts->ts_sleepq[TS_READER_Q]));
+               KASSERT(LIST_EMPTY(&ts->ts_sleepq[TS_WRITER_Q]));
                ts->ts_obj = obj;
                ts->ts_inheritor = NULL;
                LIST_INSERT_HEAD(tc, ts, ts_chain);
@@ -459,7 +460,8 @@ turnstile_wakeup(turnstile_t *ts, int q,
        sq = &ts->ts_sleepq[q];
 



Home | Main Index | Thread Index | Old Index