From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1B1C433FE for ; Fri, 8 Apr 2022 12:58:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236022AbiDHNAJ (ORCPT ); Fri, 8 Apr 2022 09:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232841AbiDHNAE (ORCPT ); Fri, 8 Apr 2022 09:00:04 -0400 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DC6A10E8; Fri, 8 Apr 2022 05:57:59 -0700 (PDT) Received: from fraeml710-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4KZdXh08ymz67kSQ; Fri, 8 Apr 2022 20:56:04 +0800 (CST) Received: from lhreml724-chm.china.huawei.com (10.201.108.75) by fraeml710-chm.china.huawei.com (10.206.15.59) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 8 Apr 2022 14:57:56 +0200 Received: from [10.47.91.39] (10.47.91.39) by lhreml724-chm.china.huawei.com (10.201.108.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 8 Apr 2022 13:57:55 +0100 Message-ID: <7b3885e3-dbae-ff0b-21dc-c28d635d950b@huawei.com> Date: Fri, 8 Apr 2022 13:57:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH 1/4] scsi: core: constify pointer to scsi_host_template To: Krzysztof Kozlowski , "James E.J. Bottomley" , "Martin K. Petersen" , Alim Akhtar , "Avri Altman" , Doug Gilbert , , References: <20220408103027.311624-1-krzysztof.kozlowski@linaro.org> <2a88a992-641a-b3ff-fe39-7a61fff87cb6@huawei.com> <4c3be5b6-50ef-9e9a-6cee-9642df943342@linaro.org> From: John Garry In-Reply-To: <4c3be5b6-50ef-9e9a-6cee-9642df943342@linaro.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.47.91.39] X-ClientProxiedBy: lhreml718-chm.china.huawei.com (10.201.108.69) To lhreml724-chm.china.huawei.com (10.201.108.75) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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