[PATCH] cmd: improve string matching for hex

Match the "=0x" instead of just "=0".
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org --- We sometimes two character partial matching for commands so people can type "re" instead of "read". But here reading two characters doesn't seem correct.
cmd/nvedit_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 24944ab81e23..7a30b5cc8f87 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -262,7 +262,7 @@ static int append_value(char **bufp, size_t *sizep, char *data) char *tmp_buf = NULL, *new_buf = NULL, *value; unsigned long len = 0;
- if (!strncmp(data, "=0x", 2)) { /* hexadecimal number */ + if (!strncmp(data, "=0x", 3)) { /* hexadecimal number */ union { u8 u8; u16 u16;

On 31.07.23 16:03, Dan Carpenter wrote:
Match the "=0x" instead of just "=0".
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org
We sometimes two character partial matching for commands so people can type "re" instead of "read". But here reading two characters doesn't seem correct.
cmd/nvedit_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 24944ab81e23..7a30b5cc8f87 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -262,7 +262,7 @@ static int append_value(char **bufp, size_t *sizep, char *data) char *tmp_buf = NULL, *new_buf = NULL, *value; unsigned long len = 0;
- if (!strncmp(data, "=0x", 2)) { /* hexadecimal number */
- if (!strncmp(data, "=0x", 3)) { /* hexadecimal number */ union { u8 u8; u16 u16;
Looking at doc/usage/cmd/env.rst, the different value formats supported by append_value() are not described at all.
Reviewed-by: Heinrich.Schuchardt xypron.glpk@gmx.de

On Mon, 31 Jul 2023 at 08:04, Dan Carpenter dan.carpenter@linaro.org wrote:
Match the "=0x" instead of just "=0".
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org
We sometimes two character partial matching for commands so people can type "re" instead of "read". But here reading two characters doesn't seem correct.
cmd/nvedit_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, 31 Jul 2023 at 20:08, Simon Glass sjg@google.com wrote:
On Mon, 31 Jul 2023 at 08:04, Dan Carpenter dan.carpenter@linaro.org wrote:
Match the "=0x" instead of just "=0".
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org
We sometimes two character partial matching for commands so people can type "re" instead of "read". But here reading two characters doesn't seem correct.
cmd/nvedit_efi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org

On Mon, Jul 31, 2023 at 05:03:59PM +0300, Dan Carpenter wrote:
Match the "=0x" instead of just "=0".
Signed-off-by: Dan Carpenter dan.carpenter@linaro.org Reviewed-by: Heinrich.Schuchardt xypron.glpk@gmx.de Reviewed-by: Simon Glass sjg@chromium.org Reviewed-by: Ilias Apalodimas ilias.apalodimas@linaro.org
Applied to u-boot/next, thanks!
participants (5)
-
Dan Carpenter
-
Heinrich Schuchardt
-
Ilias Apalodimas
-
Simon Glass
-
Tom Rini