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

Re: [XEN PATCH v2] misra: address violation of MISRA C Rule 10.1


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Fri, 11 Jul 2025 12:09:02 +0000
  • Accept-language: en-US, uk-UA, ru-RU
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=hBy1AoOakJN4+RRJYznmGeGusmfksTKMp5H7bPh96/U=; b=quXVFK3gMElb5lM8TDLsKVMDdHsiXnpvbEu+PtH+5IMwdYVxt4N5W303EnaexCEQhrxGSW9pvvEJodZJ7cfa0PlAURm1YQRkbYodRVMvgq+pRSaWOrzsO2OmazxBH33+xAYoRZIi3H+jcnaATAAT3xB1l3KwXPK4rjIJED1zTzVYcXPaOMVym69XfnMIo/d+AEie50bqqqihjAPimb7JaEfEJE0QEsFDzyy+poiV9YLaHpqadkNJC+9Iel/R0yorSXa9rvDZIkhAr28k/Gj3IuNHkZfe2FPcztDwkB1Z6XwG4V0w4evgr/1wpp1BGysI3ekK9p0eLVqj7octN5RAFQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Yi0L/jLrGp/u1d2upgDEA6BLGmBlvEk96Qzx0whMqoXBwoW417q8vcN4w+9khc86NUzj6D82rqLZICKaiCPGqrM0MHjXiFe4nA5LYqWLi8Gyny6JpZl+9ieRYP9/8UFnVSO7vJ7vRJpRK3lcA+botxAL8GfnScHyL84d/rld0xy5uxen+MUErqr6401N6smKKwhdPUPfSfmBzKuZZyOh1W69UHAsdGwOzVvV4VEcK36yei3gzyvxIjEDAxXqBnwlB+FRu8QFCcKLnlH0qiZ02XQBiQ/D8GOVGSxYngv1jmvv+empIgRzKjt7LrKvnLg3R4nxqJs7QIVrOgW7Gofv2w==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Rahul Singh <rahul.singh@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 11 Jul 2025 12:09:12 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHb8lj8U0c0yIOr5EqfSUQdGwVgzbQs0wmAgAABcYA=
  • Thread-topic: [XEN PATCH v2] misra: address violation of MISRA C Rule 10.1


On 7/11/25 15:03, Jan Beulich wrote:
> On 11.07.2025 13:43, Dmytro Prokopchuk1 wrote:
>> --- a/xen/common/memory.c
>> +++ b/xen/common/memory.c
>> @@ -773,7 +773,7 @@ static long 
>> memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)
>>   
>>                   nrspin_lock(&d->page_alloc_lock);
>>                   drop_dom_ref = (dec_count &&
>> -                                !domain_adjust_tot_pages(d, -dec_count));
>> +                                !domain_adjust_tot_pages(d, 
>> -(long)dec_count));
> 
> Here and elsewhere I continue to think that we would better avoid casts
> in such cases as well, just like we try to minimize their use everywhere
> else.
Got it!

> 
>> --- a/xen/common/time.c
>> +++ b/xen/common/time.c
>> @@ -84,7 +84,7 @@ struct tm gmtime(unsigned long t)
>>       }
>>       tbuf.tm_year = y - 1900;
>>       tbuf.tm_yday = days;
>> -    ip = (const unsigned short int *)__mon_lengths[__isleap(y)];
>> +    ip = (const unsigned short int *)__mon_lengths[__isleap(y) ? 1 : 0];
> 
> If an expression is needed here, I'd suggest to use !!, as we have in
> (luckily decreasing) number of places elsewhere. Personally I don't
> understand though why a boolean cannot be used as an array index.
> 
>> --- a/xen/drivers/passthrough/arm/smmu-v3.c
>> +++ b/xen/drivers/passthrough/arm/smmu-v3.c
>> @@ -315,7 +315,7 @@ static int queue_poll_cons(struct arm_smmu_queue *q, 
>> bool sync, bool wfe)
>>   
>>      while (queue_sync_cons_in(q),
>>            (sync ? !queue_empty(&q->llq) : queue_full(&q->llq))) {
>> -            if ((NOW() > timeout) > 0)
>> +            if (NOW() > timeout)
>>                      return -ETIMEDOUT;
> 
> How does this change fit here?
> 
> Jan

if ((NOW() > timeout) > 0)
Result of "(NOW() > timeout)" is Boolean, so we have comparison Boolean 
with Numeric value.

 


Rackspace

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