diff mbox

[U-Boot,v2,16/32] dm: cbfs: Fix handling of invalid type

Message ID 1456784765-10788-17-git-send-email-sjg@chromium.org
State Accepted
Commit a696d768c1274d667be86abe72869461b9fe0073
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass Feb. 29, 2016, 10:25 p.m. UTC
The comment for file_cbfs_type() says that it returns 0 for an invalid type.
The code appears to check for -1, except that it uses an unsigned variable
to store the type. This results in a warning on 64-bit machines.

Adjust it to make the meaning clearer. Continue to handle the -1 case since
it may be needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Bring the 'case 0' from a later patch into this one

 cmd/cbfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Simon Glass March 13, 2016, 1:53 a.m. UTC | #1
On 29 February 2016 at 15:25, Simon Glass <sjg@chromium.org> wrote:
> The comment for file_cbfs_type() says that it returns 0 for an invalid type.
> The code appears to check for -1, except that it uses an unsigned variable
> to store the type. This results in a warning on 64-bit machines.
>
> Adjust it to make the meaning clearer. Continue to handle the -1 case since
> it may be needed.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2:
> - Bring the 'case 0' from a later patch into this one
>
>  cmd/cbfs.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied to u-boot-dm/next.
diff mbox

Patch

diff --git a/cmd/cbfs.c b/cmd/cbfs.c
index 35d8a7a..779e9c0 100644
--- a/cmd/cbfs.c
+++ b/cmd/cbfs.c
@@ -103,7 +103,7 @@  int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 	printf("     size              type  name\n");
 	printf("------------------------------------------\n");
 	while (file) {
-		u32 type = file_cbfs_type(file);
+		int type = file_cbfs_type(file);
 		char *type_name = NULL;
 		const char *filename = file_cbfs_name(file);
 
@@ -140,7 +140,8 @@  int do_cbfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 		case CBFS_COMPONENT_CMOS_LAYOUT:
 			type_name = "cmos layout";
 			break;
-		case -1UL:
+		case -1:
+		case 0:
 			type_name = "null";
 			break;
 		}