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

Re: [PATCH 0/7] Fix MISRA C 2012 Rule 20.7 violations


  • To: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
  • From: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • Date: Thu, 1 Sep 2022 13:34:09 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=PxRw09bemW009EVnRvkMOlocZZXMODx4PFwP1puPuW4=; b=ilfApVadfPbgmAwFG+HD7jng+q5IfZhU26zAM/NUdGoU6GCSF2xm1G55xo7dreGyWUpDWwIu4UO905bITYJIi2pqMjYRyvmxC6SCrkjJ07uTXtrGsiOkbHPZBTmQi3sMtP/cpK3KH0Q+UZeurrIXumDBozIJqxHtXupsCj5HLEmlnA0N4wsVx5+RxknrvpyH5x+GOBvtoNJ6HoFub2MnciwYDQ7QyUCpJfYA2lFdyT8fBlanPj012uSSUdF/85SDk43QGugRMBwQRqKKT/i4azb08+SdIVhnzOSq1bLUJAx9ZXaEhX+brHqh0dUnqLp3tGkX4IJR5hby58He52c97Q==
  • 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=PxRw09bemW009EVnRvkMOlocZZXMODx4PFwP1puPuW4=; b=VhD62jDQe+DopgorYDM6DfNyZ147LCTwcNLUDEUj1SYGzefFsFFF4FW8FKqYjWiHSk1RFxOCjt9slkRoCidh4i7CRA8m+SzlBaqOkO1RuPiZHkn0dbnYk6mfMrrp8X43qsXwrClofh9DeNOzqGsJch9QsIBs8/jpRG1gqs4QvSKrGQriqqFpQ+oMdBPqhyOGL6eP5iFYBiCaQlblKrQ0ZeNCldmTL9Z+dczOM+4AGqhLHwwoQIf/7G+1KPS0iph/ZDorvsF3TMpsdCju/WMyXX+4TNDc/OjSw8KJBvueRuHnjIrqZVnQtaYBHBpe80Y4AbE25Lz6x5vcAa2xALo/SQ==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=g7VCfSoLX4aSrypoRWTLXNfUio1FNYEVQ5V/lgjQE8ZX+hVQfmIZH+hzkkZYJeZwI4xsB97gleTBI6s6ReFiMC/BqvkimQV046XSmp7IY+rjNs+iEwappcBfFmVqxGtPIHXQI0Y6mu0T+f4HcGQQt0NFgxVikuWuceuldHRYe69BKdTLfyuVSt2bWcK4x47NcNOpQ5RHfYDp+eQCtpvSp1Ely2g8S0J8zXXgFmApNyHzoid3KCCrJP5EIbS0vubOdVpMl4t7d7U9zwirbCuEqFBs6ALmEcA5hi28Fgjmv4XexxtGZqUlsh1CjKaI7aLBjY7hcSD7emt77g2MBH3jYg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hcd9S8YN3uJFe+UASidkv+AZpdLEtNqwdSH7koKvtMfDPBsOItBKzhfmZ8QWijEJzLz/LpyQTblPDfNUypdlJvrqkJDlC9YldQyZRrPuHqbkDHMgdSuZ72zK8BIfrK9qFJYhh3E/do8Mw+g9Mm8JdsxyOffNbmqAPJ7J1Rvfy0jRPenD75AY7bUfhAVw9dW1e52v5vIWm/UdRqNqQGM/+0EN5UApXzovcZIRMxPhbA4/vJ64a1o3QzE2AQUHYitK4kdXkD4SxKFBSkBnUidVVSZpFip55QegfPT/y0XghR0WbHEvSX+hQiM5lujNh3MB3f6f2bFqCSex2bVibJYz3w==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 01 Sep 2022 13:34:25 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHYtAQe6qSxrEQGbEumth30q9ivnq3Jq9wAgAC2VQCAAETOgA==
  • Thread-topic: [PATCH 0/7] Fix MISRA C 2012 Rule 20.7 violations

Hi Xenia,

> On 1 Sep 2022, at 10:27, Xenia Ragiadakou <burzalodowa@xxxxxxxxx> wrote:
> 
> 
> On 9/1/22 01:35, Stefano Stabellini wrote:
>> Patches 1, 4, and 6 are already committed. I plan to commit patches 2, 3
>> and 5 in the next couple of days.
>> Patch 7 needs further discussions and it is best addressed during the
>> next MISRA C sync-up.
> 
> I would like to share here, before the next MISRA C sync, my understandings 
> that will hopefully resolve a wrong impression of mine, that I may have 
> spread around, regarding this rule.
> There was a misunderstanding regarding the rule 20.7 from my part and I think 
> that Jan is absolutely right that parenthesizing macro parameters used as 
> function arguments is not required by the rule.
> 
> The rule 20.7 states "Expressions resulting from the expansion of macro 
> parameters shall be enclosed in parentheses" and in the rationale of the rule 
> states "If a macro parameter is not being used as an expression then the 
> parentheses are not necessary because no operators are involved.".
> 
> Initially, based on the title, my understanding was that it requires for the 
> expression resulting from the expansion of the macro to be enclosed in 
> parentheses. Then, based on the rule explanation and the examples given,  my 
> understanding was that it requires the macro parameters that are used as 
> expressions to be enclosed in parentheses.
> But, after re-thinking about it, the most probable and what makes more sense, 
> is that it require parentheses around the macro parameters that are part of 
> an expression and not around those that are used as expressions.
> 
> Therefore, macro parameters being used as function arguments are not required 
> to be enclosed in parentheses, because the function arguments are part of an 
> expression list, not of an expression (comma is evaluated as separator, not 
> as operator).
> While, macro parameters used as rhs and lhs expressions of the assignment 
> operator are required to be enclosed in parentheses because they are part of 
> an assignment expression.
> 
> I verified that the violation reported by cppcheck is not due to missing 
> parentheses around the function argument (though still I have not understood 
> the origin of the warning). Also, Eclair does not report it.
> 
> Hence, it was a misunderstanding of mine and there is no inconsistency, with 
> respect to this rule, in adding parentheses around macro parameters used as 
> rhs of assignments. The rule does not require adding parentheses around macro 
> parameters used as function arguments and neither cppcheck nor Eclair report 
> violation for missing parentheses around macro parameters used as function 
> arguments.


Thanks a lot for the detailed explanation :-)

What you say does make sense and I agree with your analysis here, only protect 
when part of an expression and not use as a subsequent parameter (for a 
function or an other macro).

Regards
Bertrand

> 
>> On Fri, 19 Aug 2022, Xenia Ragiadakou wrote:
>>> Xenia Ragiadakou (7):
>>>   xen/arm: gic_v3_its: Fix MISRA C 2012 Rule 20.7 violations
>>>   xsm/flask: sidtab: Fix MISRA C 2012 Rule 20.7 violations
>>>   xen/elf: Fix MISRA C 2012 Rule 20.7 violations
>>>   xen/vgic: Fix MISRA C 2012 Rule 20.7 violation
>>>   xen/rbtree: Fix MISRA C 2012 Rule 20.7 violation
>>>   xen/arm: processor: Fix MISRA C 2012 Rule 20.7 violations
>>>   xen/device_tree: Fix MISRA C 2012 Rule 20.7 violations
>>> 
>>>  xen/arch/arm/include/asm/gic_v3_its.h | 10 +++++-----
>>>  xen/arch/arm/include/asm/new_vgic.h   |  2 +-
>>>  xen/arch/arm/include/asm/processor.h  |  4 ++--
>>>  xen/include/xen/device_tree.h         |  6 +++---
>>>  xen/include/xen/elfstructs.h          |  4 ++--
>>>  xen/lib/rbtree.c                      |  2 +-
>>>  xen/xsm/flask/ss/sidtab.c             |  8 ++++----
>>>  7 files changed, 18 insertions(+), 18 deletions(-)
>>> 
>>> -- 
>>> 2.34.1
>>> 
> 
> -- 
> Xenia




 


Rackspace

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