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

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


  • To: Xenia Ragiadakou <burzalodowa@xxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 26 Aug 2022 10:01:12 +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=KtpTCoOMpnhczrpSIGOvpOg2fd+K2Iz3qYZ2LBR1pAA=; b=YD8zjEY16kBDKCJVvE9VElvDdVejd5EJvDOIkkBFfLgz4xyQMu8IipfOiaVeGRpG/dLaLNCwZ9Hon44Xcvs3O8+FqlQCUlCkDUf07GtONKBHU/3w2fPTHfyyxmksqZ1Yu5EnwEYTyXZmcnL2hm5idg/BOl0caz42IeEtNH0f1Qp7+1vVJeD7xY2RbavGQUGagqRGt1IPfxvOZ1++coc1vlfGE66qdVj7yoM+V22Q9vj0ge4GLOcbA8m8T7i3MiNTSwscHFfchukVXe9jH8iNR0k2X8BDowZTVIRQ4p4K9qnvDSQpps/m9uDDKWWNFftDdf2xQIzCXUAmZUKKKZvFqg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kj5Uo8eWLkS7YVGpudRfo1XXCGHZYOwQi5kq7Gu1P+jh0eE4PQkFO0fSW5jY+GXs5sJbRcw6PVgcx4BUJgHRoR3f8UvFM+G0/xCtsRLTm96SYDzxrX6HxpsgVO1RPKqeAciA/lLFlUyAcC+PwapuRivhQCrbSjSjyzi+L9Gh/izSvJmdaSuyCtxyHpv28/j2+dP6tQfhWYDrI9j8+wspTr6Sg0TYg7KxEiopq5zOEckXLcZfAB9GEaoAxL3o4hqDOJDg+4yhSxQhQUN7l1Zvtu8AEy749YQaJZBL9eMarnd/ySPIGSXgrfkUqaBMhWxbvW/FPFRZcMPAmUX+ZlLfTQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, Julien Grall <julien@xxxxxxx>, andrew.cooper3@xxxxxxxxxx, bertrand.marquis@xxxxxxx, roger.pau@xxxxxxxxxx, roberto.bagnara@xxxxxxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Fri, 26 Aug 2022 08:01:23 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 26.08.2022 09:58, Xenia Ragiadakou wrote:
> On 8/26/22 09:21, Jan Beulich wrote:
>> On 25.08.2022 20:09, Stefano Stabellini wrote:
>>> But first, let's confirm whether this change:
>>>
>>>
>>>   #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 )
>>>
>>>
>>> is sufficient to make the violation go away in Eclair or cppcheck.  I am
>>> assuming it is not sufficient, but let's confirm.
>>
>> Well, even if for the lhs of assignments there was an exception, this
>> still wouldn't be sufficient. The minimum needed is
>>
>> #define dt_for_each_property_node(dn, pp)                   \
>>      for ( pp = (dn)->properties; (pp) != NULL; pp = (pp)->next )
>>
> 
> If pp is assumed to be a valid lvalue, then why it is needed to add 
> parentheses here (pp) != NULL ?

Because in one expression is doesn't matter that in another expression
the same identifier is used as the lhs of an assignment. Whether
parentheses are needed should solely depend on the operators in use,
not any further context.

Jan



 


Rackspace

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