Re: [PATCH 1/8] btrfs: Make get_state_failrec return failrec directly

David Sterba
2020-07-02T13:30:10Z

On Thu, Jul 02, 2020 at 09:07:51AM -0400, Josef Bacik wrote:
> On 7/2/20 8:23 AM, Nikolay Borisov wrote:
> > +struct io_failure_record *get_state_failrec(struct extent_io_tree *tree,
> > + u64 start)
> > {
> > struct rb_node *node;
> > struct extent_state *state;
> > - int ret = 0;
> > + struct io_failure_record *failrec;
>
> Seems we can just do
>
> struct io_failure_record *failrec = ERR_PTR(-ENOENT);
>
> here and avoid the extra stuff below, as we only ever return -ENOENT on failure.

I'm not a fan of this pattern, setting the error code just before the
label is IMHO more clear and one does not have to look up the initial
value.