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: <7b3885e3-dbae-ff0b-21dc-c28d635d950b@huawei.com>
Date:   Fri, 8 Apr 2022 13:57:52 +0100
From:   John Garry <john.garry@...wei.com>
To:     Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
        "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Alim Akhtar <alim.akhtar@...sung.com>,
        "Avri Altman" <avri.altman@....com>,
        Doug Gilbert <dgilbert@...erlog.com>,
        <linux-scsi@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template

On 08/04/2022 13:32, Krzysztof Kozlowski wrote:
> On 08/04/2022 14:14, John Garry wrote:
>> On 08/04/2022 11:30, Krzysztof Kozlowski wrote:
>>> Several pointers to 'struct scsi_host_template' do not modify it, so
>>> made them const for safety.
>>>
>> Is this standard practice? What is so special here?
> This is standard practice and there is nothing special here. Pointers to
> const are preferred because:
> 1. They add safety if data is actually const. This is not yet the case,
> but scsi_host_template allocation could be made const with some effort.

To me this seems better, but I think that some drivers might modify 
their scsi_host_template (so not possible)

> 2. The more const variables, the easier function contents and its impact
> is to understand. This is actually the biggest benefit when dealing with
> code touching different structures.
> 
> In general, constifying is a common practice everywhere in the kernel.

Thanks,
John

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ