[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 10:42:58 +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=KQn4fUH3mAVzi0iGnDX44c+aMziGaB7QTno6XBJ60h0=; b=mD404E554wEGEPETXoFssxZrP8Z9mXxVSOkUKGTP1jtT9COPeD5GcSBj1ciypFyIxGF3voT2lm9Zo3JswqHgPm+K+dN0Nu8TWc1WiKPBqxd13Dy5fvlH+9uC8PHhwM4mAT2PhJF8eUVsGdFr1koBgmOZKnDTnN5lx8KVd/bN6OU9S1KCoeDO9cBYj2rNJsG1hGtkne5UJS2FlgEPc0CYgsg2sekZQJQrLSMZfGtCoJr2JZqWc8lAD7XyQUO7BcxRc1n1T5BGSc/BwmlqdQD+V0yjENlFIE55mOj2CcRPFUUsMZAtTQ0IA25xLuo+NKLLVC4BHepXyFyFpv3LK03maQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XWFvE7ZFOpvIpSwQLeBbvQ5cnZUcW/RKAjbDf8U2/cXbCUQeF9wmRwmptWzd6XOkBVySVbOcV9+9arcZDb580rEjG65r/cSA1Zdb70EePwsJj8wwf0KqWmADxYsNZ/aCA1jFC78iApxO8DnDhVnn45jWtf2iF19v8CE8roLoQdjw0VcL78eoK+s4+jOq00TWDAQxVpjXStCpOF2XMOpYX2/vmGcvD+12TJcCRBM8UDRCUY6wEbkYVh9gFUiWbdPpSQj/Qrj4YMlKB7FaUv7gheTlJy/CFsFKknd9TuiJi7gjfyeuFWEr2XKUtd/gfXdjKgMhTfJV7Q2lNAy6tYfZlg==
  • 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 08:43:10 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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).

Jan



 


Rackspace

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