qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] [TRIVIAL] usb-linux: remove unreachable default


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] [TRIVIAL] usb-linux: remove unreachable default in switch statement
Date: Wed, 17 Mar 2010 12:15:53 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Lightning/1.0pre Thunderbird/3.0

On 03/17/2010 12:08 PM, Paul Brook wrote:
On 03/17/2010 11:14 AM, Paul Bolle wrote:
On Wed, 2010-03-17 at 10:59 -0500, Anthony Liguori wrote:
On 03/08/2010 06:58 AM, Paul Bolle wrote:
Signed-off-by: Paul Bolle<address@hidden>
Applied.  Thanks.
Paul Brook was "tempted to replace it by an abort()" (about one and a
half week ago). Did you perhaps miss that message or weren't you tempted
to do this?
I missed it, but then again, I don't think the patch was wrong in the
first place.

I think we use too many aborts/exits in the device model that can
potentially be triggered by guest code.
If something should never happen (as in this case) then an abort/assert is
completely appropriate. Once things get that screwed up there's no right
answer, and the best thing we can do is terminate immediately to try and avoid
further damage.

This case was:

switch (foo & 0x03) {
case 0: case 1: case 2: case 3:
default:
}

The default is unreachable. Having it there just introduces more code that serves no purpose. Unless someone does something totally foolish and changes the mask in the switch statement, there's no way it will ever be reachable.

If an assert/abort can be triggered by a guest then you obviously have a bug.

Agreed.

Removing the assert is not the correct solution.  You should either fix
whatever caused the invalid state to occur, or replace it with an appropriate
retry, fallback or guest visible failure.

Also agreed.

Regards,

Anthony Liguori

Paul





reply via email to

[Prev in Thread] Current Thread [Next in Thread]