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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241218154837.GC1155365@yaz-khff2.amd.com>
Date: Wed, 18 Dec 2024 10:48:37 -0500
From: Yazen Ghannam <yazen.ghannam@....com>
To: Qiuxu Zhuo <qiuxu.zhuo@...el.com>
Cc: bp@...en8.de, tony.luck@...el.com, tglx@...utronix.de,
	dave.hansen@...ux.intel.com, mingo@...hat.com, hpa@...or.com,
	sohil.mehta@...el.com, nik.borisov@...e.com, x86@...nel.org,
	linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 3/7] x86/mce: Make four functions return bool

On Thu, Dec 12, 2024 at 10:00:59PM +0800, Qiuxu Zhuo wrote:
> Make those functions whose callers only care about success or failure
> return a boolean value for better readability. Also, update the call
> sites accordingly as the polarities of all the return values have been
> flipped.
> 
> No functional changes.
> 
> Suggested-by: Thomas Gleixner <tglx@...utronix.de>
> Reviewed-by: Sohil Mehta <sohil.mehta@...el.com>
> Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@...el.com>
> ---

Reviewed-by: Yazen Ghannam <yazen.ghannam@....com>

But one thought below...

[...]

> -static int mce_gen_pool_create(void)
> +static bool mce_gen_pool_create(void)
>  {
>  	int mce_numrecords, mce_poolsz, order;
>  	struct gen_pool *gpool;
> -	int ret = -ENOMEM;
>  	void *mce_pool;
>  
>  	order = order_base_2(sizeof(struct mce_evt_llist));
>  	gpool = gen_pool_create(order, -1);
>  	if (!gpool)
> -		return ret;
> +		return false;
>  
>  	mce_numrecords = max(MCE_MIN_ENTRIES, num_possible_cpus() * MCE_PER_CPU);
>  	mce_poolsz = mce_numrecords * (1 << order);
>  	mce_pool = kmalloc(mce_poolsz, GFP_KERNEL);
>  	if (!mce_pool) {
>  		gen_pool_destroy(gpool);
> -		return ret;
> +		return false;
>  	}
> -	ret = gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1);
> -	if (ret) {
> +
> +	if (gen_pool_add(gpool, (unsigned long)mce_pool, mce_poolsz, -1)) {
>  		gen_pool_destroy(gpool);
>  		kfree(mce_pool);
> -		return ret;
> +		return false;
>  	}
>  
>  	mce_evt_pool = gpool;
>  
> -	return ret;
> +	return true;
>  }
>  

It seems like this segment could make use of the helpers in
<linux/cleanup.h> (maybe as future work).

Thanks,
Yazen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ