Re: [PATCH v5 3/7] x86/mce: Make four functions return bool

From: Yazen Ghannam
Date: Wed Dec 18 2024 - 10:49:05 EST


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@xxxxxxxxxxxxx>
> Reviewed-by: Sohil Mehta <sohil.mehta@xxxxxxxxx>
> Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@xxxxxxxxx>
> ---

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

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