Message ID | 20240219172525.71406-2-jiri@resnulli.us (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | netlink: specs: devlink: add the rest of missing attribute definitions | expand |
On Mon, 19 Feb 2024 18:25:17 +0100 Jiri Pirko wrote: > elif attr["type"] == 'flag': > + if value == False: > + return b'' how about "if value:" ? It could also be null / None or some other "false" object.
Mon, Feb 19, 2024 at 09:42:22PM CET, kuba@kernel.org wrote: >On Mon, 19 Feb 2024 18:25:17 +0100 Jiri Pirko wrote: >> elif attr["type"] == 'flag': >> + if value == False: >> + return b'' > >how about "if value:" ? It could also be null / None or some other >"false" object. Sure, why not.
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py index f45ee5f29bed..108fe7eadd93 100644 --- a/tools/net/ynl/lib/ynl.py +++ b/tools/net/ynl/lib/ynl.py @@ -459,6 +459,8 @@ class YnlFamily(SpecFamily): attr_payload += self._add_attr(attr['nested-attributes'], subname, subvalue, sub_attrs) elif attr["type"] == 'flag': + if value == False: + return b'' attr_payload = b'' elif attr["type"] == 'string': attr_payload = str(value).encode('ascii') + b'\x00'