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

Re: [PATCH] xen/char: imx-lpuart: Fix MISRA C 2012 Rule 20.7 violation


  • To: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Tue, 2 Aug 2022 15:49:48 +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=MjHhj687bB1N/fUDO+UxrkaUXeca6WM44E+lwGtUS8A=; b=MaIjFG8WwiGFve7k1kbYO3LUlgAtw1aEJv8Hu52MI4orSBo8NAPp3a8Yy8D+X6LoRvCpX0F0RcAC+S5UoDSxcJIGgMB5Ax3IYKH7pyksTOmxYk5DL5fk0xN2WNlFMPLF4l006qqqLP4xd9hLGTKXXGYrMLxPWTUeFw335zpMIqgt7Gi2NX8DiKRgL3sQPvJbHPNKGK0vvAZBHXY9i3Q/rV/v+rKE/Dzm78LocGBiOA7vxtXDo8TUb/H9H0lcmvi8YL42Cr/plfFPGZelfj+B59IqDR2wf89Ix6eL8BRN38Hpw22OF8/rYnz6Kv5xnu15NvArzyi5vIVmufdRX59kWw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XmBGHElTdgyJhMqSPvVTyBnqJk8uEbxFSz9WvOzJ9nmu8nuM7h8GjMm6QwFb84aOytrjt6PVETmzC3eKekcN29a/okA25cWNg10/L+h0NQ6y/Rnk/c36FCoLaNtF48OKchODM+Xt4t90NbK2kOvjDAey0Pl8WVQ7lDLstuMs8cm0MGljY+KuVYsI6zURvHafxNbfkFDuKPpf1uY04X5CaUJrodn+9YH1zXeXMcOXj8I9qyll/Qpi2hCrU/FM6eQLceXST4f3yUeog0IP2uOJ+O1ojCi9yT4Odqvkhk2FR5pwezxRNqlZ8k+tLcbBAOnDDT85z6xnJt5Hy3+GzO4P9w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Tue, 02 Aug 2022 13:49:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 02.08.2022 14:40, Xenia Ragiadakou wrote:
> On 8/2/22 14:58, Jan Beulich wrote:
>> On 02.08.2022 09:54, Xenia Ragiadakou wrote:
>>> --- a/xen/drivers/char/imx-lpuart.c
>>> +++ b/xen/drivers/char/imx-lpuart.c
>>> @@ -26,8 +26,8 @@
>>>   #include <asm/imx-lpuart.h>
>>>   #include <asm/io.h>
>>>   
>>> -#define imx_lpuart_read(uart, off)       readl((uart)->regs + off)
>>> -#define imx_lpuart_write(uart, off, val) writel((val), (uart)->regs + off)
>>> +#define imx_lpuart_read(uart, off)       readl((uart)->regs + (off))
>>> +#define imx_lpuart_write(uart, off, val) writel((val), (uart)->regs + 
>>> (off))
>>
>> As elsewhere before I think at the same time you want to drop the
>> parentheses from the single use of "val".
>>
> 
> In general I do not want to include irrelevant changes in my patches.
> Also, here, I do not want to drop the parentheses from val because the 
> removal of the parentheses
> - consists a violation of the rule 20.7
> - would allow the following to compile
> #define VAL x, y, z);(
> imx_lpuart_write(uart, off, VAL)

Parenthesization won't help against all forms of odd use of parentheses
in macro expansions anyway. Maybe MISRA should (or even does) have a
rule disallowing unbalanced parentheses (an square brackets) in macro
expansions ...

> - is not justifiable (i.e does not fix a bug, does not result in more 
> readable code etc)

As said before, I very much view too many parentheses as affecting
readability.

> I understand that the rest of the community does not agree with adding 
> parentheses around macro parameters used as function arguments

This may indeed be the case, while ...

> and as 
> the right-side operand of the assignment operator,

... iirc for this one it was only Julien so far who disliked the
addition of parentheses.

> but I consider them 
> useful and I do not want to remove them myself. Maybe somebody else from 
> the community could do that.

Fair enough; my remark was indeed _only_ a remark - the maintainers
will have to judge in the end.

Jan



 


Rackspace

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