Skip to content

Commit 8e37079

Browse files
kuba-moodavem330
authored andcommitted
tools: ynl-gen: always append ULL/LL to range types
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>
1 parent d1d3470 commit 8e37079

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

tools/net/ynl/ynl-gen-c.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,12 +2070,13 @@ def print_kernel_policy_ranges(family, cw):
20702070
first = False
20712071

20722072
sign = '' if attr.type[0] == 'u' else '_signed'
2073+
suffix = 'ULL' if attr.type[0] == 'u' else 'LL'
20732074
cw.block_start(line=f'static const struct netlink_range_validation{sign} {c_lower(attr.enum_name)}_range =')
20742075
members = []
20752076
if 'min' in attr.checks:
2076-
members.append(('min', attr.get_limit('min')))
2077+
members.append(('min', str(attr.get_limit('min')) + suffix))
20772078
if 'max' in attr.checks:
2078-
members.append(('max', attr.get_limit('max')))
2079+
members.append(('max', str(attr.get_limit('max')) + suffix))
20792080
cw.write_struct_init(members)
20802081
cw.block_end(line=';')
20812082
cw.nl()

0 commit comments

Comments
 (0)