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: <CAPhsuW7B=n6HYSCJxfQbumO4-e5TacvUGbOXBMHfB-TvD0M7zA@mail.gmail.com>
Date:   Mon, 25 Apr 2022 14:20:47 -0700
From:   Song Liu <song@...nel.org>
To:     David Sloan <david.sloan@...eticom.com>
Cc:     linux-raid <linux-raid@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>,
        Logan Gunthorpe <logang@...tatee.com>
Subject: Re: [PATCH] md: Replace role magic numbers with defined constants

On Thu, Apr 21, 2022 at 12:46 PM David Sloan <david.sloan@...eticom.com> wrote:
>
> There are several instances where magic numbers are used in md.c instead
> of the defined constants in md_p.h. This patch set improves code
> readability by replacing all occurrences of 0xffff, 0xfffe, and 0xfffd when
> relating to md roles with their equivalent defined constant.
>
> Signed-off-by: David Sloan <david.sloan@...eticom.com>
> Reviewed-by: Logan Gunthorpe <logang@...tatee.com>

Thanks for the clean up!

> ---
>  drivers/md/md.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/md/md.c b/drivers/md/md.c
> index 309b3af906ad..b34b72fc5887 100644
> --- a/drivers/md/md.c
> +++ b/drivers/md/md.c
> @@ -2645,11 +2645,12 @@ static bool does_sb_need_changing(struct mddev *mddev)
>         rdev_for_each(rdev, mddev) {
>                 role = le16_to_cpu(sb->dev_roles[rdev->desc_nr]);
>                 /* Device activated? */
> -               if (role == 0xffff && rdev->raid_disk >=0 &&
> +               if (role == MD_DISK_ROLE_SPARE && rdev->raid_disk >= 0 &&
>                     !test_bit(Faulty, &rdev->flags))
>                         return true;
>                 /* Device turned faulty? */
> -               if (test_bit(Faulty, &rdev->flags) && (role < 0xfffd))
> +               if (test_bit(Faulty, &rdev->flags) &&
> +                   role < MD_DISK_ROLE_JOURNAL)

I changed this to role < MD_DISK_ROLE_MAX.

Also made some minor style changes, and applied it to md-next.

Thanks,
Song

>                         return true;
>         }

[...]

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ