Re: [PATCH] mm, sparse: remove check with __highest_present_section_nr in for_each_present_section_nr()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 11, 2018 at 11:51:28AM +0800, Wei Yang wrote:
>A valid present section number is in [0, __highest_present_section_nr].
>And the return value of next_present_section_nr() meets this
>requirement. This means it is not necessary to check it with

            ^ , if it is not (-1)

Would like to add this to be more exact.

>__highest_present_section_nr again in for_each_present_section_nr().
>
>Since we pass an unsigned long *section_nr* to
>for_each_present_section_nr(), we need to cast it to int before
>comparing.
>
>Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
>---
> mm/sparse.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>diff --git a/mm/sparse.c b/mm/sparse.c
>index a4fdbcb21514..9eaa8f98a3d2 100644
>--- a/mm/sparse.c
>+++ b/mm/sparse.c
>@@ -197,8 +197,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));	\
>+	     (int)section_nr >= 0;				\
> 	     section_nr = next_present_section_nr(section_nr))
> 
> static inline unsigned long first_present_section_nr(void)
>-- 
>2.15.1

-- 
Wei Yang
Help you, Help me




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux