|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH 04/10] tools/libxl: Fix uninitialised variable in libxl__domain_get_device_model_uid()
Andrew Cooper writes ("[PATCH 04/10] tools/libxl: Fix uninitialised variable in
libxl__domain_get_device_model_uid()"):
> The logic is sufficiently complicated I can't figure out if the complain is
> legitimate or not. There is exactly one path wanting kill_by_uid set to true,
> so default it to false and drop the existing workaround for this problem at
> other optimisation levels.
The place where it's used is here:
if (!rc && user) {
state->dm_runas = user;
if (kill_by_uid)
state->dm_kill_uid = GCSPRINTF("%ld",...
This is gated by !rc. So for this to be used uninitialised, we'd have
to get here with rc==0 but uninitialised kill_by_uid.
The label `out` is preceded by a nonzero assignment to rc.
All the `goto out` are preceded by either (i) nonzero assignment to
rc, or (ii) assignment to kill_by_uid and setting rc=0.
So the compiler is wrong.
If only we had sum types.
In the absence of sum types I suggest the following restructuring:
Change all the `rc = ERROR...; goto out;` to `goto err` and make `goto
out` be the success path only.
Ian.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |