From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 6C2721EB5F8 for ; Mon, 4 May 2026 20:16:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777925772; cv=none; b=C/47mmOdr3Ogvd51XMhV7ys0XlcG2Mh+9fiXISrLG84rsL4pWo8UCYlX3VgoiQ7/oask4vVod81RNY8QJWchZ4EGrjIUeDyTrjQMdED8r6BDadxcli6JHFaWW5g+g5HqDU1xKAeKhe4V0cx096zet7Ql8PlHRj47x48FMZEuHXc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777925772; c=relaxed/simple; bh=vm4lu3HLQekZqgpCavEdu7CRRfsWGWStQdCoz6mraVU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TUXLqDKjczotjj870LpXsyhl1Jf2uR13U69KutMPUua4UVcCXg9H2BGEg3TY3+7d4ZoEUlwTEfzTUWb68RfImQMJgJtnosRqh1pyApX/g2JsqKLNupMxDjqwljgweBbJmO9lDOjft5BMU1vXUStYcAnHeijivlOrmf97m5JCK+Q= 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=BWe5Gd8R; arc=none smtp.client-ip=209.85.128.53 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="BWe5Gd8R" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-48a525dd2b5so5705965e9.2 for ; Mon, 04 May 2026 13:16:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777925770; x=1778530570; 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=BWe5Gd8RrfNMJqBF6OxOjbqFsSEtbmXrafS6N3KxKaDcLcruMC8IGM5HtcWHnS0a0D lOly9Fbx8kknd80z2iNcnLGjBOy0jJdKK05OI6mCISv4CrxC2pUJBhzsk/EYr8EBap+F 4qAIJjet+IzGpZKXOn7iECmXFBYyVtzTowWdKJwTamqhVky/NAk0mdXhAExALaUbGGoj 5nhiKO21/g2TYc63padL5NszAiReYEpILWda/EJrNPnIZpdh7PHXPO97N0mixPhWhJpZ hDWTJx4k1r0l6WWYdHX2Eq8dDf2NejGpMvV8YQTtQHsy5oK4+zk6z8KNI4twrDJVH+uy rx0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777925770; x=1778530570; 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=loBo4CG8oGewlWa6WKRYpdy5qWwst0b+1ao95XbAbKVsgJlwpBLx7kjZ/Qn1kvzaJw WBSeEboGfPFCvRTpHBwz7ajYcIK2xc8EBjE1Ci/VoKZXEx0JposrnH/LyEEGTqKJAX68 paCK0ksl/ZiNkbqCCJcfrfI/OaEv3tUYoFmi35aOfi8OUpyJ8Bn1S5M0X2kTYca4z9oF UxGgeedWHLloJjkvvYKhlwEv/B6VuRU5SpYAR9E4qe3Ya/OLg1RskLI5Jr/2kIdae107 we8NidFHSrnpXYl7SKAM8le926FW4NtkegBgdaXSSyUTVBDUmqBeH4apmGLDpnSfJnyH LLHQ== X-Gm-Message-State: AOJu0YznzfiH4l2a7GuaPodnHOc6OXtimWGN9OMjSltswdNHezKi7gb5 OMhAkQcjeMZJ6rwcSxQUUr8siaLE8pRZKxGrsABelHJrOB+FFgLX7N6V X-Gm-Gg: AeBDiev9n6staC0aSpOoAQKtsauKzsTjfzBWWmlryysSil2vHbPNBcmnetJTPo3mLx1 +ukmx6fnYNcIVrTpL+84ijwVl5mFxsan6p2RLlB46P6LG4GpuEavz9vF5FJkMd2uVGirx5bi53u mRHHtHHX3dambY7XaxC8kSvXEIKfi83mVtTMKyhZBiJ0/VMI+a20KoXVyCk27R5xdrzSdl0OgdQ c6afz99mCxgO4FDCpCjFO33fWY0Mx2J4Cs6IWqzgeJA060ebKVPynV/Aa4unDV2WN0oN8D6vcmQ cWeK6+sDoOV4j4SvpQkLTP7KXRWU8KsQOsuztWfyeNjaWIwdFbTHE+Mu3X+dJZzrMDbSa0dMC7K MBjyBSdlw6bWlFswmVk1yZ4WpTKVA+PILpnAJYbek1Sd7bz3ZjVrBPUpz1Ir+N7CDGk0us0OOL1 hk/+zlaBCAHzfql8Pc2fgv X-Received: by 2002:a05:6000:42c7:b0:43d:55b3:a200 with SMTP id ffacd0b85a97d-44bb57753b6mr6350260f8f.4.1777925769769; Mon, 04 May 2026 13:16:09 -0700 (PDT) Received: from lucas ([2a01:e0a:354:c290:234c:5dad:48b0:9188]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4500fe90e77sm372605f8f.32.2026.05.04.13.16.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 13:16:09 -0700 (PDT) From: Lucas Poupeau To: akpm@linux-foundation.org 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:16:07 +0200 Message-ID: <20260504201607.56932-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