From: Peter Krempa <pkrempa@xxxxxxxxxx> Use automatic clearing for temporary variable, remove 'cleanup' label and declare parameters according to new coding style rules. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> Reviewed-by: Andrea Bolognani <abologna@xxxxxxxxxx> Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx> --- src/util/virutil.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/util/virutil.c b/src/util/virutil.c index bf6008fdfb..2abcb282fe 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -1377,25 +1377,24 @@ virValidateWWN(const char *wwn) * Returns -1 on error, 0 otherwise. */ int -virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr) +virParseOwnershipIds(const char *label, + uid_t *uidPtr, + gid_t *gidPtr) { - int rc = -1; uid_t theuid; gid_t thegid; - char *tmp_label = NULL; + g_autofree char *tmp_label = g_strdup(label); char *sep = NULL; char *owner = NULL; char *group = NULL; - tmp_label = g_strdup(label); - /* Split label */ sep = strchr(tmp_label, ':'); if (sep == NULL) { virReportError(VIR_ERR_INVALID_ARG, _("Failed to parse uid and gid from '%1$s'"), label); - goto cleanup; + return -1; } *sep = '\0'; owner = tmp_label; @@ -1406,19 +1405,14 @@ virParseOwnershipIds(const char *label, uid_t *uidPtr, gid_t *gidPtr) */ if (virGetUserID(owner, &theuid) < 0 || virGetGroupID(group, &thegid) < 0) - goto cleanup; + return -1; if (uidPtr) *uidPtr = theuid; if (gidPtr) *gidPtr = thegid; - rc = 0; - - cleanup: - VIR_FREE(tmp_label); - - return rc; + return 0; } static time_t selfLastChanged; -- 2.46.2