[PATCH 3/3] fastboot: switch to using error format specifiers

Ahmad Fatoum a.fatoum at pengutronix.de
Thu Jun 5 04:25:33 PDT 2025


With the addition of the __printf attribute to fastboot_tx_print, we get
a number of warnings telling us that we are passing not a string literal
as format string, but the result of strerror.

Silence the warning by using the error format specifiers instead.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/fastboot.c                        | 6 +++---
 drivers/usb/gadget/function/f_fastboot.c | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 886f22f61128..2a5906c7e6a4 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -835,7 +835,7 @@ static void cb_erase(struct fastboot *fb, const char *cmd)
 
 	fd = open(filename, O_RDWR);
 	if (fd < 0)
-		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, strerror(-fd));
+		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "%m");
 
 	ret = erase(fd, ERASE_SIZE_ALL, 0, ERASE_TO_CLEAR);
 
@@ -920,7 +920,7 @@ static void cb_oem_setenv(struct fastboot *fb, const char *cmd)
 	free(var);
 
 	if (ret)
-		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, strerror(-ret));
+		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "%pe", ERR_PTR(ret));
 }
 
 static void cb_oem_exec(struct fastboot *fb, const char *cmd)
@@ -935,7 +935,7 @@ static void cb_oem_exec(struct fastboot *fb, const char *cmd)
 
 	ret = run_command(cmd);
 	if (ret < 0)
-		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, strerror(-ret));
+		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "%pe", ERR_PTR(ret));
 	else if (ret > 0)
 		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "");
 	else
diff --git a/drivers/usb/gadget/function/f_fastboot.c b/drivers/usb/gadget/function/f_fastboot.c
index 20a5f076aa12..85732802ff80 100644
--- a/drivers/usb/gadget/function/f_fastboot.c
+++ b/drivers/usb/gadget/function/f_fastboot.c
@@ -471,7 +471,7 @@ static void rx_handler_dl_image(struct usb_ep *ep, struct usb_request *req)
 					    req->actual);
 	if (ret < 0) {
 		fastboot_tx_print(&f_fb->fastboot, FASTBOOT_MSG_FAIL,
-				  strerror(-ret));
+				  "%pe", ERR_PTR(ret));
 		return;
 	}
 
-- 
2.39.5




More information about the barebox mailing list