[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241113183230.4d908a54@kernel.org>
Date: Wed, 13 Nov 2024 18:32:29 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Stanislav Fomichev <stfomichev@...il.com>
Cc: Stanislav Fomichev <sdf@...ichev.me>, netdev@...r.kernel.org,
davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
linux-kernel@...r.kernel.org, horms@...nel.org, donald.hunter@...il.com,
andrew+netdev@...n.ch, kory.maincent@...tlin.com, nicolas.dichtel@...nd.com
Subject: Re: [PATCH net-next 3/7] ynl: support directional specs in
ynl-gen-c.py
On Wed, 13 Nov 2024 15:45:21 -0800 Stanislav Fomichev wrote:
> On 11/13, Jakub Kicinski wrote:
> > On Wed, 13 Nov 2024 10:10:19 -0800 Stanislav Fomichev wrote:
> > > - supported_models = ['unified']
> > > - if args.mode in ['user', 'kernel']:
> > > - supported_models += ['directional']
> > > - if parsed.msg_id_model not in supported_models:
> > > - print(f'Message enum-model {parsed.msg_id_model} not supported for {args.mode} generation')
> > > - os.sys.exit(1)
> >
> > Don't we still need to validate that it's one of the two options?
>
> I removed it because I'm assuming only two modes exist (and we support
> them both now). Are you suggesting it's better to future-proof it and
> still keep the check in case we add some new modes in the future? (or
> running against some rogue specs?)
TBH I don't remember how much precedent there is for C codegen
depending on jsonschema for spec input validation. My gut tells
me to do:
+ if family.msg_id_model == 'unified':
+ render_uapi_unified(family, cw, max_by_define, separate_ntf)
+ elif family.msg_id_model == 'directional':
+ render_uapi_directional(family, cw, max_by_define)
+ else:
+ raise ..
and then we can indeed drop the validation of the arg directly
Powered by blists - more mailing lists