vircommand: Simplify virCommandAddArg

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-02-01 13:42:07 +01:00 committed by Peter Krempa
parent ae9f4d5e0c
commit 8b1755024b

View File

@ -1520,8 +1520,6 @@ virCommandAddEnvXDG(virCommandPtr cmd, const char *baseDir)
void
virCommandAddArg(virCommandPtr cmd, const char *val)
{
char *arg;
if (!cmd || cmd->has_error)
return;
@ -1530,16 +1528,13 @@ virCommandAddArg(virCommandPtr cmd, const char *val)
return;
}
arg = g_strdup(val);
/* Arg plus trailing NULL. */
if (VIR_RESIZE_N(cmd->args, cmd->maxargs, cmd->nargs, 1 + 1) < 0) {
VIR_FREE(arg);
cmd->has_error = ENOMEM;
return;
}
cmd->args[cmd->nargs++] = arg;
cmd->args[cmd->nargs++] = g_strdup(val);
}