[libvirt] [PATCH 0/2] Fix condition value assignments in conditions

Split into two patches, as we might want to backport the first one somewhere. Ján Tomko (2): Fix error on fs pool build failure Fix assignment of comparison against zero src/storage/storage_backend_fs.c | 2 +- tests/virnettlshelpers.c | 4 ++-- tools/virsh-network.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) -- 1.8.5.5

https://bugzilla.redhat.com/show_bug.cgi?id=1119592 Introduced by commit 62927dd v0.7.6. --- src/storage/storage_backend_fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 1615c12..bfaa41f 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -798,7 +798,7 @@ virStorageBackendFileSystemBuild(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_DIR_CREATE_FORCE_PERMS | VIR_DIR_CREATE_ALLOW_EXIST | (pool->def->type == VIR_STORAGE_POOL_NETFS - ? VIR_DIR_CREATE_AS_UID : 0)) < 0)) { + ? VIR_DIR_CREATE_AS_UID : 0))) < 0) { virReportSystemError(-err, _("cannot create path '%s'"), pool->def->target.path); goto error; -- 1.8.5.5

Assign the value we're comparing: (val = func()) < 0 instead of assigning the comparison value: (val = func() < 0) Both were introduced along with the code, the TLS tests by commit bd789df in 0.9.4 net events by commit de87691 in 1.2.2. Note that the event id type fix is a no-op: vshNetworkEventIdTypeFromString can only return -1 (failure) and the event is never used or 0 (the only possible event) and the value of 0 < 0 is still 0. --- tests/virnettlshelpers.c | 4 ++-- tools/virsh-network.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/virnettlshelpers.c b/tests/virnettlshelpers.c index 47a1b12..6e667d1 100644 --- a/tests/virnettlshelpers.c +++ b/tests/virnettlshelpers.c @@ -383,7 +383,7 @@ testTLSGenerateCert(struct testTLSCertReq *req, * If no 'ca' is set then we are self signing * the cert. This is done for the root CA certs */ - if ((err = gnutls_x509_crt_sign(crt, ca ? ca : crt, privkey) < 0)) { + if ((err = gnutls_x509_crt_sign(crt, ca ? ca : crt, privkey)) < 0) { VIR_WARN("Failed to sign certificate %s", gnutls_strerror(err)); abort(); } @@ -391,7 +391,7 @@ testTLSGenerateCert(struct testTLSCertReq *req, /* * Finally write the new cert out to disk */ - if ((err = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, buffer, &size) < 0)) { + if ((err = gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, buffer, &size)) < 0) { VIR_WARN("Failed to export certificate %s", gnutls_strerror(err)); abort(); } diff --git a/tools/virsh-network.c b/tools/virsh-network.c index 7f4f4ce..fc08b09 100644 --- a/tools/virsh-network.c +++ b/tools/virsh-network.c @@ -1238,7 +1238,7 @@ cmdNetworkEvent(vshControl *ctl, const vshCmd *cmd) vshError(ctl, "%s", _("either --list or event type is required")); return false; } - if ((event = vshNetworkEventIdTypeFromString(eventName) < 0)) { + if ((event = vshNetworkEventIdTypeFromString(eventName)) < 0) { vshError(ctl, _("unknown event type %s"), eventName); return false; } -- 1.8.5.5

On Tue, Jul 15, 2014 at 02:59:50PM +0200, Ján Tomko wrote:
Split into two patches, as we might want to backport the first one somewhere.
Ján Tomko (2): Fix error on fs pool build failure Fix assignment of comparison against zero
src/storage/storage_backend_fs.c | 2 +- tests/virnettlshelpers.c | 4 ++-- tools/virsh-network.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
-- 1.8.5.5
ACK series. Maybe libvirt will now work after 4 years (the commit in 1/2) :) Martin
participants (2)
-
Ján Tomko
-
Martin Kletzander