From 0316dd79552a5542963b1dc648172e335049de85 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Sat, 27 Apr 2024 13:04:25 +0200 Subject: [PATCH] command: refactor loop test for end of string --- tools/command.c | 2 +- tools/man-generator.c | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/command.c b/tools/command.c index c39295a54..c05852af3 100644 --- a/tools/command.c +++ b/tools/command.c @@ -1596,7 +1596,7 @@ static void _print_usage_description(struct command *cmd) unsigned di = 0; int bi = 0; - for (di = 0; di < strlen(desc); di++) { + for (di = 0; desc[di]; di++) { if (!strncmp(&desc[di], "DESC:", 5)) { if (bi) { buf[bi] = '\0'; diff --git a/tools/man-generator.c b/tools/man-generator.c index 03322dc40..a0b4dde18 100644 --- a/tools/man-generator.c +++ b/tools/man-generator.c @@ -993,7 +993,7 @@ static void _print_man_option_desc(struct command_name *cname, int opt_enum) return; } - for (di = 0; di < strlen(desc); di++) { + for (di = 0; desc[di]; di++) { buf[bi++] = desc[di]; if (bi == DESC_LINE) { @@ -1318,9 +1318,7 @@ static void _print_desc_man(const char *desc) unsigned di; int bi = 0; - for (di = 0; di < strlen(desc); di++) { - if (desc[di] == '\0') - break; + for (di = 0; desc[di]; di++) { if (desc[di] == '\n') continue;