On 14/11/2023 10:24, Zachary Leaf wrote:
This gets me thinking: assuming we are supposed to handle all the bpf_cmd enum values (I think we do), it would actually be better not to have a default. This way, we would get a warning if a new value is added (I think -Wswitch is enabled but worth checking this actually works).
We are meant to handle all values. To get the warning we need to change the signature to accept enum bpf_cmd instead of int cmd.
This shows us we're already missing 6 values (!)
kernel/bpf/syscall.c:5201:10: warning: 6 enumeration values not handled in switch: 'BPF_MAP_UPDATE_ELEM', 'BPF_MAP_DELETE_ELEM', 'BPF_MAP_LOOKUP_BATCH'... [-Wswitch]
Somehow missed these before. The check is good. Fixed in v5.
Excellent! This will definitely help with rebasing - clearly it is extremely easy to miss new commands in this case.
Kevin