Re: [RFC PATCH v3] cleanup: Add cond_guard() to conditional guards

From: Fabio M. De Francesco
Date: Wed Jan 31 2024 - 20:26:05 EST


On Thursday, 1 February 2024 02:12:12 CET Dan Williams wrote:
> Fabio M. De Francesco wrote:
> > I just noticed that this is not the final version. It misses a semicolon.
> > Please discard this v3. I'm sending v4.
>
> Ok, but do please copy the aspect of scoped_conf_guard() to take a
> "_fail" statement argument. Passing a return code collector variable by
> reference just feels a bit too magical. I like the explicitness of
> passing the statement directly.

I'm sorry I haven't been clear. The following call convention fails my tests:

cond_guard(..., rc = -EINTR, ...);

It always returns -EINTR, regardless of the success of
down_read_interuptible(). There must be a reason that I can't see.

It works only if we immediaely return an error code:

cond_guard(..., return -EINTR, ...);

But this is not what we want since we want to check 'rc'.

Fabio