lkml.org 
[lkml]   [2022]   [Aug]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/6] mm: pagewalk: make error checks more obvious
On Mon, 22 Aug 2022 15:00:05 +0200 Rolf Eike Beer <eb@emlix.com> wrote:

> The err variable only needs to be checked when it was assigned directly
> before, it is not carried on to any later checks. Move the checks into the
> same "if" conditions where they are assigned. Also just return the error at
> the relevant places. While at it move these err variables to a more local
> scope at some places.
>
> ...
>
> @@ -593,16 +608,15 @@ int walk_page_mapping(struct address_space *mapping, pgoff_t first_index,
> walk.mm = vma->vm_mm;
>
> err = walk_page_test(vma->vm_start, vma->vm_end, &walk);
> - if (err > 0) {
> - err = 0;
> - break;
> - } else if (err < 0)
> - break;
> + if (err > 0)
> + return 0;
> + else if (err < 0)
> + return err;
>
> err = __walk_page_range(start_addr, end_addr, &walk);
> if (err)
> - break;
> + return err;
> }
>
> - return err;
> + return 0;
> }

I'm not really a fan of multiple return points - it tends to lead to
locking/resource leaks as the code evolves. I don't really think it's
worth redoing the patch for this reason though; the rest looks good.

\
 
 \ /
  Last update: 2022-08-22 22:55    [W:0.158 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site