Use automatic clearing for temporary variable, remove 'cleanup' label
and declare parameters according to new coding style rules.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
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 dc5009f11d..56682d7be9 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -1367,25 +1367,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;
@@ -1396,19 +1395,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.45.2