From: Ján Tomko Date: Fri, 18 Oct 2019 21:32:12 +0000 (+0200) Subject: virsh: getSignalNumber: use g_autofree X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5c808a09a774ec3396e6e9681aaad0acaf31dbfe;p=libvirt.git virsh: getSignalNumber: use g_autofree Mark the 'str' variable as g_autofree and avoid the need for a separate cleanup label. Signed-off-by: Ján Tomko Reviewed-by: Daniel Henrique Barboza --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index d74a671167..44eb8a5d32 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8806,27 +8806,21 @@ static int getSignalNumber(vshControl *ctl, const char *signame) { size_t i; int signum; - char *str = vshStrdup(ctl, signame); + g_autofree char *str = vshStrdup(ctl, signame); char *p = str; for (i = 0; signame[i]; i++) p[i] = c_tolower(signame[i]); if (virStrToLong_i(p, NULL, 10, &signum) >= 0) - goto cleanup; + return signum; if (STRPREFIX(p, "sig_")) p += 4; else if (STRPREFIX(p, "sig")) p += 3; - if ((signum = virDomainProcessSignalTypeFromString(p)) >= 0) - goto cleanup; - - signum = -1; - cleanup: - VIR_FREE(str); - return signum; + return virDomainProcessSignalTypeFromString(p); } static bool