Skip to contentSkip to conversation

Fix warning differ in signedness in common/cmd_ide.c

PATCH New Jean-Christophe PLAGNIOL-VILLARD 4 participants 11 messages Nov 7, 2007 – Nov 18, 2007 Networking

lore
Share & tools
lore
#0 lore raw

cover Fix warning differ in signedness in common/cmd_ide.c

common/cmd_ide.c +6 -6
index bb064ea..27cecac 100644
@@ -1136,9 +1136,9 @@ static void ide_ident (block_dev_desc_t *dev_desc)
 
 	input_swap_data (device, iobuf, ATA_SECTORWORDS);
 
-	ident_cpy (dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision));
-	ident_cpy (dev_desc->vendor, iop->model, sizeof(dev_desc->vendor));
-	ident_cpy (dev_desc->product, iop->serial_no, sizeof(dev_desc->product));
+	ident_cpy ((unsigned char*)dev_desc->revision, iop->fw_rev, sizeof(dev_desc->revision));
+	ident_cpy ((unsigned char*)dev_desc->vendor, iop->model, sizeof(dev_desc->vendor));
+	ident_cpy ((unsigned char*)dev_desc->product, iop->serial_no, sizeof(dev_desc->product));
 #ifdef __LITTLE_ENDIAN
 	/*
 	 * firmware revision and model number have Big Endian Byte
@@ -1953,9 +1953,9 @@ static void	atapi_inquiry(block_dev_desc_t * dev_desc)
 		return;
 
 	/* copy device ident strings */
-	ident_cpy(dev_desc->vendor,&iobuf[8],8);
-	ident_cpy(dev_desc->product,&iobuf[16],16);
-	ident_cpy(dev_desc->revision,&iobuf[32],5);
+	ident_cpy((unsigned char*)dev_desc->vendor,&iobuf[8],8);
+	ident_cpy((unsigned char*)dev_desc->product,&iobuf[16],16);
+	ident_cpy((unsigned char*)dev_desc->revision,&iobuf[32],5);
 
 	dev_desc->lun=0;
 	dev_desc->lba=0;
Signature · 1 line
1.5.3.2
#1 lore raw

PATCH 1/2 Fix warning differ in signedness on NetSetTimeout in net/net.c and net/nfs.c

net/net.c +1 -1
index cde2680..f3c70c5 100644
@@ -598,7 +598,7 @@ void NetStartAgain (void)
 	if (NetRestartWrap) {
 		NetRestartWrap = 0;
 		if (NetDevExists && !once) {
-			NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
+			NetSetTimeout ((ulong)10 * CFG_HZ, startAgainTimeout);
 			NetSetHandler (startAgainHandler);
 		} else {
 			NetState = NETLOOP_FAIL;
net/nfs.c +2 -2
index 1b27c97..18b00cc 100644
@@ -669,7 +669,7 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
 
 	case STATE_READ_REQ:
 		rlen = nfs_read_reply (pkt, len);
-		NetSetTimeout (NFS_TIMEOUT * CFG_HZ, NfsTimeout);
+		NetSetTimeout ((ulong)NFS_TIMEOUT * CFG_HZ, NfsTimeout);
 		if (rlen > 0) {
 			nfs_offset += rlen;
 			NfsSend ();
@@ -758,7 +758,7 @@ NfsStart (void)
 	printf ("\nLoad address: 0x%lx\n"
 		"Loading: *\b", load_addr);
 
-	NetSetTimeout (NFS_TIMEOUT * CFG_HZ, NfsTimeout);
+	NetSetTimeout ((ulong)NFS_TIMEOUT * CFG_HZ, NfsTimeout);
 	NetSetHandler (NfsHandler);
 
 	NfsTimeoutCount = 0;
Signature · 1 line
1.5.3.2
#2 lore raw

PATCH 2/2 Fix warning: pointer targets in assignment differ in signedness

board/purple/flash.c +1 -1
index 7522580..1baae35 100644
@@ -299,7 +299,7 @@ void flash_print_info (flash_info_t *info)
 	int i;
 	uchar *boottype;
 	uchar *bootletter;
-	uchar *fmt;
+	char *fmt;
 	uchar botbootletter[] = "B";
 	uchar topbootletter[] = "T";
 	uchar botboottype[] = "bottom boot sector";
Signature · 1 line
1.5.3.2
#3 lore raw

PATCH 1/2 Fix warning differ in signedness on NetSetTimeout in net/net.c and net/nfs.c

In reply to Jean-Christophe PLAGNIOL-VILLARD
Quoted 7 lines · In message <[email protected]> you wrote:
net/net.c +0 -0
index cde2680..f3c70c5 100644

net/net.c void NetStartAgain (void) · line 604

Quoted 8 lines
net/net.c +1 -1
@@ -598,7 +598,7 @@ void NetStartAgain (void)
 	if (NetRestartWrap) {
 		NetRestartWrap = 0;
 		if (NetDevExists && !once) {
-			NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
+			NetSetTimeout ((ulong)10 * CFG_HZ, startAgainTimeout);
 			NetSetHandler (startAgainHandler);
 		} else {
 			NetState = NETLOOP_FAIL;

This doesn't look right to me.

Instead of "(ulong)10 * CFG_HZ" we should probably write "10UL * CFG_HZ"

And, why do we cast the first operand to "ulong" - and not the second one, or the second one, too, or the result?

Finally, this is not the only place where this construct is used:

-> grep -n CFG_HZ net/net.c
253: if ((t - NetArpWaitTimerStart) > ARP_TIMEOUT * CFG_HZ) {
592: NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
601: NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
777: NetSetTimeout (10 * CFG_HZ, PingTimeout);
800:#define CDP_TIMEOUT (CFG_HZ/4) /* one packet every 250ms */

Quoted 14 lines
net/nfs.c +1 -1
index 1b27c97..18b00cc 100644
@@ -669,7 +669,7 @@ NfsHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len)
 
 	case STATE_READ_REQ:
 		rlen = nfs_read_reply (pkt, len);
-		NetSetTimeout (NFS_TIMEOUT * CFG_HZ, NfsTimeout);
+		NetSetTimeout ((ulong)NFS_TIMEOUT * CFG_HZ, NfsTimeout);
 		if (rlen > 0) {
 			nfs_offset += rlen;
 			NfsSend ();

net/nfs.c NfsStart (void) · line 764

Quoted 8 lines
net/nfs.c +1 -1
@@ -758,7 +758,7 @@ NfsStart (void)
 	printf ("\nLoad address: 0x%lx\n"
 		"Loading: *\b", load_addr);
 
-	NetSetTimeout (NFS_TIMEOUT * CFG_HZ, NfsTimeout);
+	NetSetTimeout ((ulong)NFS_TIMEOUT * CFG_HZ, NfsTimeout);
 	NetSetHandler (NfsHandler);
 
 	NfsTimeoutCount = 0;

The first two questions from above apply here, too.

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
Status quo. Latin for "the mess we're in."
#4 lore raw

PATCH 1/1 Fix warning differ in signedness in net/net.c and net/nfs.c

net/bootp.c +1 -1
index 55dcc81..89e30d2 100644
@@ -33,7 +33,7 @@
 
 #if defined(CONFIG_CMD_NET)
 
-#define TIMEOUT		5		/* Seconds before trying BOOTP again	*/
+#define TIMEOUT		5UL		/* Seconds before trying BOOTP again	*/
 #ifndef CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT	5		/* # of timeouts before giving up  */
 #else
net/bootp.h +1 -1
index ba9826e..320cc3b 100644
@@ -88,7 +88,7 @@ typedef enum { INIT,
 #define DHCP_NAK      6
 #define DHCP_RELEASE  7
 
-#define SELECT_TIMEOUT 3	/* Seconds to wait for offers */
+#define SELECT_TIMEOUT 3UL	/* Seconds to wait for offers */
 
 /**********************************************************************/
 
net/net.c +4 -4
index cde2680..c719bc4 100644
@@ -94,7 +94,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define ARP_TIMEOUT		5		/* Seconds before trying ARP again */
+#define ARP_TIMEOUT		5UL		/* Seconds before trying ARP again */
 #ifndef	CONFIG_NET_RETRY_COUNT
 # define ARP_TIMEOUT_COUNT	5		/* # of timeouts before giving up  */
 #else
@@ -589,7 +589,7 @@ void NetStartAgain (void)
 		return;
 	}
 #ifndef CONFIG_NET_MULTI
-	NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
+	NetSetTimeout (10UL * CFG_HZ, startAgainTimeout);
 	NetSetHandler (startAgainHandler);
 #else	/* !CONFIG_NET_MULTI*/
 	eth_halt ();
@@ -598,7 +598,7 @@ void NetStartAgain (void)
 	if (NetRestartWrap) {
 		NetRestartWrap = 0;
 		if (NetDevExists && !once) {
-			NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
+			NetSetTimeout (10UL * CFG_HZ, startAgainTimeout);
 			NetSetHandler (startAgainHandler);
 		} else {
 			NetState = NETLOOP_FAIL;
@@ -774,7 +774,7 @@ static void PingStart(void)
 #if defined(CONFIG_NET_MULTI)
 	printf ("Using %s device\n", eth_get_name());
 #endif	/* CONFIG_NET_MULTI */
-	NetSetTimeout (10 * CFG_HZ, PingTimeout);
+	NetSetTimeout (10UL * CFG_HZ, PingTimeout);
 	NetSetHandler (PingHandler);
 
 	PingSend();
net/nfs.c +1 -1
index 1b27c97..aa8d612 100644
@@ -34,7 +34,7 @@
 #if defined(CONFIG_CMD_NET) && defined(CONFIG_CMD_NFS)
 
 #define HASHES_PER_LINE 65	/* Number of "loading" hashes per line	*/
-#define NFS_TIMEOUT 60
+#define NFS_TIMEOUT 60UL
 
 static int fs_mounted = 0;
 static unsigned long rpc_id = 0;
net/rarp.c +1 -1
index 21dfa52..ecf38e4 100644
@@ -31,7 +31,7 @@
 
 #if defined(CONFIG_CMD_NET)
 
-#define TIMEOUT		5		/* Seconds before trying BOOTP again */
+#define TIMEOUT		5UL		/* Seconds before trying BOOTP again */
 #ifndef	CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT	5		/* # of timeouts before giving up  */
 #else
net/tftp.c +1 -1
index 5ee7676..8b95bcf 100644
@@ -15,7 +15,7 @@
 #if defined(CONFIG_CMD_NET)
 
 #define WELL_KNOWN_PORT	69		/* Well known TFTP port #		*/
-#define TIMEOUT		5		/* Seconds to timeout for a lost pkt	*/
+#define TIMEOUT		5UL		/* Seconds to timeout for a lost pkt	*/
 #ifndef	CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT	10		/* # of timeouts before giving up  */
 #else
Signature · 1 line
1.5.3.2
#5 lore raw

PATCH 1/1 Fix warning differ in signedness in net/net.c and net/nfs.c

net/bootp.c

Quoted 2 lines · In message <[email protected]> you wrote:
net/bootp.c +0 -0

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
[Doctors and Bartenders], We both get the same two kinds of customers
-- the living and the dying.
	-- Dr. Boyce, "The Menagerie" ("The Cage"), stardate unknown
#6 lore raw

PATCH 1/1 Fix warning differ in signedness in net/net.c and net/nfs.c

In reply to Wolfgang Denk

Fix warning integer overflow in expressioni bootp.c, rarp.c and tftp.c

net/bootp.c +1 -1
index 55dcc81..89e30d2 100644
@@ -33,7 +33,7 @@
 
 #if defined(CONFIG_CMD_NET)
 
-#define TIMEOUT		5		/* Seconds before trying BOOTP again	*/
+#define TIMEOUT		5UL		/* Seconds before trying BOOTP again	*/
 #ifndef CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT	5		/* # of timeouts before giving up  */
 #else
net/bootp.h +1 -1
index ba9826e..320cc3b 100644
@@ -88,7 +88,7 @@ typedef enum { INIT,
 #define DHCP_NAK      6
 #define DHCP_RELEASE  7
 
-#define SELECT_TIMEOUT 3	/* Seconds to wait for offers */
+#define SELECT_TIMEOUT 3UL	/* Seconds to wait for offers */
 
 /**********************************************************************/
 
net/net.c +4 -4
index cde2680..c719bc4 100644
@@ -94,7 +94,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define ARP_TIMEOUT		5		/* Seconds before trying ARP again */
+#define ARP_TIMEOUT		5UL		/* Seconds before trying ARP again */
 #ifndef	CONFIG_NET_RETRY_COUNT
 # define ARP_TIMEOUT_COUNT	5		/* # of timeouts before giving up  */
 #else
@@ -589,7 +589,7 @@ void NetStartAgain (void)
 		return;
 	}
 #ifndef CONFIG_NET_MULTI
-	NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
+	NetSetTimeout (10UL * CFG_HZ, startAgainTimeout);
 	NetSetHandler (startAgainHandler);
 #else	/* !CONFIG_NET_MULTI*/
 	eth_halt ();
@@ -598,7 +598,7 @@ void NetStartAgain (void)
 	if (NetRestartWrap) {
 		NetRestartWrap = 0;
 		if (NetDevExists && !once) {
-			NetSetTimeout (10 * CFG_HZ, startAgainTimeout);
+			NetSetTimeout (10UL * CFG_HZ, startAgainTimeout);
 			NetSetHandler (startAgainHandler);
 		} else {
 			NetState = NETLOOP_FAIL;
@@ -774,7 +774,7 @@ static void PingStart(void)
 #if defined(CONFIG_NET_MULTI)
 	printf ("Using %s device\n", eth_get_name());
 #endif	/* CONFIG_NET_MULTI */
-	NetSetTimeout (10 * CFG_HZ, PingTimeout);
+	NetSetTimeout (10UL * CFG_HZ, PingTimeout);
 	NetSetHandler (PingHandler);
 
 	PingSend();
net/nfs.c +1 -1
index 1b27c97..aa8d612 100644
@@ -34,7 +34,7 @@
 #if defined(CONFIG_CMD_NET) && defined(CONFIG_CMD_NFS)
 
 #define HASHES_PER_LINE 65	/* Number of "loading" hashes per line	*/
-#define NFS_TIMEOUT 60
+#define NFS_TIMEOUT 60UL
 
 static int fs_mounted = 0;
 static unsigned long rpc_id = 0;
net/rarp.c +1 -1
index 21dfa52..ecf38e4 100644
@@ -31,7 +31,7 @@
 
 #if defined(CONFIG_CMD_NET)
 
-#define TIMEOUT		5		/* Seconds before trying BOOTP again */
+#define TIMEOUT		5UL		/* Seconds before trying BOOTP again */
 #ifndef	CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT	5		/* # of timeouts before giving up  */
 #else
net/tftp.c +1 -1
index 5ee7676..8b95bcf 100644
@@ -15,7 +15,7 @@
 #if defined(CONFIG_CMD_NET)
 
 #define WELL_KNOWN_PORT	69		/* Well known TFTP port #		*/
-#define TIMEOUT		5		/* Seconds to timeout for a lost pkt	*/
+#define TIMEOUT		5UL		/* Seconds to timeout for a lost pkt	*/
 #ifndef	CONFIG_NET_RETRY_COUNT
 # define TIMEOUT_COUNT	10		/* # of timeouts before giving up  */
 #else
Signature · 1 line
1.5.3.2
#7 lore raw

PATCH 1/1 Fix warning differ in signedness in net/net.c and net/nfs.c

net/bootp.c

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

Fix warning integer overflow in expressioni bootp.c, rarp.c and tftp.c

net/bootp.c +0 -0
index 55dcc81..89e30d2 100644

Umm...

error: patch failed: net/bootp.c:33
error: net/bootp.c: patch does not apply
error: patch failed: net/bootp.h:88
error: net/bootp.h: patch does not apply
error: patch failed: net/net.c:94
error: net/net.c: patch does not apply
error: patch failed: net/nfs.c:34
error: net/nfs.c: patch does not apply
error: patch failed: net/rarp.c:31
error: net/rarp.c: patch does not apply
error: patch failed: net/tftp.c:15
error: net/tftp.c: patch does not apply
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.

Please check!!

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
Microsoft Multimedia:
You have nice graphics, sound and animations when the system crashes.
#8 lore raw

cover Fix warning differ in signedness in common/cmd_ide.c

In reply to Jean-Christophe PLAGNIOL-VILLARD

Hi J

Please excuse my ignorance. Your patch is of course the right fix and I verified it on my ARM boards.
A great thank you for providing the right fix and doing it so quickly.

Cheers

Marcel

#9 lore raw

[U-Boot-Users] at91rm9200 RTC

Hi:

does anybody know any errata regarding at91rm9200 internal RTC? Somehow I can set it only once. After that ACKUPD bit remains ON forver and RTC calendar register cannot be modified.

Thanks,

Leonid.

#10 lore raw

cover Fix warning differ in signedness in common/cmd_ide.c

In reply to Jean-Christophe PLAGNIOL-VILLARD

common/cmd_ide.c

Quoted 4 lines · In message <[email protected]> you wrote:
common/cmd_ide.c +0 -0
index bb064ea..27cecac 100644

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
Military secrets are the most fleeting of all.
	-- Spock, "The Enterprise Incident", stardate 5027.4