[PATCH] qemu: snapshot: Restructure control flow to detect errors sooner and work around compiler
Pavel Hrdina
phrdina at redhat.com
Mon Jan 9 13:12:33 UTC 2023
On Mon, Jan 09, 2023 at 02:09:24PM +0100, Peter Krempa wrote:
> Some compilers aren't happy when an automatically freed variable is used
> just to free something (thus it's only assigned in the code):
>
> When compiling qemuSnapshotDelete after recent commits they complain:
>
> ../src/qemu/qemu_snapshot.c:3153:61: error: variable 'delData' set but not used [-Werror,-Wunused-but-set-variable]
> g_autoslist(qemuSnapshotDeleteExternalData) delData = NULL;
> ^
>
> To work around the issue we can restructure the code which also has the
> following semantic implications:
> - since qemuSnapshotDeleteExternalPrepare does validation we error out
> sooner than attempting to start the VM
>
> - we read the temporary variable at least in one code path
>
> Fixes: 4a4d89a9252
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
> src/qemu/qemu_snapshot.c | 16 ++++++++--------
> 1 file changed, 8 insertions(+), 8 deletions(-)
Reviewed-by: Pavel Hrdina <phrdina at redhat.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230109/df00ed40/attachment.sig>
More information about the libvir-list
mailing list