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
signature.asc
Description: OpenPGP digital signature