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: <20250424193600.2ae5a2d8@kernel.org>
Date: Thu, 24 Apr 2025 19:36:00 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Jacob Keller <jacob.e.keller@...el.com>
Cc: <davem@...emloft.net>, <netdev@...r.kernel.org>, <edumazet@...gle.com>,
 <pabeni@...hat.com>, <andrew+netdev@...n.ch>, <horms@...nel.org>,
 <donald.hunter@...il.com>, <sdf@...ichev.me>
Subject: Re: [PATCH net-next 03/12] tools: ynl-gen: fill in missing empty
 attr lists

On Thu, 24 Apr 2025 08:49:32 -0700 Jacob Keller wrote:
> >  class Operation(SpecOperation):
> >      def __init__(self, family, yaml, req_value, rsp_value):
> > +        # Fill in missing operation properties (for fixed hdr-only msgs)
> > +        for mode in ['do', 'dump', 'event']:
> > +            if mode not in yaml.keys():
> > +                continue
> > +            for direction in ['request', 'reply']:
> > +                if direction not in yaml[mode]:
> > +                    continue
> > +                if 'attributes' not in yaml[mode][direction]:
> > +                    yaml[mode][direction]['attributes'] = []
> > +  
> 
> 
> This feels like there should be a more "pythonic" way to do this without
> as much boilerplate.. but I can't actually come up with a better suggestion.
> 
> Maybe some sort of try/except with a catch for KeyError or something..
> not really sure I like that more than the list approach either tho... I
> guess it would be:
> 
> for mode in ['do', 'dump', 'event']:
>   for direction in ['request', 'reply']:
>     try:
>       yaml[mode][direction].setdefault('attributes', [])
>     except KeyError:
>       pass

I like this better, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ