[libvirt] [PATCH] qemu: eliminate nested switch, simplify code

Eric Blake eblake at redhat.com
Wed Mar 28 21:21:57 UTC 2012


On 03/28/2012 01:33 PM, Laine Stump wrote:
> qemuBuildHostNetStr had a switch-within-a-switch where both were
> looking at the same variable. This was apparently to take advantage of
> code common to three different cases (while also taking care of some
> code that was different). However, there were only 2 lines common to
> all, one of those can be eliminated by merging it into the
> virAsprintfs that are in each case. On top of that, all the extra
> empty cases cause Coverity complaints (because they are unreachable),
> but absence of the empty cases causes a compile error due to
> "enumeration value not handled in switch".
> 
> The solution is to just make each toplevel case independent, folding
> in the common code to each.
> ---
>  src/qemu/qemu_command.c |   55 ++++++++++++++++++-----------------------------
>  1 files changed, 21 insertions(+), 34 deletions(-)

ACK.

-- 
Eric Blake   eblake at redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120328/7a31524e/attachment-0001.sig>


More information about the libvir-list mailing list