From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Cc: "Sean Anderson" <seanga2@gmail.com>,
"Simon Glass" <sjg@chromium.org>,
"Benoît Thébaudeau" <benoit.thebaudeau@advansee.com>,
"Daniel Palmer" <daniel@thingy.jp>,
"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Tom Rini" <trini@konsulko.com>,
"Varadarajan Narayanan" <varadarajan.narayanan@oss.qualcomm.com>
Subject: [RFC PATCH 03/11] fs: fat: Use strlower() to normalise case
Date: Fri, 15 May 2026 14:32:54 -0600 [thread overview]
Message-ID: <20260515203311.2555651-4-sjg@chromium.org> (raw)
In-Reply-To: <20260515203311.2555651-1-sjg@chromium.org>
Drop the local downcase() helper. The two get_name() call sites
operate on buffers that are NUL-terminated before the lowercase
pass, and the trailing FAT-name padding is spaces which tolower()
leaves untouched, so strlower() gives the same result without
needing an explicit length.
Move the 'ptr[3] = '\0'' assignment in get_name() to before the
extension is lowercased so strlower() sees a terminated string.
Signed-off-by: Simon Glass <sjg@chromium.org>
---
fs/fat/fat.c | 20 ++++----------------
fs/fat/fat_write.c | 2 +-
2 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index c1ccf30771a..dd328f948fb 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -26,23 +26,11 @@
#include <linux/compiler.h>
#include <linux/ctype.h>
#include <linux/log2.h>
+#include <linux/string.h>
/* maximum number of clusters for FAT12 */
#define MAX_FAT12 0xFF4
-/*
- * Convert a string to lowercase. Converts at most 'len' characters,
- * 'len' may be larger than the length of 'str' if 'str' is NULL
- * terminated.
- */
-static void downcase(char *str, size_t len)
-{
- while (*str != '\0' && len--) {
- *str = tolower(*str);
- str++;
- }
-}
-
static struct blk_desc *cur_dev;
static struct disk_partition cur_part_info;
static int fat_sect_size;
@@ -270,13 +258,13 @@ static void get_name(dir_entry *dirent, char *s_name)
while (*ptr && *ptr != ' ')
ptr++;
if (dirent->lcase & CASE_LOWER_BASE)
- downcase(s_name, (unsigned)(ptr - s_name));
+ strlower(s_name);
if (dirent->nameext.ext[0] && dirent->nameext.ext[0] != ' ') {
*ptr++ = '.';
memcpy(ptr, dirent->nameext.ext, 3);
- if (dirent->lcase & CASE_LOWER_EXT)
- downcase(ptr, 3);
ptr[3] = '\0';
+ if (dirent->lcase & CASE_LOWER_EXT)
+ strlower(ptr);
while (*ptr && *ptr != ' ')
ptr++;
}
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index c98b530f747..ea8d301514c 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -1464,7 +1464,7 @@ static int normalize_longname(char *l_filename, const char *filename)
}
strcpy(l_filename, filename);
- downcase(l_filename, VFAT_MAXLEN_BYTES);
+ strlower(l_filename);
return 0;
}
--
2.43.0
next prev parent reply other threads:[~2026-05-15 20:33 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 20:32 [RFC PATCH 00/11] Tidy command option parsing and use it a bit Simon Glass
2026-05-15 20:32 ` [RFC PATCH 01/11] lib: string: Add strlower() Simon Glass
2026-05-15 20:32 ` [RFC PATCH 02/11] cmd: ini: Use strlower() to normalise case Simon Glass
2026-05-15 20:32 ` Simon Glass [this message]
2026-05-15 20:32 ` [RFC PATCH 04/11] boot: pxe_utils: Use strlower() in get_string() Simon Glass
2026-05-15 20:32 ` [RFC PATCH 05/11] lib: getopt: Permute by default with inline reorder Simon Glass
2026-05-15 21:37 ` Sean Anderson
2026-05-20 20:42 ` Simon Glass
2026-05-15 20:32 ` [RFC PATCH 06/11] lib: getopt: Add getopt_pop() helper Simon Glass
2026-05-15 21:40 ` Sean Anderson
2026-05-20 20:41 ` Simon Glass
2026-05-15 20:32 ` [RFC PATCH 07/11] cmd: echo: Use getopt() with '+' prefix for option parsing Simon Glass
2026-05-15 21:58 ` Sean Anderson
2026-05-20 20:41 ` Simon Glass
2026-05-15 20:32 ` [RFC PATCH 08/11] cmd: hash: Use getopt() " Simon Glass
2026-05-15 20:33 ` [RFC PATCH 09/11] cmd: nvedit: Use getopt() in env grep Simon Glass
2026-05-15 20:33 ` [RFC PATCH 10/11] cmd: nvedit: Use getopt() in env export and env import Simon Glass
2026-05-15 20:33 ` [RFC PATCH 11/11] doc: commands: Recommend getopt() for option parsing Simon Glass
2026-05-15 21:43 ` [RFC PATCH 00/11] Tidy command option parsing and use it a bit Tom Rini
2026-05-15 21:59 ` Sean Anderson
2026-05-15 22:06 ` Sean Anderson
2026-05-15 22:21 ` Tom Rini
2026-05-15 22:27 ` Sean Anderson
2026-05-20 20:40 ` Simon Glass
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=20260515203311.2555651-4-sjg@chromium.org \
--to=sjg@chromium.org \
--cc=benoit.thebaudeau@advansee.com \
--cc=daniel@thingy.jp \
--cc=seanga2@gmail.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
--cc=varadarajan.narayanan@oss.qualcomm.com \
--cc=xypron.glpk@gmx.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