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

Re: [PATCH v3 1/2] xen/device_tree: fix Eclair findings for MISRA C 2012 Rule 20.7


  • To: Michal Orzel <michal.orzel@xxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 6 Feb 2023 14:57:55 +0000
  • Accept-language: en-GB, en-US
  • 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=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=na2eRzEXYv0U2eIJkYzdDK5WRObRa3XeWd8bVJTDIMA=; b=OyZw2znp62mlbaUEfrn+w7ELINxOzJUT8tM+olc7yKV3MyElDSpSLUbfBhDQSuzB0c1c5VF3bOkkFgGCQ5Dg74FFBjY1riNaXjZLWBNy0AH7jt7CE3DH6q+qicYbik0VStWdYo0ZyWy3lwlvSKV8lOhkXvwSNQV5Y79/mX+/GGd2Is8BbgiuOgj9yy1dApfk2WU9XTMdG+jOtWz3YEZDpQsUJf4Oujv2kqX3RD7+xBXt+k9oKy651yg88Z2N85ogB6M5m0g5vPWGPCanAno7MFCh2DWxPeDbslVRsX5qPiHh01GvlOgZxaU3MczNDR9XpFLPKn1KKreFAviJnP2koA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mjpSyn6CawGOgbUgKU3QPmZ/hL/A4qOStRrrW9LeRIGWKB4M7hJ5SCkQelBiJSfdWPNJudHAC9FnmCXbEDY024mExvILEYiD76JAU+wiPEPgNrF5ShEwXrLRUz4HuNb/xaqyBUp0NU6SrScM4hd9nFFQCaT7tKEF2GobNkFBDpob4Z7d58i1cof7U3L9C4Zg64uRMqIzWa0EexxIgAyLgdvQoB5MW5iRzp9B1gGA89DD8KvS510CiSE+zwUiieAjDverzuspF3cShFccuu8zG97eHgTsaAflx/RgF3uT3XHuaTU9c5rnr8+X4QKVRcA32/QJtH0iZlY7tUYZUmS+WQ==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>
  • Delivery-date: Mon, 06 Feb 2023 14:58:16 +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: AQHZOAMhFrHFBGWgpEqoPT1xaNlgs67B/28AgAABlgCAAAWwAA==
  • Thread-topic: [PATCH v3 1/2] xen/device_tree: fix Eclair findings for MISRA C 2012 Rule 20.7


> On 6 Feb 2023, at 14:37, Michal Orzel <michal.orzel@xxxxxxx> wrote:
> 
> Hi Luca,
> 
> On 06/02/2023 15:31, Luca Fancellu wrote:
>> 
>> 
>> Hi Xenia,
>> 
>>> On 3 Feb 2023, at 19:09, Xenia Ragiadakou <burzalodowa@xxxxxxxxx> wrote:
>>> 
>>> Signed-off-by: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
>>> ---
>>> 
>>> Changes in v3:
>>> - the fixes are based solely to Eclair findings (the tool has been
>>>   adjusted to report only those violations that can result to a bug)
>>> - reflect this in the commit title
>>> 
>>> xen/include/xen/device_tree.h | 14 +++++++-------
>>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>> 
>>> diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
>>> index a28937d12ae8..7839a199e311 100644
>>> --- a/xen/include/xen/device_tree.h
>>> +++ b/xen/include/xen/device_tree.h
>>> @@ -37,11 +37,11 @@ struct dt_device_match {
>>>    const void *data;
>>> };
>>> 
>>> -#define __DT_MATCH_PATH(p)              .path = p
>>> -#define __DT_MATCH_TYPE(typ)            .type = typ
>>> -#define __DT_MATCH_COMPATIBLE(compat)   .compatible = compat
>>> +#define __DT_MATCH_PATH(p)              .path = (p)
>>> +#define __DT_MATCH_TYPE(typ)            .type = (typ)
>>> +#define __DT_MATCH_COMPATIBLE(compat)   .compatible = (compat)
>>> #define __DT_MATCH_NOT_AVAILABLE()      .not_available = 1
>>> -#define __DT_MATCH_PROP(p)              .prop = p
>>> +#define __DT_MATCH_PROP(p)              .prop = (p)
>>> 
>>> #define DT_MATCH_PATH(p)                { __DT_MATCH_PATH(p) }
>>> #define DT_MATCH_TYPE(typ)              { __DT_MATCH_TYPE(typ) }
>>> @@ -226,13 +226,13 @@ dt_find_interrupt_controller(const struct 
>>> dt_device_match *matches);
>>> #define DT_ROOT_NODE_SIZE_CELLS_DEFAULT 1
>>> 
>>> #define dt_for_each_property_node(dn, pp)                   \
>>> -    for ( pp = dn->properties; pp != NULL; pp = pp->next )
>>> +    for ( pp = (dn)->properties; (pp) != NULL; pp = (pp)->next )
>>> 
>>> #define dt_for_each_device_node(dt, dn)                     \
>>> -    for ( dn = dt; dn != NULL; dn = dn->allnext )
>>> +    for ( dn = dt; (dn) != NULL; dn = (dn)->allnext )
>>> 
>>> #define dt_for_each_child_node(dt, dn)                      \
>>> -    for ( dn = dt->child; dn != NULL; dn = dn->sibling )
>>> +    for ( dn = (dt)->child; (dn) != NULL; dn = (dn)->sibling )
>>> 
>>> /* Helper to read a big number; size is in cells (not bytes) */
>>> static inline u64 dt_read_number(const __be32 *cell, int size)
>>> --
>>> 2.37.2
>>> 
>>> 
>> 
>> While the changes looks sensible to me, I’ve had a look in eclair but I was 
>> unable to find the findings,
>> here what findings I have in the latest report:
>> https://eclairit.com:8443/job/XEN/Target=ARM64,agent=docker1/lastBuild/eclair/packageName.832204620/fileName.1811675806/
> 
> Eclair does not report violations at the definition but rather at the use.
> Check domain_build.c for example to see the reports for 20.7 related to these 
> macros.

Wow yes that’s right, a bit annoying to link the issues! Who knows if there is 
a mode to make it point out the violation at the definition
like cppcheck.

I’ll review this patch later this week if I manage to find the time

> 
> ~Michal


 


Rackspace

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