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: Sukrit Bhatnagar <skrtbhtngr@gmail.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
bool
virKModIsBlacklisted(const char *module)
{
- bool retval = false;
size_t i;
- char *drvblklst = NULL;
- char *outbuf = NULL;
+ VIR_AUTOFREE(char *) drvblklst = NULL;
+ VIR_AUTOFREE(char *) outbuf = NULL;
if (virAsprintfQuiet(&drvblklst, "blacklist %s\n", module) < 0)
- goto cleanup;
+ return false;
/* modprobe will convert all '-' into '_', so we need to as well */
for (i = 0; i < drvblklst[i]; i++)
drvblklst[i] = '_';
if (doModprobe("-c", NULL, &outbuf, NULL) < 0)
- goto cleanup;
+ return false;
if (strstr(outbuf, drvblklst))
- retval = true;
+ return true;
- cleanup:
- VIR_FREE(drvblklst);
- VIR_FREE(outbuf);
- return retval;
+ return false;
}