From nobody Thu Jun 20 17:53:51 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4W4p5D6Pcpz5PCVp; Thu, 20 Jun 2024 17:53:52 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4W4p5C6347z4y72; Thu, 20 Jun 2024 17:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718906031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C/zbLobjqfo24PEmn46HScYjZTvmT5mqYK7HqdNsIco=; b=uexkN84PZH8Oe6MNPO0hEPjT1y3IpLCKjDREtWT/lwS5Vr50eYkTuyBvQflMZr5kQKriiP PQtUQthPb6KVx0lAflh/le3HPhgyOeniibR6iC9ewBujVtJrzZy3nzitJgnqmFKqd0s+eG JtoeVdnBhjKAfCsNAHf3DVm0lO8YM6QOIVURTqkx4AwaNY9EUUmrSRcmSweAsnwVprsj5P ubuGEtmSvSDVn00f+qHvew75MTWZBLTFrMJaM5HlxMm8lnyExgbKyhma9e5sYZsFTV2zg1 hCOa7tHEB4YYcaRAzcdYasjI76c7qBHM4MtmiQrn54RPcEvBwZBr0xqAIvTQBg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1718906031; a=rsa-sha256; cv=none; b=HQ9PikmzMJOBCuVLpDe1VowN6fLx2i0S3LhN8wKxGS5ly5NqG0PBP4kxxfIdh9VRLTwZfu GaHc8WmtIHD02BI5dKcgI0+apJgKWtdYYK+64xLuuM9n3RRRz9ylX4K9tPQWEu9eEWTX9s sSkxrBfG57bU+UTXHvkwKHFspN9HkRcEeQvBUC3L1D4st8KvrTqdNvUJF/fm1yFiiKsrBV Oho4ij3qL2LXEWEC4yhNRU6iKX7rLKo/X723VmKLB8Gn0LEUB5pzyklOLDETIjxhszuAwR E1x6guHlI0GqvKww6bOJ8fXQUlMFBJwFK0veLwdT4dZ0Pin7P6WpZak9JFbm8A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1718906031; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=C/zbLobjqfo24PEmn46HScYjZTvmT5mqYK7HqdNsIco=; b=YUAPQK9/PsPXwTmyawpFJXmZpeD6VghWNf99N91ENfVgs2fjJRdEe4+uPEFZYY7XHKC0rI K1TjyWct3V8JWUDwmY8VZC5jRnIZ3/n2TzwDcTN7Kl+cxsO4p9lNP1sQWEJj/xKE/LZTKR aAoRe9m3HJkk395StfU2U23uf9gu0Xq41qTT3JjzL8o+0yg5RwefJG487JGh00ykRkM9dv J/7R/hrSXH4dc0F/pxbeY+qhMx3n95Eq8gAPu2zfTXOt/nykKALo/xd33m5i6Or31kuONc zBQxOLtiwAuRNJ1PDIPyWp+205UdPtwBb/VLhWtUh+g8uyIUqNSood1gmAtssg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4W4p5C5TtYzZn1; Thu, 20 Jun 2024 17:53:51 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 45KHrpd1065935; Thu, 20 Jun 2024 17:53:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 45KHrpVm065932; Thu, 20 Jun 2024 17:53:51 GMT (envelope-from git) Date: Thu, 20 Jun 2024 17:53:51 GMT Message-Id: <202406201753.45KHrpVm065932@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 39afff09c550 - main - callout: tidy up _callout_init_lock() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 39afff09c5509c2e838c370a0c476dd9ac97d622 Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=39afff09c5509c2e838c370a0c476dd9ac97d622 commit 39afff09c5509c2e838c370a0c476dd9ac97d622 Author: Gleb Smirnoff AuthorDate: 2024-06-20 17:53:31 +0000 Commit: Gleb Smirnoff 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