Skip to contentSkip to conversation

CLEANUP: Cleanup of common/ directory

PATCH New Marek Vasut 2 participants 11 messages Oct 25, 2011 – Oct 27, 2011

lore
Share & tools
lore
#0 lore raw

cover CLEANUP: Cleanup of common/ directory

This series fixes the warnings generated by new debug() macro implementation, which will be merged after this series. This series fixes the problems before the macro is reworked to avoid smooth transition. Most of the problems fixed by this series are printf() formating related problems.

Marek Vasut (5):
GCC4.6: Squash warnings in common/usb.c GCC4.6: Squash warning in cmd_ide.c
GCC4.6: Squash warning in usb_storage.c GCC4.6: Squash subsequent warnings in usb_storage.c GCC4.6: Squash undefined variable in cmd_mtdparts.c

 common/cmd_ide.c      |    2 +-
 common/cmd_mtdparts.c |    2 --
 common/usb.c          |   21 +++++++--------------
 common/usb_storage.c  |   33 +++++++++++++++++----------------
 4 files changed, 25 insertions(+), 33 deletions(-)
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
Signature · 1 line
1.7.6.3
#1 lore raw

PATCH 1/5 GCC4.6: Squash warnings in common/usb.c

usb.c: In function ?usb_parse_config?:
usb.c:331:17: warning: variable ?ch? set but not used [-Wunused-but-set-variable]
usb.c: In function ?usb_hub_port_connect_change?:
usb.c:1123:29: warning: variable ?portchange? set but not used [-Wunused-but-set-variable]
usb.c: In function ?usb_hub_configure?:
usb.c:1183:25: warning: variable ?hubsts? set but not used [-Wunused-but-set-variable]

Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/usb.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)
common/usb.c +7 -14
index 2cd50db..bed5116 100644
@@ -56,16 +56,16 @@
 #endif
 
 #ifdef DEBUG
-#define USB_DEBUG
-#define USB_HUB_DEBUG
-#endif
-
-#ifdef	USB_DEBUG
-#define	USB_PRINTF(fmt, args...)	printf(fmt , ##args)
+#define USB_DEBUG	1
+#define USB_HUB_DEBUG	1
 #else
-#define USB_PRINTF(fmt, args...)
+#define USB_DEBUG	0
+#define USB_HUB_DEBUG	0
 #endif
 
+#define USB_PRINTF(fmt, args...)	debug_cond(USB_DEBUG, fmt, ##args)
+#define USB_HUB_PRINTF(fmt, args...)	debug_cond(USB_HUB_DEBUG, fmt, ##args)
+
 #define USB_BUFSIZ	512
 
 static struct usb_device usb_dev[USB_MAX_DEVICE];
@@ -968,13 +968,6 @@ void usb_scan_devices(void)
  * Probes device for being a hub and configurate it
  */
 
-#ifdef	USB_HUB_DEBUG
-#define	USB_HUB_PRINTF(fmt, args...)	printf(fmt , ##args)
-#else
-#define USB_HUB_PRINTF(fmt, args...)
-#endif
-
-
 static struct usb_hub_device hub_dev[USB_MAX_HUB];
 static int usb_hub_index;
 
Signature · 1 line
1.7.6.3
#2 lore raw

PATCH 1/5 GCC4.6: Squash warnings in common/usb.c

Dear Marek Vasut,

Quoted 10 lines · In message <[email protected]> you wrote:

usb.c: In function ?usb_parse_config?:
usb.c:331:17: warning: variable ?ch? set but not used [-Wunused-but-set-variable]
usb.c: In function ?usb_hub_port_connect_change?:
usb.c:1123:29: warning: variable ?portchange? set but not used [-Wunused-but-set-variable]
usb.c: In function ?usb_hub_configure?:
usb.c:1183:25: warning: variable ?hubsts? set but not used [-Wunused-but-set-variable]

Quoted 7 lines
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/usb.c |   21 +++++++--------------
 1 files changed, 7 insertions(+), 14 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Life, loathe it or ignore it, you can't like it."
- Marvin the paranoid android
#3 lore raw

PATCH 2/5 GCC4.6: Squash warning in cmd_ide.c

In reply to Marek Vasut

cmd_ide.c: In function ?ide_read?:
cmd_ide.c:1227:2: warning: format ?%LX? expects argument of type ?long long unsigned int?, but argument 3 has type ?lbaint_t? [-Wformat]

Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/cmd_ide.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
common/cmd_ide.c +1 -1
index da5189c..74e6504 100644
@@ -1224,7 +1224,7 @@ ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
 		lba48 = 1;
 	}
 #endif
-	debug ("ide_read dev %d start %LX, blocks %lX buffer at %lX\n",
+	debug("ide_read dev %d start %lX, blocks %lX buffer at %lX\n",
 		device, blknr, blkcnt, (ulong)buffer);
 
 	ide_led (DEVICE_LED(device), 1);	/* LED on	*/
Signature · 1 line
1.7.6.3
#4 lore raw

PATCH 2/5 GCC4.6: Squash warning in cmd_ide.c

Dear Marek Vasut,

Quoted 11 lines · In message <[email protected]> you wrote:

cmd_ide.c: In function ?ide_read?:
cmd_ide.c:1227:2: warning: format ?%LX? expects argument of type ?long long unsigned int?, but argument 3 has type ?lbaint_t? [-Wformat]

Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/cmd_ide.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The price one pays for pursuing any profession,  or  calling,  is  an
intimate knowledge of its ugly side.                  - James Baldwin
#5 lore raw

PATCH 3/5 GCC4.6: Squash warning in usb_storage.c

In reply to Marek Vasut

usb_storage.c: In function ?usb_stor_CB_reset?:
usb_storage.c:466:6: warning: variable ?result? set but not used [-Wunused-but-set-variable]

Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/usb_storage.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
common/usb_storage.c +4 -3
index 16667f3..10e786f 100644
@@ -56,16 +56,17 @@
 #include <part.h>
 #include <usb.h>
 
-#undef USB_STOR_DEBUG
 #undef BBB_COMDAT_TRACE
 #undef BBB_XPORT_TRACE
 
 #ifdef	USB_STOR_DEBUG
-#define USB_STOR_PRINTF(fmt, args...)	printf(fmt , ##args)
+#define USB_BLK_DEBUG	1
 #else
-#define USB_STOR_PRINTF(fmt, args...)
+#define USB_BLK_DEBUG	0
 #endif
 
+#define USB_STOR_PRINTF(fmt, args...)	debug_cond(USB_BLK_DEBUG, fmt, ##args)
+
 #include <scsi.h>
 /* direction table -- this indicates the direction of the data
  * transfer for each command code -- a 1 indicates input
Signature · 1 line
1.7.6.3
#6 lore raw

PATCH 3/5 GCC4.6: Squash warning in usb_storage.c

Dear Marek Vasut,

Quoted 11 lines · In message <[email protected]> you wrote:

usb_storage.c: In function ?usb_stor_CB_reset?:
usb_storage.c:466:6: warning: variable ?result? set but not used [-Wunused-but-set-variable]

Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/usb_storage.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If I ever needed a brain transplant, I'd choose a teenager's  because
I'd want a brain that had never been used.
#7 lore raw

PATCH 4/5 GCC4.6: Squash subsequent warnings in usb_storage.c

In reply to Marek Vasut

usb_storage.c: In function ?us_one_transfer?:
usb_storage.c:377:7: warning: format ?%X? expects argument of type ?unsigned int?, but argument 2 has type ?long unsigned int? [-Wformat] usb_storage.c:389:6: warning: format ?%d? expects argument of type ?int?, but argument 2 has type ?long unsigned int? [-Wformat] usb_storage.c:394:6: warning: format ?%d? expects argument of type ?int?, but argument 2 has type ?long unsigned int? [-Wformat]
usb_storage.c: In function ?usb_stor_BBB_reset?:
usb_storage.c:442:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:448:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:454:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c: In function ?usb_stor_CB_reset?:
usb_storage.c:482:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c: In function ?usb_stor_CB_comdat?:
usb_storage.c:572:3: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:584:4: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c: In function ?usb_stor_BBB_transport?:
usb_storage.c:782:3: warning: format ?%d? expects argument of type ?int?, but argument 3 has type ?long unsigned int? [-Wformat]
usb_storage.c: In function ?usb_stor_CB_transport?:
usb_storage.c:807:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:830:3: warning: format ?%X? expects argument of type ?unsigned int?, but argument 2 has type ?long unsigned int? [-Wformat] usb_storage.c:857:3: warning: format ?%d? expects argument of type ?int?, but argument 2 has type ?long unsigned int? [-Wformat]

Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Remy Bohmer <[email protected]>
---
 common/usb_storage.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)
common/usb_storage.c +13 -13
index 10e786f..d9a2585 100644
@@ -373,7 +373,7 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
 					usb_clear_halt(us->pusb_dev, pipe);
 					us->pusb_dev->status = stat;
 					if (this_xfer == partial) {
-						USB_STOR_PRINTF("bulk transferred with error %X, but data ok\n", us->pusb_dev->status);
+						USB_STOR_PRINTF("bulk transferred with error %lX, but data ok\n", us->pusb_dev->status);
 						return 0;
 					}
 					else
@@ -385,12 +385,12 @@ static int us_one_transfer(struct us_data *us, int pipe, char *buf, int length)
 				}
 				USB_STOR_PRINTF("bulk transferred with error");
 				if (this_xfer == partial) {
-					USB_STOR_PRINTF(" %d, but data ok\n",
+					USB_STOR_PRINTF(" %ld, but data ok\n",
 							us->pusb_dev->status);
 					return 0;
 				}
 				/* if our try counter reaches 0, bail out */
-					USB_STOR_PRINTF(" %d, data %d\n",
+					USB_STOR_PRINTF(" %ld, data %d\n",
 						us->pusb_dev->status, partial);
 				if (!maxtry--)
 						return result;
@@ -438,19 +438,19 @@ static int usb_stor_BBB_reset(struct us_data *us)
 
 	/* long wait for reset */
 	wait_ms(150);
-	USB_STOR_PRINTF("BBB_reset result %d: status %X reset\n", result,
+	USB_STOR_PRINTF("BBB_reset result %d: status %lX reset\n", result,
 			us->pusb_dev->status);
 	pipe = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
 	result = usb_clear_halt(us->pusb_dev, pipe);
 	/* long wait for reset */
 	wait_ms(150);
-	USB_STOR_PRINTF("BBB_reset result %d: status %X clearing IN endpoint\n",
+	USB_STOR_PRINTF("BBB_reset result %d: status %lX clearing IN endpoint\n",
 			result, us->pusb_dev->status);
 	/* long wait for reset */
 	pipe = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
 	result = usb_clear_halt(us->pusb_dev, pipe);
 	wait_ms(150);
-	USB_STOR_PRINTF("BBB_reset result %d: status %X"
+	USB_STOR_PRINTF("BBB_reset result %d: status %lX"
 			" clearing OUT endpoint\n", result,
 			us->pusb_dev->status);
 	USB_STOR_PRINTF("BBB_reset done\n");
@@ -478,7 +478,7 @@ static int usb_stor_CB_reset(struct us_data *us)
 
 	/* long wait for reset */
 	wait_ms(1500);
-	USB_STOR_PRINTF("CB_reset result %d: status %X"
+	USB_STOR_PRINTF("CB_reset result %d: status %lX"
 			" clearing endpoint halt\n", result,
 			us->pusb_dev->status);
 	usb_clear_halt(us->pusb_dev, usb_rcvbulkpipe(us->pusb_dev, us->ep_in));
@@ -569,7 +569,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 					 srb->cmd, srb->cmdlen,
 					 USB_CNTL_TIMEOUT * 5);
 		USB_STOR_PRINTF("CB_transport: control msg returned %d,"
-				" status %X\n", result, us->pusb_dev->status);
+				" status %lX\n", result, us->pusb_dev->status);
 		/* check the return code for the command */
 		if (result < 0) {
 			if (us->pusb_dev->status & USB_ST_STALLED) {
@@ -581,7 +581,7 @@ int usb_stor_CB_comdat(ccb *srb, struct us_data *us)
 				us->pusb_dev->status = status;
 			}
 			USB_STOR_PRINTF(" error during command %02X"
-					" Stat = %X\n", srb->cmd[0],
+					" Stat = %lX\n", srb->cmd[0],
 					us->pusb_dev->status);
 			return result;
 		}
@@ -778,7 +778,7 @@ again:
 		usb_stor_BBB_reset(us);
 		return USB_STOR_TRANSPORT_FAILED;
 	} else if (data_actlen > srb->datalen) {
-		USB_STOR_PRINTF("transferred %dB instead of %dB\n",
+		USB_STOR_PRINTF("transferred %dB instead of %ldB\n",
 			data_actlen, srb->datalen);
 		return USB_STOR_TRANSPORT_FAILED;
 	} else if (csw.bCSWStatus == CSWSTATUS_FAILED) {
@@ -803,7 +803,7 @@ int usb_stor_CB_transport(ccb *srb, struct us_data *us)
 	/* issue the command */
 do_retry:
 	result = usb_stor_CB_comdat(srb, us);
-	USB_STOR_PRINTF("command / Data returned %d, status %X\n",
+	USB_STOR_PRINTF("command / Data returned %d, status %lX\n",
 			result, us->pusb_dev->status);
 	/* if this is an CBI Protocol, get IRQ */
 	if (us->protocol == US_PR_CBI) {
@@ -826,7 +826,7 @@ do_retry:
 	/* do we have to issue an auto request? */
 	/* HERE we have to check the result */
 	if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) {
-		USB_STOR_PRINTF("ERROR %X\n", us->pusb_dev->status);
+		USB_STOR_PRINTF("ERROR %lX\n", us->pusb_dev->status);
 		us->transport_reset(us);
 		return USB_STOR_TRANSPORT_ERROR;
 	}
@@ -853,7 +853,7 @@ do_retry:
 		status = usb_stor_CBI_get_status(psrb, us);
 
 	if ((result < 0) && !(us->pusb_dev->status & USB_ST_STALLED)) {
-		USB_STOR_PRINTF(" AUTO REQUEST ERROR %d\n",
+		USB_STOR_PRINTF(" AUTO REQUEST ERROR %ld\n",
 				us->pusb_dev->status);
 		return USB_STOR_TRANSPORT_ERROR;
 	}
Signature · 1 line
1.7.6.3
#8 lore raw

PATCH 4/5 GCC4.6: Squash subsequent warnings in usb_storage.c

Dear Marek Vasut,

Quoted 33 lines · In message <[email protected]> you wrote:

usb_storage.c: In function ?us_one_transfer?:
usb_storage.c:377:7: warning: format ?%X? expects argument of type ?unsigned int?, but argument 2 has type ?long unsigned int? [-Wformat] usb_storage.c:389:6: warning: format ?%d? expects argument of type ?int?, but argument 2 has type ?long unsigned int? [-Wformat] usb_storage.c:394:6: warning: format ?%d? expects argument of type ?int?, but argument 2 has type ?long unsigned int? [-Wformat]
usb_storage.c: In function ?usb_stor_BBB_reset?:
usb_storage.c:442:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:448:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:454:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c: In function ?usb_stor_CB_reset?:
usb_storage.c:482:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c: In function ?usb_stor_CB_comdat?:
usb_storage.c:572:3: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:584:4: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c: In function ?usb_stor_BBB_transport?:
usb_storage.c:782:3: warning: format ?%d? expects argument of type ?int?, but argument 3 has type ?long unsigned int? [-Wformat]
usb_storage.c: In function ?usb_stor_CB_transport?:
usb_storage.c:807:2: warning: format ?%X? expects argument of type ?unsigned int?, but argument 3 has type ?long unsigned int? [-Wformat] usb_storage.c:830:3: warning: format ?%X? expects argument of type ?unsigned int?, but argument 2 has type ?long unsigned int? [-Wformat] usb_storage.c:857:3: warning: format ?%d? expects argument of type ?int?, but argument 2 has type ?long unsigned int? [-Wformat]

Quoted 8 lines
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
Cc Remy Bohmer <[email protected]>
---
 common/usb_storage.c |   26 +++++++++++++-------------
 1 files changed, 13 insertions(+), 13 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Command, n.:
            Statement presented by a human and accepted by a computer
in such a manner as to make the human feel as if he is in control.
#9 lore raw

PATCH 5/5 GCC4.6: Squash undefined variable in cmd_mtdparts.c

In reply to Marek Vasut
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/cmd_mtdparts.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)
common/cmd_mtdparts.c +0 -2
index 2c2e4e0..b7c833b 100644
@@ -839,9 +839,7 @@ static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_
 	const char *mtd_id;
 	unsigned int mtd_id_len;
 	const char *p;
-#ifdef DEBUG
 	const char *pend;
-#endif
 	LIST_HEAD(tmp_list);
 	struct list_head *entry, *n;
 	u16 num_parts;
Signature · 1 line
1.7.6.3
#10 lore raw

PATCH 5/5 GCC4.6: Squash undefined variable in cmd_mtdparts.c

Dear Marek Vasut,

Quoted 7 lines · In message <[email protected]> you wrote:
Cc Wolfgang Denk <[email protected]>
Cc Simon Glass <[email protected]>
Cc Mike Frysinger <[email protected]>
---
 common/cmd_mtdparts.c |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If it has syntax, it isn't user friendly.