From: Andrew Morton <akpm@linux-foundation.org>
To: Rolf Eike Beer <eb@emlix.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/6] mm: pagewalk: make error checks more obvious
Date: Mon, 22 Aug 2022 13:53:16 -0700 [thread overview]
Message-ID: <20220822135316.ee37696392ff756b1c810059@linux-foundation.org> (raw)
In-Reply-To: <2203731.iZASKD2KPV@devpool047>
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.
next prev parent reply other threads:[~2022-08-22 20:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-22 12:59 [PATCH 0/6] Minor improvements for pagewalk code Rolf Eike Beer
2022-08-22 13:00 ` [PATCH 2/6] mm: pagewalk: don't check vma in walk_page_range_novma() Rolf Eike Beer
2022-08-22 13:01 ` [PATCH 3/6] mm: pagewalk: fix documentation of PTE hole handling Rolf Eike Beer
2022-08-22 13:02 ` [PATCH 4/6] mm: pagewalk: add api documentation for walk_page_range_novma() Rolf Eike Beer
2022-08-22 13:03 ` [PATCH 5/6] mm: pagewalk: allow walk_page_range_novma() without mm Rolf Eike Beer
2022-08-22 13:04 ` [PATCH 6/6] mm: pagewalk: move variables to more local scope, tweak loops Rolf Eike Beer
[not found] ` <2203731.iZASKD2KPV@devpool047>
2022-08-22 20:53 ` Andrew Morton [this message]
2022-08-24 11:00 ` [PATCH 7/6] mm: pagewalk: add back missing variable initializations Rolf Eike Beer
2022-08-24 15:08 ` Nathan Chancellor
[not found] <202208231649.7QKavhA3-lkp@intel.com>
2022-08-23 9:25 ` [PATCH 1/6] mm: pagewalk: make error checks more obvious Rolf Eike Beer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220822135316.ee37696392ff756b1c810059@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=eb@emlix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox