4ast wrote:
>
> I think this _should_ fail to verify if kernel doesn't know have
> hugetlb_cgrp_id, if the code is written this way. Realistically, your switch
> should only have enumerators you expect always to be present, and if you want
> to handle something that might not be there, you'll have to handle that with
> existence check with explicit if/else:
>
> ```
> if (bpf_core_enum_value_exists(enum cgroup_subsys_id, hugetlb_cgpr_id) &&
> ssid == hugetlb_cgrp_id /* relocatable, poisoned if doesn't exist, but
> unreachable then */) {
> ...
> }
> ```
I stopped short to propose that the switch should be rewritten like above by
llvm automatically.
(not exactly with the bpf_core_enum_value_exists macro, but with builtins that
it knows about)
Not sure what's a good path here. I guess if we're fine with errors during load
time for switches
like that... then add it to some doc. like other examples I gave.
https://github.com/llvm/llvm-project/pull/243338
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits