Ludovic Courtès, le lun. 21 avril 2025 16:59:03 +0200, a ecrit:
> Samuel Thibault <samuel.thiba...@gnu.org> writes:
> > dev_read starts with if (err) return err;. Various functions do not
> > define their own err variable. I don't know the original reason for
> > this, but this looks fishy to me, and local variables should probably
> > always be used, patch welcome.
> 
> I wondered about that: access to the underlying device is serialized
> (‘trivfs_S_io_read’ & co. start by acquiring ‘global_lock’), and there’s
> this global ‘err’ variable, and I thought the intent may be to memorize
> what error occurred previously and avoid initiating a new device
> operation until it is cleared.
> 
> So at least this seems to be internally consistent, no?

Possibly, but this is surprising, and I would be not surprised at all
that some changeset got this wrong. See e.g. start_output which uses the
global variable while start_input which doesn't. At the very least, I
would call this global variable another way.

Samuel

Reply via email to