linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Tatashin <pasha.tatashin@gmail.com>
To: penghao122@sina.com.cn
Cc: Linux Memory Management List <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	pasha.tatashin@oracle.com, osalvador@suse.de,
	LKML <linux-kernel@vger.kernel.org>,
	peng.hao2@zte.com.cn
Subject: Re: [PATCH] mm/sparse: remove a check that compare if unsigned variable is negative
Date: Sat, 13 Oct 2018 13:04:45 -0400	[thread overview]
Message-ID: <CAGM2reYqEpY9KbMDU6uSaCuzsyN6qcXit930vbWk54PLhvZxZg@mail.gmail.com> (raw)
In-Reply-To: <1539447319-5383-1-git-send-email-penghao122@sina.com.cn>

This is incorrect: next_present_section_nr() returns "int" and -1 no
next section, this change would lead to infinite loop.
On Sat, Oct 13, 2018 at 12:16 PM Peng Hao <penghao122@sina.com.cn> wrote:
>
>
> From: Peng Hao <peng.hao2@zte.com.cn>
>
> In all use locations for for_each_present_section_nr, variable
> section_nr is unsigned. It is unnecessary to test if it is negative.
>
> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
> ---
>  mm/sparse.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index 10b07ee..a6f9f22 100644
> --- a/mm/sparse.c
> +++ b/mm/sparse.c
> @@ -196,8 +196,7 @@ static inline int next_present_section_nr(int section_nr)
>  }
>  #define for_each_present_section_nr(start, section_nr)         \
>         for (section_nr = next_present_section_nr(start-1);     \
> -            ((section_nr >= 0) &&                              \
> -             (section_nr <= __highest_present_section_nr));    \
> +            section_nr <= __highest_present_section_nr;        \
>              section_nr = next_present_section_nr(section_nr))
>
>  static inline unsigned long first_present_section_nr(void)
> --
> 1.8.3.1
>
>

  reply	other threads:[~2018-10-13 17:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-13 16:15 [PATCH] mm/sparse: remove a check that compare if unsigned variable is negative Peng Hao
2018-10-13 17:04 ` Pavel Tatashin [this message]
2018-10-15  1:08   ` [PATCH] mm/sparse: remove a check that compare if unsignedvariable " peng.hao2
2018-10-19  8:28   ` [PATCH] mm/sparse: remove a check that compare if unsigned variable " Wei Yang

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=CAGM2reYqEpY9KbMDU6uSaCuzsyN6qcXit930vbWk54PLhvZxZg@mail.gmail.com \
    --to=pasha.tatashin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=pasha.tatashin@oracle.com \
    --cc=peng.hao2@zte.com.cn \
    --cc=penghao122@sina.com.cn \
    /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;
as well as URLs for NNTP newsgroup(s).