qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2] vhost_net: fix misuse of assert()
@ 2015-06-19 12:03 Greg Kurz
  0 siblings, 0 replies; only message in thread
From: Greg Kurz @ 2015-06-19 12:03 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: qemu-devel

>From assert(3): "assert() is implemented as a macro; if the expression tested
has side-effects, program behavior will be different depending on whether
NDEBUG is defined."

Even if QEMU isn't compiled with NDEBUG, it is bad practice to put bits
with a relevant functionnal meaning in assert().

This is a readability enhancement. The patch does not fix any bug.

Suggested-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
---
 hw/net/vhost_net.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

v2: rewrote commit log

diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index f505c91d420a..6d3b7879f8ef 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -376,7 +376,8 @@ void vhost_net_stop(VirtIODevice *dev, NetClientState *ncs,
     }
     assert(r >= 0);
 
-    assert(vhost_net_set_vnet_endian(dev, ncs[0].peer, false) >= 0);
+    r = vhost_net_set_vnet_endian(dev, ncs[0].peer, false);
+    assert(r >= 0);
 }
 
 void vhost_net_cleanup(struct vhost_net *net)

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-06-19 12:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-19 12:03 [Qemu-devel] [PATCH v2] vhost_net: fix misuse of assert() Greg Kurz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).