Patchwork [U-Boot,4/4] mpc8323erdb: Update crc32 check of MAC

login
register
mail settings
Submitter Tom Rini
Date May 13, 2013, 8:31 p.m.
Message ID <1368477117-32669-4-git-send-email-trini@ti.com>
Download mbox | patch
Permalink /patch/243531/
State Changes Requested
Delegated to: Wolfgang Denk
Headers show

Comments

Tom Rini - May 13, 2013, 8:31 p.m.
We need to cast to unsigned char, not unsigned short here to avoid a
warning.

Cc: Michael Barkowski <michael.barkowski@freescale.com>
Signed-off-by: Tom Rini <trini@ti.com>
---
 board/freescale/mpc8323erdb/mpc8323erdb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Wolfgang Denk - May 13, 2013, 10:38 p.m.
Dear Tom Rini,

In message <1368477117-32669-4-git-send-email-trini@ti.com> you wrote:
> We need to cast to unsigned char, not unsigned short here to avoid a
> warning.

You fix the warning, but break the code.

> Cc: Michael Barkowski <michael.barkowski@freescale.com>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
>  board/freescale/mpc8323erdb/mpc8323erdb.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c b/board/freescale/mpc8323erdb/mpc8323erdb.c
> index f29b2f4..ba4993e 100644
> --- a/board/freescale/mpc8323erdb/mpc8323erdb.c
> +++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
> @@ -195,7 +195,7 @@ int mac_read_from_eeprom(void)
>  		printf("\nEEPROM @ 0x%02x read FAILED!!!\n",
>  		       CONFIG_SYS_I2C_EEPROM_ADDR);
>  	} else {
> -		if (crc32(crc, buf, 24) == *(unsigned int *)&buf[24]) {
> +		if (crc32(crc, buf, 24) == *(unsigned char *)&buf[24]) {

We need to read a 32 bit number here.

Best regards,

Wolfgang Denk

Patch

diff --git a/board/freescale/mpc8323erdb/mpc8323erdb.c b/board/freescale/mpc8323erdb/mpc8323erdb.c
index f29b2f4..ba4993e 100644
--- a/board/freescale/mpc8323erdb/mpc8323erdb.c
+++ b/board/freescale/mpc8323erdb/mpc8323erdb.c
@@ -195,7 +195,7 @@  int mac_read_from_eeprom(void)
 		printf("\nEEPROM @ 0x%02x read FAILED!!!\n",
 		       CONFIG_SYS_I2C_EEPROM_ADDR);
 	} else {
-		if (crc32(crc, buf, 24) == *(unsigned int *)&buf[24]) {
+		if (crc32(crc, buf, 24) == *(unsigned char *)&buf[24]) {
 			printf("Reading MAC from EEPROM\n");
 			for (i = 0; i < 4; i++) {
 				if (memcmp(&buf[i * 6], "\0\0\0\0\0\0", 6)) {