lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201120151307.4d9e3ef092ba01a325db7ce2@linux-foundation.org>
Date:   Fri, 20 Nov 2020 15:13:07 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Alex Shi <alex.shi@...ux.alibaba.com>
Cc:     Hugh Dickins <hughd@...gle.com>, Yu Zhao <yuzhao@...gle.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Michal Hocko <mhocko@...e.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH next] mm/vmscan: __isolate_lru_page_prepare clean up

On Fri, 20 Nov 2020 16:03:33 +0800 Alex Shi <alex.shi@...ux.alibaba.com> wrote:

> The function just return 2 results, so use a 'switch' to deal with its
> result is unnecessary, and simplify it to a bool func as Vlastimil
> suggested.
> 
> Also removed 'goto' in using by reusing list_move().
> 
> ...
>
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1540,7 +1540,7 @@ unsigned int reclaim_clean_pages_from_list(struct zone *zone,
>   */
>  int __isolate_lru_page_prepare(struct page *page, isolate_mode_t mode)
>  {
> -	int ret = -EBUSY;
> +	int ret = false;
>  
>  	/* Only take pages on the LRU. */
>  	if (!PageLRU(page))
> @@ -1590,7 +1590,7 @@ int __isolate_lru_page_prepare(struct page *page, isolate_mode_t mode)
>  	if ((mode & ISOLATE_UNMAPPED) && page_mapped(page))
>  		return ret;
>  
> -	return 0;
> +	return true;
>  }

The resulting __isolate_lru_page_prepare() is rather unpleasing.

- Why return an int and not a bool?

- `int ret = false' is a big hint that `ret' should have bool type!

- Why not just remove `ret' and do `return false' in all those `return
  ret' places?

- The __isolate_lru_page_prepare() kerneldoc still says "returns 0 on
  success, -ve errno on failure".  

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ