
On 11.02.2015 18:34, Eric Blake wrote:
On 02/11/2015 07:04 AM, Michal Privoznik wrote:
On 10.02.2015 16:35, Martin Kletzander wrote:
<snip/> + +typedef enum { + VIR_PROC_POLICY_NONE, + VIR_PROC_POLICY_BATCH, + VIR_PROC_POLICY_IDLE, + VIR_PROC_POLICY_FIFO, + VIR_PROC_POLICY_RR, + + VIR_PROC_POLICY_LAST +} virProcessSchedPolicy;
The C language guarantees that VIR_PROC_POLICY_NONE == 0, and that VIR_PROC_POLICY_BATCH == (VIR_PROC_POLICY_NONE + 1). That is, C guarantees that an initial enum not otherwise initialized is 0, and that all subsequent enums not otherwise initialized are one more than the previous value (whether or not the previous value was explicitly initialized). So the code you questioned is safe as-is.
So in other words, we don't need zero 'initialization' in enums? So for instance the following (taken from daemon/libvirtd.c:122): enum { VIR_DAEMON_ERR_NONE = 0, /* snip */ }; is the same as enum { VIR_DAEMON_ERR_NONE, /* snip */ }; If it is so, is it worth bothering with cleanup patch(es)? There's roughly 250 occurrences in the code: $ git grep "[A-Z]\+ = 0" | wc -l 268 Michal