The branch main has been updated by glebius:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=39afff09c5509c2e838c370a0c476dd9ac97d622

commit 39afff09c5509c2e838c370a0c476dd9ac97d622
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2024-06-20 17:53:31 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2024-06-20 17:53:31 +0000

    callout: tidy up _callout_init_lock()
    
    Separate function into assertive part and into assigning part.
    Consistently use __func__ in the assertions.  Write the assigning code in
    a declarative style.
    
    The functional change is that we no longer validate flags in the
    non-INVARIANT kernel.  The assertion that checks flags has been there for
    17 years, so all code that calls with invalid flags must have been
    filtered and fixed.
---
 sys/kern/kern_timeout.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c
index 5f2d78285c66..e06cf997ab8a 100644
--- a/sys/kern/kern_timeout.c
+++ b/sys/kern/kern_timeout.c
@@ -1331,16 +1331,18 @@ callout_init(struct callout *c, int mpsafe)
 void
 _callout_init_lock(struct callout *c, struct lock_object *lock, int flags)
 {
-       bzero(c, sizeof *c);
-       c->c_lock = lock;
        KASSERT((flags & ~(CALLOUT_RETURNUNLOCKED | CALLOUT_SHAREDLOCK)) == 0,
-           ("callout_init_lock: bad flags %d", flags));
+           ("%s: bad flags %d", __func__, flags));
        KASSERT(lock != NULL || (flags & CALLOUT_RETURNUNLOCKED) == 0,
-           ("callout_init_lock: CALLOUT_RETURNUNLOCKED with no lock"));
+           ("%s: CALLOUT_RETURNUNLOCKED with no lock", __func__));
        KASSERT(lock == NULL || !(LOCK_CLASS(lock)->lc_flags & LC_SLEEPABLE),
            ("%s: callout %p has sleepable lock", __func__, c));
-       c->c_iflags = flags & (CALLOUT_RETURNUNLOCKED | CALLOUT_SHAREDLOCK);
-       c->c_cpu = cc_default_cpu;
+
+       *c = (struct callout ){
+               .c_lock = lock,
+               .c_iflags = flags,
+               .c_cpu = cc_default_cpu,
+       };
 }
 
 static int

Reply via email to