[PATCH v2 4/8] cmd/command.c: relax length check in cmd_get_data_size()

Rasmus Villemoes rasmus.villemoes at prevas.dk
Wed Jan 3 11:47:06 CET 2024


Just check that the length is at least 2. This allows passing strings
like ".b", which can be convenient when constructing
tests (i.e. parametrizing the suffix used).

Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
---
 common/command.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/command.c b/common/command.c
index 474ac98bc38..f0354f41644 100644
--- a/common/command.c
+++ b/common/command.c
@@ -471,7 +471,7 @@ int cmd_get_data_size(const char *arg, int default_size)
 	/* Check for a size specification .b, .w or .l.
 	 */
 	int len = strlen(arg);
-	if (len > 2 && arg[len-2] == '.') {
+	if (len >= 2 && arg[len-2] == '.') {
 		switch (arg[len-1]) {
 		case 'b':
 			return 1;
-- 
2.40.1.1.g1c60b9335d



More information about the U-Boot mailing list