]> xenbits.xensource.com Git - libvirt.git/commit
virhostdevtest: Decrease possibility of uninitialized @subsys
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 6 Feb 2023 15:03:44 +0000 (16:03 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 6 Feb 2023 15:33:26 +0000 (16:33 +0100)
commit874e0916c31f5c663b93f2d20cf37bdac193f344
treef4a5fffeb786dc39e4ff294b68d087510ceb5c17
parentaf954d60468b502ccb2ef29a1504c908d8f9d77d
virhostdevtest: Decrease possibility of uninitialized @subsys

With the current way the myInit() is written, it's fairly easy to
miss initialization of @subsys variable as the variable is
allocated firstly on the stack and then it's assigned to
hostdev[i] which was allocated using g_new0() (this it is
containing nothing but all zeroes).

Make the subsys point to the corresponding member in hostdev[i]
from the start. This way only the important bits are overwritten
and the rest stays initialized to zero.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
tests/virhostdevtest.c