[syslinux] [PATCH 6/6] hdt: fix sizeof(char *) misuse
Jonathan Boeing
jonathan.n.boeing at gmail.com
Mon Feb 9 19:01:39 PST 2015
The code was passing sizeof(const char *) - not the length of the string
or the size of the buffer - as the length to strncmp(). These two cases
don't need the length, so switch to strcmp.
Fixes the warning: argument to 'sizeof' in 'strncmp' call is the same
expression as the second source; did you mean to provide an explicit
length?
Signed-off-by: Jonathan Boeing <jonathan.n.boeing at gmail.com>
---
com32/hdt/hdt-cli.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/com32/hdt/hdt-cli.c b/com32/hdt/hdt-cli.c
index 2895b13..776c8e8 100644
--- a/com32/hdt/hdt-cli.c
+++ b/com32/hdt/hdt-cli.c
@@ -211,7 +211,7 @@ cli_mode_t mode_s_to_mode_t(char *name)
int i = 0;
while (list_modes[i]) {
- if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name)))
+ if (!strcmp(name, list_modes[i]->name))
break;
i++;
}
@@ -288,8 +288,7 @@ static void expand_aliases(char *line __unused, char **command, char **module,
/* Simple aliases mapping a single command to another one */
for (i = 0; i < MAX_ALIASES; i++) {
for (j = 0; j < hdt_aliases[i].nb_aliases; j++) {
- if (!strncmp(*command, hdt_aliases[i].aliases[j],
- sizeof(hdt_aliases[i].aliases[j]))) {
+ if (!strcmp(*command, hdt_aliases[i].aliases[j])) {
dprintf("CLI DEBUG: ALIAS %s ", *command);
strlcpy(*command, hdt_aliases[i].command,
sizeof(hdt_aliases[i].command) + 1);
--
2.3.0
More information about the Syslinux
mailing list