|
From: | Eric Blake |
Subject: | Re: [PATCH COMMITTED] src: Fix NDEBUG compilation: avoid side-effects in assert |
Date: | Thu, 27 Feb 2020 07:01:08 -0600 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 |
On 2/27/20 6:54 AM, Eric Blake wrote:
+++ b/src/ios.c @@ -220,12 +220,14 @@ void ios_close (ios io) { struct ios *tmp; + int r; /* XXX: if not saved, ask before closing. */ /* Close the device operated by the IO space. XXX: handle errors. */ - assert (io->dev_if->close (io->dev)); + r = io->dev_if->close (io->dev); + assert (r);Another way to do this that does not use temporary variables that we'd have to ifdef out under NDEBUG would be:if (! io->dev_if->close (io->dev)) assert (0);I can make that switch if you'd like (and undo the addition of all my temporaries).
And independently of that offer, at this particular code site we DO need to fix the XXX comment; at least my patch to add an NBD io space can have a failed dev_if->close() call if the NBD server went AWOL in the meantime. The actions of a failing server should not cause poke to die from an assertion, but instead inform the user about the potential data loss due to the failed close.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |