tools: ynl: skip the explicit op array size when not needed
authorJakub Kicinski <kuba@kernel.org>
Tue, 21 Mar 2023 04:41:59 +0000 (21:41 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 22 Mar 2023 04:45:31 +0000 (21:45 -0700)
Jiri suggests it reads more naturally to skip the explicit
array size when possible. When we export the symbol we want
to make sure that the size is right but for statics its
not needed.

Link: https://lore.kernel.org/r/20230321044159.1031040-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/netdev-genl-gen.c
tools/net/ynl/ynl-gen-c.py

index 3abab70..de17ca2 100644 (file)
@@ -16,7 +16,7 @@ static const struct nla_policy netdev_dev_get_nl_policy[NETDEV_A_DEV_IFINDEX + 1
 };
 
 /* Ops table for netdev */
-static const struct genl_split_ops netdev_nl_ops[2] = {
+static const struct genl_split_ops netdev_nl_ops[] = {
        {
                .cmd            = NETDEV_CMD_DEV_GET,
                .doit           = netdev_nl_dev_get_doit,
index c16671a..972b87c 100755 (executable)
@@ -1696,7 +1696,9 @@ def print_kernel_op_table_fwd(family, cw, terminate):
                          'split': 'genl_split_ops'}
         struct_type = pol_to_struct[family.kernel_policy]
 
-        if family.kernel_policy == 'split':
+        if not exported:
+            cnt = ""
+        elif family.kernel_policy == 'split':
             cnt = 0
             for op in family.ops.values():
                 if 'do' in op: