build: remove clang warning about global var 'match'
remove clang warning - "Argument to free() is the address of a global variable, which is not memory allocated by malloc()". Change-Id: I015273eafc9644207684b363434c6ae8149bfcde Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/1613 Tested-by: jenkins
This commit is contained in:
parent
2e4e53f7b5
commit
117cff71d5
|
@ -814,13 +814,13 @@ static COMMAND_HELPER(command_help_find, struct command *head,
|
||||||
}
|
}
|
||||||
|
|
||||||
static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
|
static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
|
||||||
bool show_help, const char *match);
|
bool show_help, const char *cmd_match);
|
||||||
|
|
||||||
static COMMAND_HELPER(command_help_show_list, struct command *head, unsigned n,
|
static COMMAND_HELPER(command_help_show_list, struct command *head, unsigned n,
|
||||||
bool show_help, const char *match)
|
bool show_help, const char *cmd_match)
|
||||||
{
|
{
|
||||||
for (struct command *c = head; NULL != c; c = c->next)
|
for (struct command *c = head; NULL != c; c = c->next)
|
||||||
CALL_COMMAND_HANDLER(command_help_show, c, n, show_help, match);
|
CALL_COMMAND_HANDLER(command_help_show, c, n, show_help, cmd_match);
|
||||||
return ERROR_OK;
|
return ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -852,7 +852,7 @@ static void command_help_show_wrap(const char *str, unsigned n, unsigned n2)
|
||||||
}
|
}
|
||||||
|
|
||||||
static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
|
static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
|
||||||
bool show_help, const char *match)
|
bool show_help, const char *cmd_match)
|
||||||
{
|
{
|
||||||
char *cmd_name = command_name(c, ' ');
|
char *cmd_name = command_name(c, ' ');
|
||||||
if (NULL == cmd_name)
|
if (NULL == cmd_name)
|
||||||
|
@ -860,9 +860,9 @@ static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
|
||||||
|
|
||||||
/* If the match string occurs anywhere, we print out
|
/* If the match string occurs anywhere, we print out
|
||||||
* stuff for this command. */
|
* stuff for this command. */
|
||||||
bool is_match = (strstr(cmd_name, match) != NULL) ||
|
bool is_match = (strstr(cmd_name, cmd_match) != NULL) ||
|
||||||
((c->usage != NULL) && (strstr(c->usage, match) != NULL)) ||
|
((c->usage != NULL) && (strstr(c->usage, cmd_match) != NULL)) ||
|
||||||
((c->help != NULL) && (strstr(c->help, match) != NULL));
|
((c->help != NULL) && (strstr(c->help, cmd_match) != NULL));
|
||||||
|
|
||||||
if (is_match) {
|
if (is_match) {
|
||||||
command_help_show_indent(n);
|
command_help_show_indent(n);
|
||||||
|
@ -913,7 +913,7 @@ static COMMAND_HELPER(command_help_show, struct command *c, unsigned n,
|
||||||
}
|
}
|
||||||
|
|
||||||
return CALL_COMMAND_HANDLER(command_help_show_list,
|
return CALL_COMMAND_HANDLER(command_help_show_list,
|
||||||
c->children, n, show_help, match);
|
c->children, n, show_help, cmd_match);
|
||||||
}
|
}
|
||||||
|
|
||||||
COMMAND_HANDLER(handle_help_command)
|
COMMAND_HANDLER(handle_help_command)
|
||||||
|
@ -921,26 +921,26 @@ COMMAND_HANDLER(handle_help_command)
|
||||||
bool full = strcmp(CMD_NAME, "help") == 0;
|
bool full = strcmp(CMD_NAME, "help") == 0;
|
||||||
int retval;
|
int retval;
|
||||||
struct command *c = CMD_CTX->commands;
|
struct command *c = CMD_CTX->commands;
|
||||||
char *match = NULL;
|
char *cmd_match = NULL;
|
||||||
|
|
||||||
if (CMD_ARGC == 0)
|
if (CMD_ARGC == 0)
|
||||||
match = "";
|
cmd_match = "";
|
||||||
else if (CMD_ARGC >= 1) {
|
else if (CMD_ARGC >= 1) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < CMD_ARGC; ++i) {
|
for (i = 0; i < CMD_ARGC; ++i) {
|
||||||
if (NULL != match) {
|
if (NULL != cmd_match) {
|
||||||
char *prev = match;
|
char *prev = cmd_match;
|
||||||
|
|
||||||
match = alloc_printf("%s %s", match, CMD_ARGV[i]);
|
cmd_match = alloc_printf("%s %s", cmd_match, CMD_ARGV[i]);
|
||||||
free(prev);
|
free(prev);
|
||||||
if (NULL == match) {
|
if (NULL == cmd_match) {
|
||||||
LOG_ERROR("unable to build search string");
|
LOG_ERROR("unable to build search string");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match = alloc_printf("%s", CMD_ARGV[i]);
|
cmd_match = alloc_printf("%s", CMD_ARGV[i]);
|
||||||
if (NULL == match) {
|
if (NULL == cmd_match) {
|
||||||
LOG_ERROR("unable to build search string");
|
LOG_ERROR("unable to build search string");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -950,10 +950,10 @@ COMMAND_HANDLER(handle_help_command)
|
||||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||||
|
|
||||||
retval = CALL_COMMAND_HANDLER(command_help_show_list,
|
retval = CALL_COMMAND_HANDLER(command_help_show_list,
|
||||||
c, 0, full, match);
|
c, 0, full, cmd_match);
|
||||||
|
|
||||||
if (CMD_ARGC >= 1)
|
if (CMD_ARGC >= 1)
|
||||||
free(match);
|
free(cmd_match);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue