From: Michal Privoznik Date: Mon, 16 Oct 2023 07:49:02 +0000 (+0200) Subject: virSecretLoadAllConfigs: Use g_autofree for @path X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7cb31974ec33a1be3ae6d9765f4b2629d9b4d2c2;p=libvirt.git virSecretLoadAllConfigs: Use g_autofree for @path When loading virSecret configs, the @path variable holds path to individual config files. In each iteration it is freed explicitly using VIR_FREE(). Switch it to g_autofree and remove those explicit calls. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa Reviewed-by: Ján Tomko --- diff --git a/src/conf/virsecretobj.c b/src/conf/virsecretobj.c index e0393e6cec..2585b2c972 100644 --- a/src/conf/virsecretobj.c +++ b/src/conf/virsecretobj.c @@ -902,7 +902,7 @@ virSecretLoadAllConfigs(virSecretObjList *secrets, /* Ignore errors reported by readdir or other calls within the * loop (if any). It's better to keep the secrets we managed to find. */ while (virDirRead(dir, &de, NULL) > 0) { - char *path; + g_autofree char *path = NULL; virSecretObj *obj; if (!virStringHasSuffix(de->d_name, ".xml")) @@ -914,11 +914,9 @@ virSecretLoadAllConfigs(virSecretObjList *secrets, if (!(obj = virSecretLoad(secrets, de->d_name, path, configDir))) { VIR_ERROR(_("Error reading secret: %1$s"), virGetLastErrorMessage()); - VIR_FREE(path); continue; } - VIR_FREE(path); virSecretObjEndAPI(&obj); }