[libvirt] [PATCH v1 09/40] util: cgroup: use VIR_AUTOFREE instead of VIR_FREE for scalar types
Erik Skultety
eskultet at redhat.com
Mon Jul 23 12:11:28 UTC 2018
On Sat, Jul 21, 2018 at 05:36:41PM +0530, Sukrit Bhatnagar wrote:
> 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 at gmail.com>
> ---
...
> @@ -1893,9 +1821,11 @@ virCgroupGetBlkioIoServiced(virCgroupPtr group,
> long long *requests_write)
> {
> long long stats_val;
> - char *str1 = NULL, *str2 = NULL, *p1, *p2;
> + VIR_AUTOFREE(char *) str1 = NULL;
> + VIR_AUTOFREE(char *) str2 = NULL;
> + char *p1;
> + char *p2;
Could have initialized ^these 2 as well for that matter...
...
>
>
> @@ -2002,9 +1927,12 @@ virCgroupGetBlkioIoDeviceServiced(virCgroupPtr group,
> long long *requests_read,
> long long *requests_write)
> {
> - char *str1 = NULL, *str2 = NULL, *str3 = NULL, *p1, *p2;
> + VIR_AUTOFREE(char *) str1 = NULL;
> + VIR_AUTOFREE(char *) str2 = NULL;
> + VIR_AUTOFREE(char *) str3 = NULL;
> + char *p1;
> + char *p2;
...here too...
Reviewed-by: Erik Skultety <eskultet at redhat.com>
More information about the libvir-list
mailing list