提交 c8682fce 编写于 作者: S Sukrit Bhatnagar 提交者: Erik Skultety

util: kmod: use VIR_AUTOFREE instead of VIR_FREE for scalar types

By making use of GNU C's cleanup attribute handled by the
VIR_AUTOFREE macro for declaring scalar variables, majority
of the VIR_FREE calls can be dropped, which in turn leads to
getting rid of most of our cleanup sections.
Signed-off-by: NSukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: NErik Skultety <eskultet@redhat.com>
上级 280c81af
...@@ -155,13 +155,12 @@ virKModUnload(const char *module) ...@@ -155,13 +155,12 @@ virKModUnload(const char *module)
bool bool
virKModIsBlacklisted(const char *module) virKModIsBlacklisted(const char *module)
{ {
bool retval = false;
size_t i; size_t i;
char *drvblklst = NULL; VIR_AUTOFREE(char *) drvblklst = NULL;
char *outbuf = NULL; VIR_AUTOFREE(char *) outbuf = NULL;
if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0) if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0)
goto cleanup; return false;
/* modprobe will convert all '-' into '_', so we need to as well */ /* modprobe will convert all '-' into '_', so we need to as well */
for (i = 0; i < drvblklst[i]; i++) for (i = 0; i < drvblklst[i]; i++)
...@@ -169,13 +168,10 @@ virKModIsBlacklisted(const char *module) ...@@ -169,13 +168,10 @@ virKModIsBlacklisted(const char *module)
drvblklst[i] = '_'; drvblklst[i] = '_';
if (doModprobe("-c", NULL, &outbuf, NULL) < 0) if (doModprobe("-c", NULL, &outbuf, NULL) < 0)
goto cleanup; return false;
if (strstr(outbuf, drvblklst)) if (strstr(outbuf, drvblklst))
retval = true; return true;
cleanup: return false;
VIR_FREE(drvblklst);
VIR_FREE(outbuf);
return retval;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册