mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/5] treewide: replace strerror of errno with %m
Date: Wed, 16 Apr 2025 12:37:45 +0200	[thread overview]
Message-ID: <20250416103748.265415-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250416103748.265415-1-a.fatoum@pengutronix.de>

%m saves us some visual clutter and even some code size, so make use of
it.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/arm/lib32/bootm.c         |  6 +++---
 arch/sandbox/os/common.c       |  3 +--
 commands/memtester/memtester.c | 11 +++++------
 common/blspec.c                |  2 +-
 drivers/misc/jtag.c            |  2 +-
 5 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/arch/arm/lib32/bootm.c b/arch/arm/lib32/bootm.c
index 34ce401e8fd9..3d3e01aa4138 100644
--- a/arch/arm/lib32/bootm.c
+++ b/arch/arm/lib32/bootm.c
@@ -204,12 +204,12 @@ static int bootm_load_tee_from_file(struct image_data *data)
 
 	fd = open(data->tee_file, O_RDONLY);
 	if (fd < 0) {
-		pr_err("%s", strerror(errno));
+		pr_err("%m\n");
 		return -errno;
 	}
 
 	if (read_full(fd, &hdr, sizeof(hdr)) < 0) {
-		pr_err("%s", strerror(errno));
+		pr_err("%m\n");
 		ret = -errno;
 		goto out;
 	}
@@ -219,7 +219,7 @@ static int bootm_load_tee_from_file(struct image_data *data)
 		goto out;
 
 	if (read_full(fd, (void *)data->tee_res->start, hdr.init_size) < 0) {
-		pr_err("%s", strerror(errno));
+		pr_err("%m\n");
 		ret = -errno;
 		release_region(data->tee_res);
 		goto out;
diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index d44213319422..c5043160b1f9 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -447,8 +447,7 @@ int linux_open_hostfile(struct hf_info *hf)
 				MAP_SHARED, fd, 0);
 
 		if (hf->base == (unsigned long)MAP_FAILED)
-			printf("warning: mmapping %s failed: %s\n",
-			       hf->filename, strerror(errno));
+			printf("warning: mmapping %s failed: %m\n", hf->filename);
 	} else {
 		printf("warning: %s: contiguous map failed\n", hf->filename);
 	}
diff --git a/commands/memtester/memtester.c b/commands/memtester/memtester.c
index f4adbfc855cb..aacb80d80936 100644
--- a/commands/memtester/memtester.c
+++ b/commands/memtester/memtester.c
@@ -109,8 +109,7 @@ static int do_memtester(int argc, char **argv) {
                 break;
             case 'd':
                 if (stat(optarg,&statbuf)) {
-                    printf("can not use %s as device: %s\n", optarg,
-                            strerror(errno));
+                    printf("can not use %s as device: %m\n", optarg);
                     return COMMAND_ERROR_USAGE;
                 } else {
                     if (!S_ISCHR(statbuf.st_mode) && !S_ISBLK(statbuf.st_mode)) {
@@ -164,14 +163,14 @@ static int do_memtester(int argc, char **argv) {
     if (memtester_use_phys) {
         memfd = open(device_name, O_RDWR);
         if (memfd == -1) {
-            printf("failed to open %s for physical memory: %s\n",
-                    device_name, strerror(errno));
+            printf("failed to open %s for physical memory: %m\n",
+                    device_name);
             return EXIT_FAIL_NONSTARTER;
         }
         buf = memmap(memfd, PROT_READ | PROT_WRITE) + memtester_physaddrbase;
         if (buf == MAP_FAILED) {
-            printf("failed to mmap %s for physical memory: %s\n",
-                    device_name, strerror(errno));
+            printf("failed to mmap %s for physical memory: %m\n",
+                    device_name);
             close(memfd);
             return EXIT_FAIL_NONSTARTER;
         }
diff --git a/common/blspec.c b/common/blspec.c
index dd3bb1c167d7..80ebe256ceaf 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -472,7 +472,7 @@ static int blspec_scan_directory(struct bootscanner *bootscanner,
 
 	ret = glob(abspath, 0, NULL, &globb);
 	if (ret) {
-		pr_debug("%s: %s: %s\n", __func__, abspath, strerror(errno));
+		pr_debug("%s: %s: %m\n", __func__, abspath);
 		ret = -errno;
 		goto err_out;
 	}
diff --git a/drivers/misc/jtag.c b/drivers/misc/jtag.c
index cca0aba2d6b5..8673fa68505b 100644
--- a/drivers/misc/jtag.c
+++ b/drivers/misc/jtag.c
@@ -269,7 +269,7 @@ static void jtag_info(struct device *pdev)
 		ret = jtag_ioctl(&info->cdev, JTAG_GET_ID, &jid);
 		printf("  Device number: %d\n", dn);
 		if (ret == -1)
-			printf("   JTAG_GET_ID failed: %s\n", strerror(errno));
+			printf("   JTAG_GET_ID failed: %m\n");
 		else
 			printf("   ID: 0x%lX\n", jid.id);
 	}
-- 
2.39.5




  reply	other threads:[~2025-04-16 10:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 10:37 [PATCH 1/5] bootm: fix error reporting around optee_verify_header_request_region Ahmad Fatoum
2025-04-16 10:37 ` Ahmad Fatoum [this message]
2025-04-16 10:37 ` [PATCH 3/5] commands: memtester: fix erroneous use of errno Ahmad Fatoum
2025-04-16 10:37 ` [PATCH 4/5] treewide: fix wrong signed value passed to strerror Ahmad Fatoum
2025-04-16 10:37 ` [PATCH 5/5] treewide: replace strerror with %pe format specifier Ahmad Fatoum

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=20250416103748.265415-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@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