From: Sascha Hauer <s.hauer@pengutronix.de>
To: "open list:BAREBOX" <barebox@lists.infradead.org>
Subject: [PATCH 5/7] filetype: make file type strings optional
Date: Tue, 18 Mar 2025 15:41:46 +0100 [thread overview]
Message-ID: <20250318-filetype-size-reduction-v1-5-4f463ffae7d0@pengutronix.de> (raw)
In-Reply-To: <20250318-filetype-size-reduction-v1-0-4f463ffae7d0@pengutronix.de>
This adds a new Kconfig option FILETYPE_STRING which makes
printing file types as strings optional. The filetype_str[]
array has become quite big and with this we can get rid of
it in size constraint barebox images. Make it default y to
keep the existing default.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/Kconfig | 8 ++++++++
common/filetype.c | 15 +++++++++++++++
2 files changed, 23 insertions(+)
diff --git a/common/Kconfig b/common/Kconfig
index 12026b8232..c57669bb61 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1332,6 +1332,14 @@ config PBL_OPTEE
Allows starting OP-TEE during lowlevel initialization of the PBL.
Requires explicit support in the board's lowlevel file.
+config FILETYPE_STRING
+ bool "Print file types as strings"
+ default y
+ depends on FILETYPE
+ help
+ Say yes here to include strings for filetypes in barebox. If disabled file
+ types will be printed as numbers only.
+
endmenu
if FASTBOOT_BASE
diff --git a/common/filetype.c b/common/filetype.c
index b8d65dfb9f..ce868223d5 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -85,8 +85,20 @@ static const struct filetype_str filetype_str[] = {
[filetype_zstd_compressed] = { "ZSTD compressed", "zstd" },
};
+static const char *file_type_to_nr_string(enum filetype f)
+{
+ static char str[sizeof("4294967295")];
+
+ sprintf(str, "%u", (unsigned int)f);
+
+ return str;
+}
+
const char *file_type_to_string(enum filetype f)
{
+ if (!IS_ENABLED(CONFIG_FILETYPE_STRINGS))
+ return file_type_to_nr_string(f);
+
if (f < ARRAY_SIZE(filetype_str))
return filetype_str[f].name;
@@ -95,6 +107,9 @@ const char *file_type_to_string(enum filetype f)
const char *file_type_to_short_string(enum filetype f)
{
+ if (!IS_ENABLED(CONFIG_FILETYPE_STRINGS))
+ return file_type_to_nr_string(f);
+
if (f < ARRAY_SIZE(filetype_str))
return filetype_str[f].shortname;
--
2.39.5
next prev parent reply other threads:[~2025-03-18 14:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 14:41 [PATCH 0/7] filetype: Some size reduction patches Sascha Hauer
2025-03-18 14:41 ` [PATCH 1/7] filetype: add file_detect_compression_type() Sascha Hauer
2025-03-18 14:41 ` [PATCH 2/7] filetype: add file_detect_fs_type() Sascha Hauer
2025-03-18 14:51 ` Ahmad Fatoum
2025-03-18 15:06 ` Sascha Hauer
2025-03-18 14:41 ` [PATCH 3/7] filetype: add function pointer to file_name_detect_type_offset() Sascha Hauer
2025-03-18 14:41 ` [PATCH 4/7] filetype: let cdev_detect_type() only detect filesystems Sascha Hauer
2025-03-18 14:41 ` Sascha Hauer [this message]
2025-03-18 14:41 ` [PATCH 6/7] ARM: am33xx: myirtech-myd: add MLO specific device tree Sascha Hauer
2025-03-18 14:41 ` [PATCH 7/7] ARM: am335x_mlo_defconfig: disable file type strings Sascha Hauer
2025-03-18 15:01 ` [PATCH 0/7] filetype: Some size reduction patches Alexander Shiyan
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=20250318-filetype-size-reduction-v1-5-4f463ffae7d0@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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