[syslinux:master] hdt: fix sizeof(char *) misuse
syslinux-bot for Jonathan Boeing
jonathan.n.boeing at gmail.com
Sun May 17 04:51:15 PDT 2015
Commit-ID: 4ab07cfbee420f43c02b8f6c51641f45191abd63
Gitweb: http://www.syslinux.org/commit/4ab07cfbee420f43c02b8f6c51641f45191abd63
Author: Jonathan Boeing <jonathan.n.boeing at gmail.com>
AuthorDate: Mon, 9 Feb 2015 20:01:39 -0700
Committer: Gene Cumm <gene.cumm at gmail.com>
CommitDate: Sun, 3 May 2015 10:52:34 -0400
hdt: fix sizeof(char *) misuse
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);
More information about the Syslinux-commits
mailing list