tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Some changes to autoconfiguration APIs



On Sun, 1 Aug 2021 at 21:50, Jason Thorpe <thorpej%me.com@localhost> wrote:
>
> > On Aug 1, 2021, at 12:48 PM, David Brownlee <abs%absd.org@localhost> wrote:
> >
> > Possible  thought to provide type safety with automatic versioning.
> >
> > Use C99 initializers with a CF_VERSION define. When cfargs changes we
> > bump CF_VERSION.
> >
> > config_found() needs to check passed cf_version and convert for old
> > versions. We are still left with a long tail of conversion code in
> > config_found(), but callers Just Work.
> >
> >       config_found(CF_VERSION, self, whatever, (const struct cfargs *){
> >           .search = ...,
> >           .locators = ...,
> >       })
>
> I would probably hide it in a macro (part of what I object to about this method, which was floated before, is that it is needlessly verbose).
>
> What do you propose should be the behavior if the versions don't match?  I have an idea in mind, but I want to hear a concrete proposal first.

Well, we're well into into perl TMTOWTDI territory here, but my first
thought would be:
- We start with CF_VERSION 1 and struct cfargs
- when bumping from 1 to 2, copy the existing cfargs to cfargs_v1 then
update, and add a convert_from_cfargs_v1 function
- config_found() starts by checking if cf_version != CF_VERSION and
calls convert_from_cfargs_v1 as needed
- when bumping from 2 to 3, repeat with _v2, plus update
convert_from_cfargs_v1, and add a new case to the start of
config_found()

David


Home | Main Index | Thread Index | Old Index