qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v2 5/6] audio: use qapi AudioFormat instead of a


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v2 5/6] audio: use qapi AudioFormat instead of audfmt_e
Date: Wed, 17 Jun 2015 10:01:53 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 06/17/2015 05:51 AM, Markus Armbruster wrote:

>>>> @@ -639,19 +639,22 @@ static int alsa_open (int in, struct alsa_params_req 
>>>> *req,
>>>>           bytes_per_sec = freq << (nchannels == 2);
>>>>
>>>>           switch (obt->fmt) {
>>>> -        case AUD_FMT_S8:
>>>> -        case AUD_FMT_U8:
>>>> +        case AUDIO_FORMAT_S8:
>>>> +        case AUDIO_FORMAT_U8:

>>>> +
>>>> +        case AUDIO_FORMAT_MAX:
>>>> +            break;
>>>
>>> Can this happen?
>>
>> Not under normal circumstances, but gcc warns otherwise.
> 
> Okay, sounds like another case of "default: abort();" to me :)

gcc has the annoying habit that it can warn you about missing enum
labels in a switch statement, but ONLY if you do not use a 'default:'
label.  Warning about missing labels is nice if you plan to add more
enum values down the road (then the compiler helpfully points out all
the code spots that need to deal with the new value) but with the
drawback that non-enum values bypass the switch completely.  So if you
anticipate this set growing, then s/break/abort()/ is all the more you
need.  On the other hand, if the set is pretty much fixed, then
switching to default: covers more cases including non-enum values
assigned into obt->fmt.

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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