From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 04/23] log: Add new category names to log_cat_name
Date: Sat, 17 Oct 2020 14:07:29 -0400 [thread overview]
Message-ID: <20201017180749.119271-5-seanga2@gmail.com> (raw)
In-Reply-To: <20201017180749.119271-1-seanga2@gmail.com>
Without every category between LOGC_NONE and LOGC_COUNT present in
log_cat_name, log_get_cat_by_name will dereference NULL pointers if it
doesn't find a name early enough.
Fixes: c3aed5db59 ("sandbox: spi: Add more logging")
Fixes: a5c13b68e7 ("sandbox: log: Add a category for sandbox")
Fixes: 9f407d4ef0 ("Add core support for a bloblist to convey data from SPL")
Fixes: cce61fc428 ("dm: devres: Convert to use logging")
Fixes: 7ca2850cbc ("dm: core: Add basic ACPI support")
Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
(no changes since v2)
Changes in v2:
- Add compiletime assert on size of log_cat_name
common/log.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/common/log.c b/common/log.c
index f3d9f4a728..5a588c4152 100644
--- a/common/log.c
+++ b/common/log.c
@@ -13,7 +13,7 @@
DECLARE_GLOBAL_DATA_PTR;
-static const char *const log_cat_name[LOGC_COUNT - LOGC_NONE] = {
+static const char *const log_cat_name[] = {
"none",
"arch",
"board",
@@ -21,6 +21,11 @@ static const char *const log_cat_name[LOGC_COUNT - LOGC_NONE] = {
"driver-model",
"device-tree",
"efi",
+ "alloc",
+ "sandbox",
+ "bloblist",
+ "devres",
+ "acpi",
};
static const char *const log_level_name[LOGL_COUNT] = {
@@ -40,6 +45,9 @@ const char *log_get_cat_name(enum log_category_t cat)
{
const char *name;
+ compiletime_assert(ARRAY_SIZE(log_cat_name) == LOGC_COUNT - LOGC_NONE,
+ "missing logging category name");
+
if (cat < 0 || cat >= LOGC_COUNT)
return "<invalid>";
if (cat >= LOGC_NONE)
--
2.28.0
next prev parent reply other threads:[~2020-10-17 18:07 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-17 18:07 [PATCH v3 00/23] log: Add commands for manipulating filters Sean Anderson
2020-10-17 18:07 ` [PATCH v3 01/23] log: Fix missing negation of ENOMEM Sean Anderson
2020-10-17 18:07 ` [PATCH v3 02/23] log: Fix incorrect documentation of log_filter.cat_list Sean Anderson
2020-10-17 18:07 ` [PATCH v3 03/23] log: Add additional const qualifier to arrays Sean Anderson
2020-10-17 18:07 ` Sean Anderson [this message]
2020-10-27 17:45 ` [PATCH v3 04/23] log: Add new category names to log_cat_name Tom Rini
2020-10-27 18:07 ` Sean Anderson
2020-10-27 18:08 ` Tom Rini
2020-10-17 18:07 ` [PATCH v3 05/23] log: Use CONFIG_IS_ENABLED() for LOG_TEST Sean Anderson
2020-10-17 18:07 ` [PATCH v3 06/23] log: Expose some helper functions Sean Anderson
2020-10-17 18:07 ` [PATCH v3 07/23] log: Add function to create a filter with flags Sean Anderson
2020-10-17 18:07 ` [PATCH v3 08/23] log: Add filter flag to deny on match Sean Anderson
2020-10-17 18:07 ` [PATCH v3 09/23] test: log: Convert log_test from python to C Sean Anderson
2020-11-03 15:11 ` Simon Glass
2020-10-17 18:07 ` [PATCH v3 10/23] test: log: Give tests names instead of numbers Sean Anderson
2020-11-03 15:11 ` Simon Glass
2020-10-17 18:07 ` [PATCH v3 11/23] test: Add tests for LOGFF_DENY Sean Anderson
2020-10-17 18:07 ` [PATCH v3 12/23] log: Add filter flag to match greater than a log level Sean Anderson
2020-10-17 18:07 ` [PATCH v3 13/23] test: Add test for LOGFF_MIN Sean Anderson
2020-10-17 18:07 ` [PATCH v3 14/23] cmd: log: Use sub-commands for log Sean Anderson
2020-10-17 18:07 ` [PATCH v3 15/23] cmd: log: Split off log level parsing Sean Anderson
2020-10-17 18:07 ` [PATCH v3 16/23] cmd: log: Add commands to list categories and drivers Sean Anderson
2020-10-17 18:07 ` [PATCH v3 17/23] cmd: log: Make "log level" print all log levels Sean Anderson
2020-10-17 18:07 ` [PATCH v3 18/23] lib: Add getopt Sean Anderson
2020-11-03 15:11 ` Simon Glass
2020-10-17 18:07 ` [PATCH v3 19/23] test: Add a test for getopt Sean Anderson
2020-11-03 15:11 ` Simon Glass
2020-10-17 18:07 ` [PATCH v3 20/23] cmd: log: Add commands to manipulate filters Sean Anderson
2020-10-17 18:07 ` [PATCH v3 21/23] test: Add a test for log filter-* Sean Anderson
2020-10-27 21:00 ` Tom Rini
2020-10-27 21:11 ` Sean Anderson
2020-10-27 21:12 ` Tom Rini
2020-10-17 18:07 ` [PATCH v3 22/23] doc: Add log kerneldocs to documentation Sean Anderson
2020-10-17 18:07 ` [PATCH v3 23/23] doc: Update logging documentation Sean Anderson
2020-10-27 20:58 ` Tom Rini
2020-10-27 21:00 ` Heinrich Schuchardt
2020-10-27 21:11 ` Sean Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201017180749.119271-5-seanga2@gmail.com \
--to=seanga2@gmail.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox