]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tools: ynl-gen: always append ULL/LL to range types
authorJakub Kicinski <kuba@kernel.org>
Wed, 22 Nov 2023 17:33:23 +0000 (09:33 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 24 Nov 2023 14:57:03 +0000 (14:57 +0000)
32bit builds generate the following warning when we use a u32-max
in range validation:

  warning: decimal constant 4294967295 is between LONG_MAX and ULONG_MAX. For C99 that means long long, C90 compilers are very likely to produce unsigned long (and a warning) here

The range values are u64, slap ULL/LL on all of them just
to avoid such noise.

There's currently no code using full range validation, but
it will matter in the upcoming page-pool introspection.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/net/ynl/ynl-gen-c.py

index 3bd6b928c14ff7c1e7e67e83ad19f2c7568db410..fe5ca7fbe01142f25007617be2ceaba5a34dd682 100755 (executable)
@@ -2070,12 +2070,13 @@ def print_kernel_policy_ranges(family, cw):
                 first = False
 
             sign = '' if attr.type[0] == 'u' else '_signed'
+            suffix = 'ULL' if attr.type[0] == 'u' else 'LL'
             cw.block_start(line=f'static const struct netlink_range_validation{sign} {c_lower(attr.enum_name)}_range =')
             members = []
             if 'min' in attr.checks:
-                members.append(('min', attr.get_limit('min')))
+                members.append(('min', str(attr.get_limit('min')) + suffix))
             if 'max' in attr.checks:
-                members.append(('max', attr.get_limit('max')))
+                members.append(('max', str(attr.get_limit('max')) + suffix))
             cw.write_struct_init(members)
             cw.block_end(line=';')
             cw.nl()