All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cmd: return code when tlv_eeprom incorrectly called
@ 2023-01-27 21:49 Heinrich Schuchardt
  2023-01-29 16:16 ` Baruch Siach
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2023-01-27 21:49 UTC (permalink / raw)
  To: Stefan Roese; +Cc: u-boot, Baruch Siach, Heinrich Schuchardt

A command called with incorrect parameters should set $? to 1 (false).
Instead of calling cmd_usage(cmdtp) and then returning 0 just return
CMD_RET_FAILURE.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
---
 cmd/tlv_eeprom.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
index bf8d453dc5..4591ff336b 100644
--- a/cmd/tlv_eeprom.c
+++ b/cmd/tlv_eeprom.c
@@ -479,17 +479,14 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 			show_tlv_devices();
 			break;
 		default:
-			cmd_usage(cmdtp);
-			break;
+			return CMD_RET_USAGE;
 		}
 		return 0;
 	}
 
 	// The set command takes one or two args.
-	if (argc > 4) {
-		cmd_usage(cmdtp);
-		return 0;
-	}
+	if (argc > 4)
+		return CMD_RET_USAGE;
 
 	// Set command. If the TLV exists in the EEPROM, delete it. Then if
 	// data was supplied for this TLV add the TLV with the new contents at
@@ -512,7 +509,7 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 		current_dev = devnum;
 		has_been_read = 0;
 	} else {
-		cmd_usage(cmdtp);
+		return CMD_RET_USAGE;
 	}
 
 	return 0;
-- 
2.38.1


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

* Re: [PATCH] cmd: return code when tlv_eeprom incorrectly called
  2023-01-27 21:49 [PATCH] cmd: return code when tlv_eeprom incorrectly called Heinrich Schuchardt
@ 2023-01-29 16:16 ` Baruch Siach
  2023-01-30  6:06 ` Stefan Roese
  2023-02-13 13:58 ` Stefan Roese
  2 siblings, 0 replies; 4+ messages in thread
From: Baruch Siach @ 2023-01-29 16:16 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: Stefan Roese, u-boot

Hi Heinrich,

On Fri, Jan 27 2023, Heinrich Schuchardt wrote:
> A command called with incorrect parameters should set $? to 1 (false).
> Instead of calling cmd_usage(cmdtp) and then returning 0 just return
> CMD_RET_FAILURE.
>
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Acked-by: Baruch Siach <baruch@tkos.co.il>

Thanks,
baruch

> ---
>  cmd/tlv_eeprom.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
> index bf8d453dc5..4591ff336b 100644
> --- a/cmd/tlv_eeprom.c
> +++ b/cmd/tlv_eeprom.c
> @@ -479,17 +479,14 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  			show_tlv_devices();
>  			break;
>  		default:
> -			cmd_usage(cmdtp);
> -			break;
> +			return CMD_RET_USAGE;
>  		}
>  		return 0;
>  	}
>  
>  	// The set command takes one or two args.
> -	if (argc > 4) {
> -		cmd_usage(cmdtp);
> -		return 0;
> -	}
> +	if (argc > 4)
> +		return CMD_RET_USAGE;
>  
>  	// Set command. If the TLV exists in the EEPROM, delete it. Then if
>  	// data was supplied for this TLV add the TLV with the new contents at
> @@ -512,7 +509,7 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>  		current_dev = devnum;
>  		has_been_read = 0;
>  	} else {
> -		cmd_usage(cmdtp);
> +		return CMD_RET_USAGE;
>  	}
>  
>  	return 0;


-- 
                                                     ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

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

* Re: [PATCH] cmd: return code when tlv_eeprom incorrectly called
  2023-01-27 21:49 [PATCH] cmd: return code when tlv_eeprom incorrectly called Heinrich Schuchardt
  2023-01-29 16:16 ` Baruch Siach
@ 2023-01-30  6:06 ` Stefan Roese
  2023-02-13 13:58 ` Stefan Roese
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2023-01-30  6:06 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: u-boot, Baruch Siach

On 1/27/23 22:49, Heinrich Schuchardt wrote:
> A command called with incorrect parameters should set $? to 1 (false).
> Instead of calling cmd_usage(cmdtp) and then returning 0 just return
> CMD_RET_FAILURE.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
>   cmd/tlv_eeprom.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
> index bf8d453dc5..4591ff336b 100644
> --- a/cmd/tlv_eeprom.c
> +++ b/cmd/tlv_eeprom.c
> @@ -479,17 +479,14 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>   			show_tlv_devices();
>   			break;
>   		default:
> -			cmd_usage(cmdtp);
> -			break;
> +			return CMD_RET_USAGE;
>   		}
>   		return 0;
>   	}
>   
>   	// The set command takes one or two args.
> -	if (argc > 4) {
> -		cmd_usage(cmdtp);
> -		return 0;
> -	}
> +	if (argc > 4)
> +		return CMD_RET_USAGE;
>   
>   	// Set command. If the TLV exists in the EEPROM, delete it. Then if
>   	// data was supplied for this TLV add the TLV with the new contents at
> @@ -512,7 +509,7 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>   		current_dev = devnum;
>   		has_been_read = 0;
>   	} else {
> -		cmd_usage(cmdtp);
> +		return CMD_RET_USAGE;
>   	}
>   
>   	return 0;

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

* Re: [PATCH] cmd: return code when tlv_eeprom incorrectly called
  2023-01-27 21:49 [PATCH] cmd: return code when tlv_eeprom incorrectly called Heinrich Schuchardt
  2023-01-29 16:16 ` Baruch Siach
  2023-01-30  6:06 ` Stefan Roese
@ 2023-02-13 13:58 ` Stefan Roese
  2 siblings, 0 replies; 4+ messages in thread
From: Stefan Roese @ 2023-02-13 13:58 UTC (permalink / raw)
  To: Heinrich Schuchardt; +Cc: u-boot, Baruch Siach

On 1/27/23 22:49, Heinrich Schuchardt wrote:
> A command called with incorrect parameters should set $? to 1 (false).
> Instead of calling cmd_usage(cmdtp) and then returning 0 just return
> CMD_RET_FAILURE.
> 
> Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>

Applied to u-boot-marvell/master

Thanks,
Stefan

> ---
>   cmd/tlv_eeprom.c | 11 ++++-------
>   1 file changed, 4 insertions(+), 7 deletions(-)
> 
> diff --git a/cmd/tlv_eeprom.c b/cmd/tlv_eeprom.c
> index bf8d453dc5..4591ff336b 100644
> --- a/cmd/tlv_eeprom.c
> +++ b/cmd/tlv_eeprom.c
> @@ -479,17 +479,14 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>   			show_tlv_devices();
>   			break;
>   		default:
> -			cmd_usage(cmdtp);
> -			break;
> +			return CMD_RET_USAGE;
>   		}
>   		return 0;
>   	}
>   
>   	// The set command takes one or two args.
> -	if (argc > 4) {
> -		cmd_usage(cmdtp);
> -		return 0;
> -	}
> +	if (argc > 4)
> +		return CMD_RET_USAGE;
>   
>   	// Set command. If the TLV exists in the EEPROM, delete it. Then if
>   	// data was supplied for this TLV add the TLV with the new contents at
> @@ -512,7 +509,7 @@ int do_tlv_eeprom(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
>   		current_dev = devnum;
>   		has_been_read = 0;
>   	} else {
> -		cmd_usage(cmdtp);
> +		return CMD_RET_USAGE;
>   	}
>   
>   	return 0;

Viele Grüße,
Stefan Roese

-- 
DENX Software Engineering GmbH,      Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de

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

end of thread, other threads:[~2023-02-13 14:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27 21:49 [PATCH] cmd: return code when tlv_eeprom incorrectly called Heinrich Schuchardt
2023-01-29 16:16 ` Baruch Siach
2023-01-30  6:06 ` Stefan Roese
2023-02-13 13:58 ` Stefan Roese

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.