Am 30. März 2023 23:32:21 MESZ schrieb Simon Glass <s...@chromium.org>:
>To save a few bytes, replace Error with ** and try to use the same string
>for multiple messages where possible.
>
>Signed-off-by: Simon Glass <s...@chromium.org>
>---
>
> fs/fat/fat.c | 12 ++++++------
> fs/fat/fat_write.c | 14 ++++----------
> 2 files changed, 10 insertions(+), 16 deletions(-)
>
>diff --git a/fs/fat/fat.c b/fs/fat/fat.c
>index 2da93dae3cf3..f0df7988e172 100644
>--- a/fs/fat/fat.c
>+++ b/fs/fat/fat.c
>@@ -97,8 +97,8 @@ int fat_register_device(struct blk_desc *dev_desc, int
>part_no)
> /* Read the partition table, if present */
> if (part_get_info(dev_desc, part_no, &info)) {
> if (part_no != 0) {
>- printf("** Partition %d not valid on device %d **\n",
>- part_no, dev_desc->devnum);
>+ printf("** Partition %d invalid on device %d **\n",
>+ part_no, dev_desc->devnum);
> return -1;
> }
>
>@@ -168,7 +168,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
> __u32 ret = 0x00;
>
> if (CHECK_CLUST(entry, mydata->fatsize)) {
>- printf("Error: Invalid FAT entry: 0x%08x\n", entry);
>+ printf("** Invalid FAT entry: %#08x\n", entry);
The ** is superfluous. The text makes it clear that an error occured
> return ret;
> }
>
>@@ -586,17 +586,17 @@ static int get_fs_info(fsdata *mydata)
> mydata->sect_size = (bs.sector_size[1] << 8) + bs.sector_size[0];
> mydata->clust_size = bs.cluster_size;
> if (mydata->sect_size != cur_part_info.blksz) {
>- printf("Error: FAT sector size mismatch (fs=%hu, dev=%lu)\n",
>+ printf("** FAT sector size mismatch (fs=%hu, dev=%lu)\n",
ditto
> mydata->sect_size, cur_part_info.blksz);
> return -1;
> }
> if (mydata->clust_size == 0) {
>- printf("Error: FAT cluster size not set\n");
>+ printf("** FAT cluster size not set\n");
ditto
> return -1;
> }
> if ((unsigned int)mydata->clust_size * mydata->sect_size >
> MAX_CLUSTSIZE) {
>- printf("Error: FAT cluster size too big (cs=%u, max=%u)\n",
>+ printf("** FAT cluster size too big
ditto
(cs=%u, max=%u)\n",
> (unsigned int)mydata->clust_size * mydata->sect_size,
> MAX_CLUSTSIZE);
> return -1;
>diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
>index 00541ebc3a4a..4d2d4db07fa6 100644
>--- a/fs/fat/fat_write.c
>+++ b/fs/fat/fat_write.c
>@@ -1568,8 +1568,9 @@ int fat_unlink(const char *filename)
> char *filename_copy, *dirname, *basename;
>
> filename_copy = strdup(filename);
>- if (!filename_copy) {
>- printf("Error: allocating memory\n");
>+ itr = malloc_cache_aligned(sizeof(fat_itr));
>+ if (!itr || !filename_copy) {
>+ printf("Error: out of memory\n");
remove 'Error: '
Best regards
Heinrich
> ret = -ENOMEM;
> goto exit;
> }
>@@ -1581,13 +1582,6 @@ int fat_unlink(const char *filename)
> goto exit;
> }
>
>- itr = malloc_cache_aligned(sizeof(fat_itr));
>- if (!itr) {
>- printf("Error: allocating memory\n");
>- ret = -ENOMEM;
>- goto exit;
>- }
>-
> ret = fat_itr_root(itr, &fsdata);
> if (ret)
> goto exit;
>@@ -1602,7 +1596,7 @@ int fat_unlink(const char *filename)
> }
>
> if (!find_directory_entry(itr, basename)) {
>- printf("%s: doesn't exist\n", basename);
>+ printf("%s: doesn't exist (%d)\n", basename, -ENOENT);
> ret = -ENOENT;
> goto exit;
> }