mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-06 12:36:58 +00:00
take the advice of an XXX comment and use an atomic operation to decrement a
variable. Also, change a use of strdup to ast_strdup and remove a duplicated error message. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@38108 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
13
cli.c
13
cli.c
@@ -1177,7 +1177,7 @@ static char *parse_args(const char *s, int *argc, char *argv[], int max, int *tr
|
|||||||
if (s == NULL) /* invalid, though! */
|
if (s == NULL) /* invalid, though! */
|
||||||
return NULL;
|
return NULL;
|
||||||
/* make a copy to store the parsed string */
|
/* make a copy to store the parsed string */
|
||||||
if (!(dup = strdup(s)))
|
if (!(dup = ast_strdup(s)))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
cur = dup;
|
cur = dup;
|
||||||
@@ -1350,10 +1350,8 @@ int ast_cli_command(int fd, const char *s)
|
|||||||
char *dup;
|
char *dup;
|
||||||
int tws;
|
int tws;
|
||||||
|
|
||||||
if (!(dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws))) {
|
if (!(dup = parse_args(s, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws)))
|
||||||
ast_log(LOG_ERROR, "Memory allocation failure\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
/* We need at least one entry, or ignore */
|
/* We need at least one entry, or ignore */
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
@@ -1373,11 +1371,8 @@ int ast_cli_command(int fd, const char *s)
|
|||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
|
ast_cli(fd, "No such command '%s' (type 'help' for help)\n", find_best(argv));
|
||||||
if (e) {
|
if (e)
|
||||||
AST_LIST_LOCK(&helpers);
|
ast_atomic_fetchadd_int(&e->inuse, -1);
|
||||||
e->inuse--; /* XXX here an atomic dec would suffice */
|
|
||||||
AST_LIST_UNLOCK(&helpers);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(dup);
|
free(dup);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user