[PATCH 7/9] usb: gadget: f_mass_storage: Rework do_request_sense slightly

Tom Rini trini at konsulko.com
Thu Apr 6 01:48:57 CEST 2023


When building with clang, it notes that sdinfo may be unused
uninitialized in some cases. This appears to be true from reading the
code, and we can simply set the variable to zero to start with and be as
correct as before.

Signed-off-by: Tom Rini <trini at konsulko.com>
---
I'm honestly not sure why gcc isn't complaining here as this seems to be
a real issue.

Cc: Lukasz Majewski <lukma at denx.de>
Cc: Marek Vasut <marex at denx.de>
---
 drivers/usb/gadget/f_mass_storage.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c
index 45f0504b6e8a..f46829eb7adb 100644
--- a/drivers/usb/gadget/f_mass_storage.c
+++ b/drivers/usb/gadget/f_mass_storage.c
@@ -1117,7 +1117,7 @@ static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh)
 {
 	struct fsg_lun	*curlun = &common->luns[common->lun];
 	u8		*buf = (u8 *) bh->buf;
-	u32		sd, sdinfo;
+	u32		sd, sdinfo = 0;
 	int		valid;
 
 	/*
@@ -1145,7 +1145,6 @@ static int do_request_sense(struct fsg_common *common, struct fsg_buffhd *bh)
 	if (!curlun) {		/* Unsupported LUNs are okay */
 		common->bad_lun_okay = 1;
 		sd = SS_LOGICAL_UNIT_NOT_SUPPORTED;
-		sdinfo = 0;
 		valid = 0;
 	} else {
 		sd = curlun->sense_data;
-- 
2.34.1



More information about the U-Boot mailing list