aboutsummaryrefslogtreecommitdiffstats
path: root/tools/net/ynl/generated/netdev-user.c
diff options
context:
space:
mode:
authorJakub Kicinski <[email protected]>2023-06-02 02:35:44 +0000
committerJakub Kicinski <[email protected]>2023-06-03 05:10:47 +0000
commit21b6e302789c412bdde84439b9325c76e2a5c428 (patch)
treedfe24da2cb28675c559b0842b1bd98ccc9a75f86 /tools/net/ynl/generated/netdev-user.c
parenttools: ynl-gen: add error checking for nested structs (diff)
downloadkernel-21b6e302789c412bdde84439b9325c76e2a5c428.tar.gz
kernel-21b6e302789c412bdde84439b9325c76e2a5c428.zip
tools: ynl-gen: generate enum-to-string helpers
It's sometimes useful to print the name of an enum value, flag or name of the op. Python can do it, add C helper code gen for getting names of things. Example: static const char * const netdev_xdp_act_strmap[] = { [0] = "basic", [1] = "redirect", [2] = "ndo-xmit", [3] = "xsk-zerocopy", [4] = "hw-offload", [5] = "rx-sg", [6] = "ndo-xmit-sg", }; const char *netdev_xdp_act_str(enum netdev_xdp_act value) { value = ffs(value) - 1; if (value < 0 || value >= (int)MNL_ARRAY_SIZE(netdev_xdp_act_strmap)) return NULL; return netdev_xdp_act_strmap[value]; } Signed-off-by: Jakub Kicinski <[email protected]>
Diffstat (limited to 'tools/net/ynl/generated/netdev-user.c')
0 files changed, 0 insertions, 0 deletions