[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XEN PATCH] xen/PCI: address violations of MISRA C:2012 Rules 8.2 and 8.3


  • To: Federico Serafini <federico.serafini@xxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Mon, 11 Sep 2023 17:21:51 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sm+fjSskQ3ewVSIp+iaOqiiJ7JXg/o9Jyz16SdfmkRE=; b=HK+Ds/9HJwTyY4PrF4fWpmfjOFU5rSMmHBfFSfLK/fmv9uBR8LG5EREwQaDPogFYUqyEbK9o9JznZKrw45wIuQwmSS6gakAtNDd06V8B19Wt3SnaXbZuc/yx6Vn7K+L2r1yYtVufAIaJ59Ifu4vOB/+m/IIN367XJAB0ZqkdbYAXSM/fONyNAv2y9XFSqK62S1foG76/V8yR5QSNMxKDYFoW5GtvGMlts9mTaR3Dlu2Wfr7BI99G0/dBGmxZJB36zjI4R6eXP+O+k1nV7Y+sJ2jGhthh4879cNFbsLP8BsaIlc36e8PyZSD5LJYDF/35/JAVs5F+lepXjkbWqtFs4Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iZ6L/thjbm2kKkw8JDWy5tJmHW5O26QPmXvPumBih7t8XoPnKWTvrqpx+PANN7R063DZizAsZXeUyGyfoo2S5IcM1Ckgc1sPlZ8BGCBI3gHHkahX8bZPm595szS4gbEv3hLmQyLlQwjGtGKAY99wAGFtz+Qv87AJ/CLrWJSiqji5S2jc3PRwdFW1i/l7kfllQDdwXPKZroyqCdmuOElwN2r0SNCaNmEStYpv1myPMI6hqbEdQusrcYL8RN+nwlFLIp2B5V3A1Kr6ipAdLNDMqZdSbF20yS0R6QzZcp1Wc6joiYWUbF+0zp3LTvB/sI6DQ5Uox6jHt7Qar8Qz/xDgRw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: consulting@xxxxxxxxxxx, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Mon, 11 Sep 2023 15:22:06 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 11.09.2023 17:13, Federico Serafini wrote:
> On 11/09/23 10:42, Jan Beulich wrote:
>> On 11.09.2023 10:15, Federico Serafini wrote:
>>> Add missing parameter names and make function declarations and
>>> definitions consistent. No functional change.
>>>
>>> Signed-off-by: Federico Serafini <federico.serafini@xxxxxxxxxxx>
>>
>> Since formally correct:
>> Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
>>
>> Nevertheless, it is probably about time to mention that ...
>>
>>> @@ -198,10 +198,11 @@ int pci_find_next_cap(u16 seg, u8 bus, unsigned int 
>>> devfn, u8 pos, int cap);
>>>   int pci_find_ext_capability(int seg, int bus, int devfn, int cap);
>>>   int pci_find_next_ext_capability(int seg, int bus, int devfn, int start,
>>>                                    int cap);
>>> -const char *parse_pci(const char *, unsigned int *seg, unsigned int *bus,
>>> -                      unsigned int *dev, unsigned int *func);
>>> -const char *parse_pci_seg(const char *, unsigned int *seg, unsigned int 
>>> *bus,
>>> -                          unsigned int *dev, unsigned int *func, bool 
>>> *def_seg);
>>> +const char *parse_pci(const char *s, unsigned int *seg_p, unsigned int 
>>> *bus_p,
>>> +                      unsigned int *dev_p, unsigned int *func_p);
>>> +const char *parse_pci_seg(const char *s, unsigned int *seg_p,
>>> +                          unsigned int *bus_p, unsigned int *dev_p,
>>> +                          unsigned int *func_p, bool *def_seg);
>>
>> ... parameter renaming like this, while fulfilling the word of Misra, is
>> actually hampering readability. To someone wanting to use the function
>> and hence looking at the declaration it is entirely uninteresting
>> whether the _p suffixes are there; there were similar changes earlier on.
>> The longer names merely make reading harder and - as is the case here -
>> also may require a single declaration to wrap across more lines. I view
>> such as going against the spirit of Misra (aiming to improve code
>> clarity).
> 
> I agree with you, but, the removal of _p would lead to
> other (mechanical) changes to the function body.
> In such cases, do you think that an improvement in readability
> justifies the code churn?

I didn't suggest changing the definition. I suggested keeping declaration
and definition (slightly) out of sync.

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.