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

Re: [Xen-devel] [RFC PATCH 0/4] Add missing default labels to switch statements



>>> On 25.02.19 at 12:47, <julien.grall@xxxxxxx> wrote:
> For enum, a compiler supporting -Wswitch can helps us to catch when we forgot 
> to 
> handle a element of the enum. The default case defeats -Wswitch. Yet having a 
> default could protect us against code error. It looks like that GCC have an 
> option -Wswitch-enum that could help us. The option will similar to -Wswitch 
> except it will warn even when there are a default case. I am curious to see 
> if 
> we can use it reliably in Xen.

I can say already now that I'm against the use of -Wswitch-enum. It
defeats the main idea of "default:" in C. The longer the list of
enumerators in an enum, the worse the situation becomes when you
mean to handle specially a couple of cases while dozens of others
use a common path, all of which would then need to get enlisted.
x86's p2m_get_iommu_flags() and hvmemul_rep_stos() may give you
a vague impression of what I mean...

Jan



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.