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] [day] [month] [year] [list]
Message-ID: <ab607667-888b-11bf-ac13-a69577f067dd@molgen.mpg.de>
Date:   Tue, 26 Oct 2021 10:26:41 +0200
From:   Paul Menzel <pmenzel@...gen.mpg.de>
To:     Jiasheng Jiang <jiasheng@...as.ac.cn>
Cc:     linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
        Song Liu <song@...nel.org>
Subject: Re: [PATCH] md/raid5: Fix implicit type conversion

Dear Jiasheng,


On 26.10.21 10:12, Jiasheng Jiang wrote:
> The variable 'cpu' is defined as ULONG.
> However in the for_each_present_cpu, its value is assigned to -1.
> That doesn't make sense and in the cpumask_next() it is implicitly
> type conversed to INT.

The description of the macro in `include/linux/cpumask.h` says:

>  * for_each_cpu - iterate over every cpu in a mask
>  * @cpu: the (optionally unsigned) integer iterator
>  * @mask: the cpumask pointer


> It is universally accepted that the implicit type conversion is
> terrible.
> Also, having the good programming custom will set an example for
> others.
> Thus, it might be better to change the definition of 'cpu' from UINT
> to INT.

Maybe get the macro description fixed first, and then update the users?

> Fixes: 738a273 ("md/raid5: fix allocation of 'scribble' array.")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
>   drivers/md/raid5.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index 7d4ff8a..c7b88eb 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -2425,7 +2425,7 @@ static int scribble_alloc(struct raid5_percpu *percpu,
>   
>   static int resize_chunks(struct r5conf *conf, int new_disks, int new_sectors)
>   {
> -	unsigned long cpu;
> +	int cpu;

Why not `long cpu`?

>   	int err = 0;
>   
>   	/*
> 


Kind regards,

Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ