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: <CAHp75Vc-BDtz62zS2_Chi=UgZJw7vvUzJ34CEHd-RCjqnOjBew@mail.gmail.com>
Date:   Mon, 4 Jun 2018 13:06:45 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Yisheng Xie <xieyisheng1@...wei.com>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        "David S. Miller" <davem@...emloft.net>,
        Anthony Yznaga <anthony.yznaga@...cle.com>,
        Pavel Tatashin <pasha.tatashin@...cle.com>,
        sparclinux@...r.kernel.org
Subject: Re: [PATCH v2 21/21] sparc64: use match_string() helper

On Mon, Jun 4, 2018 at 4:06 AM, Yisheng Xie <xieyisheng1@...wei.com> wrote:
> Hi Andy,
>
> On 2018/6/1 19:34, Andy Shevchenko wrote:
>> On Thu, May 31, 2018 at 2:11 PM, Yisheng Xie <xieyisheng1@...wei.com> wrote:
>>> match_string() returns the index of an array for a matching string,
>>> which can be used instead of open coded variant.
>>
>>> @@ -512,10 +512,9 @@ static unsigned long __init mdesc_cpu_hwcap_list(void)
>>>                                 break;
>>>                         }
>>>                 }
>>
>> It seems previous loop also can be replaced.
>
> No, because the there is an NULL in the middle of the array hwcaps:
>  static const char *hwcaps[] = {
>           "flush", "stbar", "swap", "muldiv", "v9",
>           "ultra3", "blkinit", "n2",
>
>           /* These strings are as they appear in the machine description
>            * 'hwcap-list' property for cpu nodes.
>            */
>           "mul32", "div32", "fsmuld", "v8plus", "popc", "vis", "vis2",
>           "ASIBlkInit", "fmaf", "vis3", "hpc", "random", "trans", "fjfmau",
>           "ima", "cspare", "pause", "cbcond", NULL /*reserved for crypto */,
>           "adp",
>   };

Actually you can.
What you need is to add string literal instead of NULL and make an
additional condition after match_string() in all users (not to many),
something like

i = match_string();
if (i < 0)
 ...
if (BIT(i) == HWCAP_SPARC_CRYPTO) // or !=
 ...

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ