From: Baruch Siach <baruch@tkos.co.il>
To: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Cc: Stefan Roese <sr@denx.de>, u-boot@lists.denx.de
Subject: Re: [PATCH] cmd: return code when tlv_eeprom incorrectly called
Date: Sun, 29 Jan 2023 18:16:58 +0200 [thread overview]
Message-ID: <87bkmhxqkh.fsf@tarshish> (raw)
In-Reply-To: <20230127214910.61204-1-heinrich.schuchardt@canonical.com>
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 -
next prev parent reply other threads:[~2023-01-29 16:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 21:49 [PATCH] cmd: return code when tlv_eeprom incorrectly called Heinrich Schuchardt
2023-01-29 16:16 ` Baruch Siach [this message]
2023-01-30 6:06 ` Stefan Roese
2023-02-13 13:58 ` Stefan Roese
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bkmhxqkh.fsf@tarshish \
--to=baruch@tkos.co.il \
--cc=heinrich.schuchardt@canonical.com \
--cc=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox