[libvirt] [PATCH v2 16/42] util: add default: case to all switch statements

Ján Tomko jtomko at redhat.com
Tue Feb 20 15:55:14 UTC 2018


On Thu, Feb 15, 2018 at 04:43:21PM +0000, Daniel P. Berrangé wrote:
>Even if the compiler has validated that all enum constants have case
>statements in a switch, it is not safe to omit a default: case
>statement. When assigning a value to a variable / struct field that is
>defined with an enum type, nothing prevents an invalid value being
>assigned. So defensive code must assume existance of invalid values and

s/existance/existence/

Jan

>thus all switches should have a default: case.
>
>Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20180220/3ca5c646/attachment-0001.sig>


More information about the libvir-list mailing list