lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD4GDZyfpU427kmj4YrW8KAr0HWOb=yqt6k6c-esX9q-VAv0CQ@mail.gmail.com>
Date: Wed, 21 Feb 2024 18:12:35 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: Jiri Pirko <jiri@...nulli.us>
Cc: netdev@...r.kernel.org, kuba@...nel.org, pabeni@...hat.com, 
	davem@...emloft.net, edumazet@...gle.com, jacob.e.keller@...el.com, 
	swarupkotikalapudi@...il.com, sdf@...gle.com, lorenzo@...nel.org, 
	alessandromarcolini99@...il.com
Subject: Re: [patch net-next v2 2/3] tools: ynl: process all scalar types
 encoding in single elif statement

On Wed, 21 Feb 2024 at 15:54, Jiri Pirko <jiri@...nulli.us> wrote:
>
> From: Jiri Pirko <jiri@...dia.com>
>
> As a preparation to handle enums for scalar values, unify the processing
> of all scalar types in a single elif statement.

LGTM.

Reviewed-by: Donald Hunter <donald.hunter@...il.com>

> Signed-off-by: Jiri Pirko <jiri@...dia.com>
> ---
>  tools/net/ynl/lib/ynl.py | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
> index 4a44840bab68..38244aff1ec7 100644
> --- a/tools/net/ynl/lib/ynl.py
> +++ b/tools/net/ynl/lib/ynl.py
> @@ -473,14 +473,14 @@ class YnlFamily(SpecFamily):
>                  attr_payload = self._encode_struct(attr.struct_name, value)
>              else:
>                  raise Exception(f'Unknown type for binary attribute, value: {value}')
> -        elif attr.is_auto_scalar:
> +        elif attr['type'] in NlAttr.type_formats or attr.is_auto_scalar:
>              scalar = int(value)
> -            real_type = attr["type"][0] + ('32' if scalar.bit_length() <= 32 else '64')
> -            format = NlAttr.get_format(real_type, attr.byte_order)
> -            attr_payload = format.pack(int(value))
> -        elif attr['type'] in NlAttr.type_formats:
> -            format = NlAttr.get_format(attr['type'], attr.byte_order)
> -            attr_payload = format.pack(int(value))
> +            if attr.is_auto_scalar:
> +                attr_type = attr["type"][0] + ('32' if scalar.bit_length() <= 32 else '64')
> +            else:
> +                attr_type = attr["type"]
> +            format = NlAttr.get_format(attr_type, attr.byte_order)
> +            attr_payload = format.pack(scalar)
>          elif attr['type'] in "bitfield32":
>              attr_payload = struct.pack("II", int(value["value"]), int(value["selector"]))
>          elif attr['type'] == 'sub-message':
> --
> 2.43.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ