From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0AB92F3621 for ; Mon, 4 May 2026 20:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777925642; cv=none; b=I2WJg+uCoJLonsNY9wuEO2m26Of9qCc5bTbljsQENyw/ELRzhQOcN48MmJ3/2W7L8Fx2ufJJm5yXQu/stGWjAcBv7GZiBkrAsR66PD777Q5e63JRjZFQae2TDdr0jF3fpKpYQBi5XBshPBD1g2TINOsi/Dm9QgHfa1G+Z6X1o3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777925642; c=relaxed/simple; bh=vm4lu3HLQekZqgpCavEdu7CRRfsWGWStQdCoz6mraVU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=UDqrc+OSGIaOpvx3DG0ie+nxhI/NHWwAA8eT2YJxg0xgSrPVmbDdO/KDUIdYFm9qtqbPmbecjz8sncBbar7bcJxZq6x3+yrAkT3jD+vfCtrFnqyS4+6aYbB1gBUJq0XOXddZs+WTjQtwEvCoUOZhjzmfDcA2dWJC4O8lTcwSZ5Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=lDYiFrXM; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lDYiFrXM" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4891f6b6388so2474265e9.0 for ; Mon, 04 May 2026 13:14:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777925639; x=1778530439; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yxx+FN2p+zAV8B9QEc+g88G+L/f/1C3C94LCqoSG7NQ=; b=lDYiFrXMeueKV5jf4AlLVKRMwZLblGGrG1BluucQe2ewQMmwgxVmeS0z21YKGGBCYw oBevuFEbqxy4m0RuWLYZK3COOHD90O577RSQGdyVP+9YEv9tC9EULg1of5kT9IbTHsxO eqzQ1iFJT/ZjVFY5Gfftc3ilnApVHMcdrTMSRq5v+7lni4pfYkERCe24FFb+99dGZahQ ZCbwTqn+bE9DNGBZq75OdNOsO90p1QNry87U1hCzsb/zabFElozlDCZBsoScluGvBGFt 4+uuWG6ETJRnvXIoA2cOty5GXr3tajF0mbWwQ9mNfLxA7W4naTP3KrZDKE2N0mlQSzoI ZxPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777925639; x=1778530439; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yxx+FN2p+zAV8B9QEc+g88G+L/f/1C3C94LCqoSG7NQ=; b=dqJj+n0R207Vd2MkWESAbTTdeJJFNJEcl3a8RJFRCKHNKnwIAKomYFmkJ+RAQIeof/ zl6vus/dSOaTFKnyObMDyxxBzw0I0qH0jiqkKWrojVAHBucFPEep3trI2NXNTmjRVPKK ZbGf8ag6JnA76g6NjnM+4mzKvulxbxh2eJm1krEn4PWTjf2qKmWD2Dmfnsj9AtlK//IG T1zOTvVCb6TehozHlWjHNn/6l5hMV4pRH6kNyZF5Y5vDF+8rR6cfr+r6UvlgNO6fZOGf lvBJ1ScCd/sizv1PamXMFmObnVb18Y7Rw52SVofMxiIozwl2oX55TzhZmB9GDHXk9y+d s7kw== X-Gm-Message-State: AOJu0YxBLhhBRg0W8qNRmZdDnIC2jwD2EGT5jdoLrdHoxwSwgtDaXDh3 xWzO2M8QYSGTRCFvzzhJIn3GxSXSSyKv9aBMYyVmcP3MmkAIMVWPDFFg X-Gm-Gg: AeBDieu+gA+qbUa1wp1hHYnmu1A9CW75Ln6SqAvwzpq68c/gwFGRyS7XNYkMfboLuoe SPjDQBnS33v0dWx0nQgpnXTIYz/gC5y371LwHdnMo+XLzJonOL8rcTdn9ZpRI5e3eOCpaQXTuri 9naQhGJ5nQjeosIeyYXGspcx3VqczCDsgwUoEN2zib5PBaSoqAv2nsvfFsJrJw4aKLXnU1WV/O9 g42YrEvRTd8KaIg74MlN2ESKZi+Ej/1mTwr1ebBdC1QyM94wes3L+yPkGFb76gratm1+ZzBIcgQ A0UUeQkOUZcfqOCR86UrHV3ZomrqxTzKzTbCh+D7zKaC/mC0nZtgxo3mpzRrNUVTw6xT3lf4Cg1 4Wxy1so9mRMqnqz8IyuctIt9qCzAD4a1grPWTWcVEVVc9KEMH2netLrkiv5AaJCHg5NLGEQCwqM dSBGKW/JJf+Ho5t7MEKuup X-Received: by 2002:a05:600c:1d21:b0:48a:5758:7999 with SMTP id 5b1f17b1804b1-48a9865e099mr89271675e9.4.1777925638685; Mon, 04 May 2026 13:13:58 -0700 (PDT) Received: from lucas ([2a01:e0a:354:c290:234c:5dad:48b0:9188]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48d14786affsm4637165e9.0.2026.05.04.13.13.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 13:13:58 -0700 (PDT) From: Lucas Poupeau To: petermz@redhat.com, tglx@linutronix.de, mingo@redhat.com Cc: linux-kernel@vger.kernel.org, Lucas Poupeau Subject: [PATCH] lib/bug: cleanup comment style, types and modernize logging Date: Mon, 4 May 2026 22:13:56 +0200 Message-ID: <20260504201356.56542-1-lucasp.linux@gmail.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Improve the overall code quality of lib/bug.c by: - Reformatting the main documentation block to follow the standard kernel multi-line comment style. - Replacing 'unsigned' with the preferred 'unsigned int'. - Converting legacy printk() calls to modern pr_warn() and pr_info() macros to include proper facility levels and satisfy checkpatch. Signed-off-by: Lucas Poupeau --- lib/bug.c | 80 +++++++++++++++++++++++++++---------------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/lib/bug.c b/lib/bug.c index 224f4cfa4aa3..f4a4df3991b0 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -1,41 +1,41 @@ // SPDX-License-Identifier: GPL-2.0 /* - Generic support for BUG() - - This respects the following config options: - - CONFIG_BUG - emit BUG traps. Nothing happens without this. - CONFIG_GENERIC_BUG - enable this code. - CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file - CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG - - CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable - (though they're generally always on). - - CONFIG_GENERIC_BUG is set by each architecture using this code. - - To use this, your architecture must: - - 1. Set up the config options: - - Enable CONFIG_GENERIC_BUG if CONFIG_BUG - - 2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON) - - Define HAVE_ARCH_BUG - - Implement BUG() to generate a faulting instruction - - NOTE: struct bug_entry does not have "file" or "line" entries - when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate - the values accordingly. - - 3. Implement the trap - - In the illegal instruction trap handler (typically), verify - that the fault was in kernel mode, and call report_bug() - - report_bug() will return whether it was a false alarm, a warning, - or an actual bug. - - You must implement the is_valid_bugaddr(bugaddr) callback which - returns true if the eip is a real kernel address, and it points - to the expected BUG trap instruction. - - Jeremy Fitzhardinge 2006 + * Generic support for BUG() + * + * This respects the following config options: + * + * CONFIG_BUG - emit BUG traps. Nothing happens without this. + * CONFIG_GENERIC_BUG - enable this code. + * CONFIG_GENERIC_BUG_RELATIVE_POINTERS - use 32-bit relative pointers for bug_addr and file + * CONFIG_DEBUG_BUGVERBOSE - emit full file+line information for each BUG + * + * CONFIG_BUG and CONFIG_DEBUG_BUGVERBOSE are potentially user-settable + * (though they're generally always on). + * + * CONFIG_GENERIC_BUG is set by each architecture using this code. + * + * To use this, your architecture must: + * + * 1. Set up the config options: + * - Enable CONFIG_GENERIC_BUG if CONFIG_BUG + * + * 2. Implement BUG (and optionally BUG_ON, WARN, WARN_ON) + * - Define HAVE_ARCH_BUG + * - Implement BUG() to generate a faulting instruction + * - NOTE: struct bug_entry does not have "file" or "line" entries + * when CONFIG_DEBUG_BUGVERBOSE is not enabled, so you must generate + * the values accordingly. + * + * 3. Implement the trap + * - In the illegal instruction trap handler (typically), verify + * that the fault was in kernel mode, and call report_bug() + * - report_bug() will return whether it was a false alarm, a warning, + * or an actual bug. + * - You must implement the is_valid_bugaddr(bugaddr) callback which + * returns true if the eip is a real kernel address, and it points + * to the expected BUG trap instruction. + * + * Jeremy Fitzhardinge 2006 */ #define pr_fmt(fmt) fmt @@ -71,7 +71,7 @@ static struct bug_entry *module_find_bug(unsigned long bugaddr) guard(rcu)(); list_for_each_entry_rcu(mod, &module_bug_list, bug_list) { - unsigned i; + unsigned int i; bug = mod->bug_table; for (i = 0; i < mod->num_bugs; ++i, ++bug) @@ -191,14 +191,14 @@ void __warn_printf(const char *fmt, struct pt_regs *regs) } #endif - printk("%s", fmt); + pr_warn("%s", fmt); } static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long bugaddr, struct pt_regs *regs) { bool warning, once, done, no_cut, has_args; const char *file, *fmt; - unsigned line; + unsigned int line; if (!bug) { if (!is_valid_bugaddr(bugaddr)) @@ -237,7 +237,7 @@ static enum bug_trap_type __report_bug(struct bug_entry *bug, unsigned long buga * extra debugging message it writes before triggering the handler. */ if (!no_cut) { - printk(KERN_DEFAULT CUT_HERE); + pr_info(CUT_HERE); __warn_printf(fmt, has_args ? regs : NULL); } -- 2.54.0