On Fri, 25 Oct 2024 12:02:17 +1100
David Gibson
On Fri, Oct 25, 2024 at 01:04:37AM +0200, Stefano Brivio wrote:
/home/sbrivio/passt/udp.c:171:1: error: inital values in enum 'udp_iov_idx' are not consistent, consider explicit initialization of all, none or only the first enumerator [cert-int09-c,readability-enum-initial-value,-warnings-as-errors] 171 | enum udp_iov_idx { | ^ 172 | UDP_IOV_TAP = 0, 173 | UDP_IOV_ETH = 1, 174 | UDP_IOV_IP = 2, 175 | UDP_IOV_PAYLOAD = 3, 176 | UDP_NUM_IOVS | | = 4
Make sure we initialise all the values, in this case.
Oof. Although it's a bit weird, I quite like the existing style, because it gives the correct value for NUM_WHATEVER without requiring editing if a new explicit value is inserted above it.
I'd be inclined to use a suppression rather than changing the code.
I see your point, but still it would be practical to just comply with INT09-C: https://wiki.sei.cmu.edu/confluence/display/c/INT09-C.+Ensure+enumeration+co... ...avoiding integer assignments altogether would do the trick as well. Perhaps I should go with that instead. -- Stefano