public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot-Users] [PATCH] The fdt boardsetup command criteria was not unique
@ 2008-06-07 16:29 Jerry Van Baren
  2008-06-09 18:16 ` Scott Wood
  0 siblings, 1 reply; 4+ messages in thread
From: Jerry Van Baren @ 2008-06-07 16:29 UTC (permalink / raw)
  To: u-boot

It was checking just for "b", which is not unique with respect to the
"boot" command.  Change to check for "boa"[rdsetup].

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---
 common/cmd_fdt.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index ede65ae..8592128 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -403,7 +403,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	}
 #ifdef CONFIG_OF_BOARD_SETUP
 	/* Call the board-specific fixup routine */
-	else if (argv[1][0] == 'b')
+	else if ((argv[1][0] == 'b') && (argv[1][1] == 'o') &&
+		   (argv[1][2] == 'a'))
 		ft_board_setup(fdt, gd->bd);
 #endif
 	/* Create a chosen node */
-- 
1.5.5.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot-Users] [PATCH] The fdt boardsetup command criteria was not unique
  2008-06-07 16:29 [U-Boot-Users] [PATCH] The fdt boardsetup command criteria was not unique Jerry Van Baren
@ 2008-06-09 18:16 ` Scott Wood
  2008-06-09 18:52   ` Jerry Van Baren
  2008-06-10  1:05   ` [U-Boot-Users] [PATCH] Use strncmp() for the fdt command Jerry Van Baren
  0 siblings, 2 replies; 4+ messages in thread
From: Scott Wood @ 2008-06-09 18:16 UTC (permalink / raw)
  To: u-boot

On Sat, Jun 07, 2008 at 12:29:26PM -0400, Jerry Van Baren wrote:
> diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
> index ede65ae..8592128 100644
> --- a/common/cmd_fdt.c
> +++ b/common/cmd_fdt.c
> @@ -403,7 +403,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
>  	}
>  #ifdef CONFIG_OF_BOARD_SETUP
>  	/* Call the board-specific fixup routine */
> -	else if (argv[1][0] == 'b')
> +	else if ((argv[1][0] == 'b') && (argv[1][1] == 'o') &&
> +		   (argv[1][2] == 'a'))
>  		ft_board_setup(fdt, gd->bd);
>  #endif

strncmp() would be clearer...

-Scott

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] [PATCH] The fdt boardsetup command criteria was not unique
  2008-06-09 18:16 ` Scott Wood
@ 2008-06-09 18:52   ` Jerry Van Baren
  2008-06-10  1:05   ` [U-Boot-Users] [PATCH] Use strncmp() for the fdt command Jerry Van Baren
  1 sibling, 0 replies; 4+ messages in thread
From: Jerry Van Baren @ 2008-06-09 18:52 UTC (permalink / raw)
  To: u-boot

Scott Wood wrote:
> On Sat, Jun 07, 2008 at 12:29:26PM -0400, Jerry Van Baren wrote:
>> diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
>> index ede65ae..8592128 100644
>> --- a/common/cmd_fdt.c
>> +++ b/common/cmd_fdt.c
>> @@ -403,7 +403,8 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
>>  	}
>>  #ifdef CONFIG_OF_BOARD_SETUP
>>  	/* Call the board-specific fixup routine */
>> -	else if (argv[1][0] == 'b')
>> +	else if ((argv[1][0] == 'b') && (argv[1][1] == 'o') &&
>> +		   (argv[1][2] == 'a'))
>>  		ft_board_setup(fdt, gd->bd);
>>  #endif
> 
> strncmp() would be clearer...
> 
> -Scott

Yeah, but that is the way the rest of them are.  :-/  Hmmm, looking at 
the other command/cmd_*.c files, it looks like my parsing 
character-by-character is in the minority vs. strncmp().

Best regards,
gvb

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot-Users] [PATCH] Use strncmp() for the fdt command
  2008-06-09 18:16 ` Scott Wood
  2008-06-09 18:52   ` Jerry Van Baren
@ 2008-06-10  1:05   ` Jerry Van Baren
  1 sibling, 0 replies; 4+ messages in thread
From: Jerry Van Baren @ 2008-06-10  1:05 UTC (permalink / raw)
  To: u-boot

Cleaner than doing multiple conditionals on characters.

Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
---

Per Scott Wood's suggestion.

gvb

 common/cmd_fdt.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c
index 8592128..4285a96 100644
--- a/common/cmd_fdt.c
+++ b/common/cmd_fdt.c
@@ -94,7 +94,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	/********************************************************************
 	 * Move the fdt
 	 ********************************************************************/
-	} else if ((argv[1][0] == 'm') && (argv[1][1] == 'o')) {
+	} else if (strncmp(argv[1], "mo", 2) == 0) {
 		struct fdt_header *newaddr;
 		int  len;
 		int  err;
@@ -144,7 +144,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	/********************************************************************
 	 * Make a new node
 	 ********************************************************************/
-	} else if ((argv[1][0] == 'm') && (argv[1][1] == 'k')) {
+	} else if (strncmp(argv[1], "mk", 2) == 0) {
 		char *pathp;		/* path */
 		char *nodep;		/* new node to add */
 		int  nodeoffset;	/* node offset from libfdt */
@@ -259,7 +259,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	/********************************************************************
 	 * Remove a property/node
 	 ********************************************************************/
-	} else if ((argv[1][0] == 'r') && (argv[1][1] == 'm')) {
+	} else if (strncmp(argv[1], "rm", 2) == 0) {
 		int  nodeoffset;	/* node offset from libfdt */
 		int  err;
 
@@ -323,15 +323,14 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	/********************************************************************
 	 * Set boot cpu id
 	 ********************************************************************/
-	} else if ((argv[1][0] == 'b') && (argv[1][1] == 'o') &&
-		   (argv[1][2] == 'o')) {
+	} else if (strncmp(argv[1], "boo", 3) == 0) {
 		unsigned long tmp = simple_strtoul(argv[2], NULL, 16);
 		fdt_set_boot_cpuid_phys(fdt, tmp);
 
 	/********************************************************************
 	 * memory command
 	 ********************************************************************/
-	} else if ((argv[1][0] == 'm') && (argv[1][1] == 'e')) {
+	} else if (strncmp(argv[1], "me", 2) == 0) {
 		uint64_t addr, size;
 		int err;
 #ifdef CFG_64BIT_STRTOUL
@@ -348,7 +347,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	/********************************************************************
 	 * mem reserve commands
 	 ********************************************************************/
-	} else if ((argv[1][0] == 'r') && (argv[1][1] == 's')) {
+	} else if (strncmp(argv[1], "rs", 2) == 0) {
 		if (argv[2][0] == 'p') {
 			uint64_t addr, size;
 			int total = fdt_num_mem_rsv(fdt);
@@ -403,8 +402,7 @@ int do_fdt (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	}
 #ifdef CONFIG_OF_BOARD_SETUP
 	/* Call the board-specific fixup routine */
-	else if ((argv[1][0] == 'b') && (argv[1][1] == 'o') &&
-		   (argv[1][2] == 'a'))
+	else if (strncmp(argv[1], "boa", 3) == 0)
 		ft_board_setup(fdt, gd->bd);
 #endif
 	/* Create a chosen node */
-- 
1.5.5.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-10  1:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-07 16:29 [U-Boot-Users] [PATCH] The fdt boardsetup command criteria was not unique Jerry Van Baren
2008-06-09 18:16 ` Scott Wood
2008-06-09 18:52   ` Jerry Van Baren
2008-06-10  1:05   ` [U-Boot-Users] [PATCH] Use strncmp() for the fdt command Jerry Van Baren

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox