[libvirt PATCH 0/5] Description Here

Ján Tomko (5): Do not check if unsigned vars are less than zero src: QemuMonitorCommandWithFiles: report error when fd passing is unsupported apparmor: report error when removing profile failed vbox: SnapshotConfAllChildren: reduce scope of tempSize storagefile: set size field of ploop to 8 src/esx/esx_stream.c | 2 +- src/libvirt-qemu.c | 4 ++-- src/security/virt-aa-helper.c | 2 +- src/storage_file/storage_file_probe.c | 2 +- src/vbox/vbox_snapshot_conf.c | 3 +-- 5 files changed, 6 insertions(+), 7 deletions(-) -- 2.34.1

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/esx/esx_stream.c | 2 +- src/libvirt-qemu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/esx/esx_stream.c b/src/esx/esx_stream.c index b356fbed70..51c96ff0e0 100644 --- a/src/esx/esx_stream.c +++ b/src/esx/esx_stream.c @@ -287,7 +287,7 @@ esxStreamRecvFlags(virStreamPtr stream, if (esxStreamTransfer(priv, false) < 0) return -1; - if (priv->buffer_used <= 0) + if (priv->buffer_used == 0) return -2; } else /* blocking */ { do { diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 3cd8c8f745..5020b5dc1b 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -233,7 +233,7 @@ virDomainQemuAttach(virConnectPtr conn, virResetLastError(); virCheckConnectReturn(conn, NULL); - virCheckPositiveArgGoto(pid_value, error); + virCheckNonZeroArgGoto(pid_value, error); if (pid != pid_value) { virReportInvalidArg(pid_value, _("pid_value in %s is too large"), -- 2.34.1

The result of the <= 0 comparison was assigned to 'rc', rendering the if (rc == 0) condition dead code. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/libvirt-qemu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 5020b5dc1b..ace91e8ada 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -161,7 +161,7 @@ virDomainQemuMonitorCommandWithFiles(virDomainPtr domain, if (ninfiles > 0 || outfiles) { int rc; if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, - VIR_DRV_FEATURE_FD_PASSING) <= 0)) { + VIR_DRV_FEATURE_FD_PASSING)) <= 0) { if (rc == 0) virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("fd passing is not supported by this connection")); -- 2.34.1

On Wed, May 18, 2022 at 04:00:57PM +0200, Ján Tomko wrote:
The result of the <= 0 comparison was assigned to 'rc', rendering the if (rc == 0) condition dead code.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/libvirt-qemu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libvirt-qemu.c b/src/libvirt-qemu.c index 5020b5dc1b..ace91e8ada 100644 --- a/src/libvirt-qemu.c +++ b/src/libvirt-qemu.c @@ -161,7 +161,7 @@ virDomainQemuMonitorCommandWithFiles(virDomainPtr domain, if (ninfiles > 0 || outfiles) { int rc; if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, - VIR_DRV_FEATURE_FD_PASSING) <= 0)) { + VIR_DRV_FEATURE_FD_PASSING)) <= 0) { if (rc == 0) virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("fd passing is not supported by this connection")); -- 2.34.1
Or even (way) better: diff --git i/src/libvirt-qemu.c w/src/libvirt-qemu.c index 3cd8c8f7453d..93107d1bfcbb 100644 --- i/src/libvirt-qemu.c +++ w/src/libvirt-qemu.c @@ -159,9 +159,9 @@ virDomainQemuMonitorCommandWithFiles(virDomainPtr domain, virCheckNonNullArgGoto(cmd, error); if (ninfiles > 0 || outfiles) { - int rc; - if ((rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, - VIR_DRV_FEATURE_FD_PASSING) <= 0)) { + int rc = VIR_DRV_SUPPORTS_FEATURE(conn->driver, conn, + VIR_DRV_FEATURE_FD_PASSING); + if (rc <= 0) { if (rc == 0) virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("fd passing is not supported by this connection")); --

Assign the return value to 'rc' before comparing it. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/security/virt-aa-helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 1f1cce8b3d..5dc941f79a 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1497,7 +1497,7 @@ main(int argc, char **argv) size = virFileLength(profile, -1); if (size == 0) { vah_warning(_("Profile of 0 size detected, will attempt to remove it")); - if ((rc = parserRemove(ctl->uuid) != 0)) + if ((rc = parserRemove(ctl->uuid)) != 0) vah_error(ctl, 1, _("could not remove profile")); unlink(profile); purged = true; -- 2.34.1

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/vbox/vbox_snapshot_conf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 6b47893b5e..90afac179e 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -454,7 +454,6 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardDisk *disk, virVBoxSnapshotConfHardDisk ***list) { size_t returnSize = 0; - size_t tempSize = 0; virVBoxSnapshotConfHardDisk **ret = NULL; virVBoxSnapshotConfHardDisk **tempList = NULL; size_t i = 0; @@ -463,7 +462,7 @@ virVBoxSnapshotConfAllChildren(virVBoxSnapshotConfHardDisk *disk, ret = g_new0(virVBoxSnapshotConfHardDisk *, 0); for (i = 0; i < disk->nchildren; i++) { - tempSize = virVBoxSnapshotConfAllChildren(disk->children[i], &tempList); + size_t tempSize = virVBoxSnapshotConfAllChildren(disk->children[i], &tempList); VIR_EXPAND_N(ret, returnSize, tempSize); for (j = 0; j < tempSize; j++) -- 2.34.1

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/storage_file/storage_file_probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/storage_file_probe.c index 54e095ffd3..9465af5d96 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -296,7 +296,7 @@ static struct FileTypeInfo const fileTypeInfo[] = { [VIR_STORAGE_FILE_VHD] = { 0, NULL, LV_LITTLE_ENDIAN, -1, 0, {0}, 0, 0, 0, NULL, NULL, NULL, NULL }, [VIR_STORAGE_FILE_PLOOP] = { 0, "WithouFreSpacExt", LV_LITTLE_ENDIAN, - -2, 0, {0}, PLOOP_IMAGE_SIZE_OFFSET, 0, + -2, 0, {0}, PLOOP_IMAGE_SIZE_OFFSET, 8, PLOOP_SIZE_MULTIPLIER, NULL, NULL, NULL, NULL }, /* All formats with a backing store probe below here */ -- 2.34.1

On Wed, May 18, 2022 at 16:00:55 +0200, Ján Tomko wrote:
Ján Tomko (5): Do not check if unsigned vars are less than zero src: QemuMonitorCommandWithFiles: report error when fd passing is unsupported apparmor: report error when removing profile failed vbox: SnapshotConfAllChildren: reduce scope of tempSize
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
storagefile: set size field of ploop to 8
For this one a commit message outlining why '8' would be great.
participants (3)
-
Ján Tomko
-
Martin Kletzander
-
Peter Krempa