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

Re: [PATCH v3] common/efi: fix Rule 2.1 violation in read_file()


  • To: Jan Beulich <jbeulich@xxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
  • From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
  • Date: Fri, 22 Aug 2025 13:14:24 +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=a/KZF6fd8DRc90/vc1J4ox92l7UdFjA3RVd/50nTEe4=; b=vrR7bbsBkQpSwPhpuHUTwVq3xaRVyoBifSvCEI++tBSHlRDUXRGiF/T6H7BU9G6olXd5Bzx7VxKKB1IEyYDyun0N0istUZD+zcHRJo7NNgBpQnoTGwQY0ALalPcCDzIckm9r/GZgsPy3ZlayAgv2FEarqIUYqE0A5CLXc8IE+5RGNgbUWQ4zFya9aAvnsynLcaBdgSqB/PL4+ZUNDmgmvR3Oq2WlYqQuaO+Q1soP8FBAVVFhPRUgL9xqkHHRjrKeNNSy2GGi2w0D3SF5LDxqIy3e4hd8/BFrLdnP66ZDcdf2ZMGA2J0o7jBL3uNpf0YAaa2W8jGFuum1gQHmIkTXKQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BI0LFQuX/1WrpIf1NP8y9I/hSbDE7QKk6oucDS9Z7Tx9E4LZtx+pKng9HIZna57oY46yXDOX73KIyPn0D48juXJ4zcV08QoO6L7Lg2Am3hL867yO7PRmEyi97HaD2URZfK6vYkfoEy8OeeMg9M0YdvYJKMs9k4bQ98Fib/YgTmKgz5ZRIi31zpfZsOkfqQ3ThfrhJ+qUJrdN8i4cP0TXL0lGewPecgo2/p/nhqiXu0UuPuCTwMDCudTx0IO5K2g9RsB2dXBkU2Z7Ritn8M40qHHobTLr+LTIjTuA7cjyS9CR6yn8mEzDA1DAuoWxlPtzBBNUAa9r4Ov+ukkSCxyhgw==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Fri, 22 Aug 2025 13:14:41 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHcEqNkBxL+JigLCU+o9uoHNz/rIbRtKXaAgAAAfQCAAX4ggA==
  • Thread-topic: [PATCH v3] common/efi: fix Rule 2.1 violation in read_file()


On 8/21/25 17:26, Jan Beulich wrote:
> On 21.08.2025 16:24, Marek Marczykowski-Górecki wrote:
>> On Thu, Aug 21, 2025 at 01:56:28PM +0000, Dmytro Prokopchuk1 wrote:
>>> MISRA C Rule 2.1 states: "A project shall not contain unreachable code."
>>>
>>> The return statements in the 'read_file()' function is unreachable due
>>> to function 'PrintErrMesg()' which has 'noreturn' attribute:
>>>          PrintErrMesg(name, ret);
>>>          /* not reached */
>>>          return false;
>>>      }
>>>
>>> No explicit return statement is needed here. Remove the statement and
>>> write a justification comment instead. No functional changes.
>>>
>>> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
>>> ---
>>> Link to v2:
>>> https://patchew.org/Xen/c20a58f24875806adfaf491f9c6eef2ca8682d18.1755711594.git.dmytro._5Fprokopchuk1@xxxxxxxx/
>>>
>>> Changes in v3:
>>> - removed unreachable code instead of deviation
>>> - updated commit subject and message
>>>
>>> Test CI pipeline:
>>> https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/1996439444
>>> ---
>>>   xen/common/efi/boot.c | 10 +++++++---
>>>   1 file changed, 7 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
>>> index 50ff1d1bd2..325de05b18 100644
>>> --- a/xen/common/efi/boot.c
>>> +++ b/xen/common/efi/boot.c
>>> @@ -851,9 +851,13 @@ static bool __init read_file(EFI_FILE_HANDLE 
>>> dir_handle, CHAR16 *name,
>>>       PrintErr(what);
>>>       PrintErr(L" failed for ");
>>>       PrintErrMesg(name, ret);
>>> -
>>> -    /* not reached */
>>> -    return false;
>>> +    /*
>>> +     * No explicit return statement is needed here because 
>>> 'PrintErrMesg()' is
>>> +     * marked as 'noreturn', which guarantees that it never returns 
>>> control to
>>> +     * the caller. If the 'noreturn' attribute of 'PrintErrMesg()' is 
>>> removed
>>> +     * in the future, compiler will emit an error about the missing return
>>> +     * statement (build-time safeguard).
>>> +     */
>>
>> I don't think this verbose code comment is needed here. Other similar places
>> use simply "Doesn't return." next to the function call, or nothing at
>> all if the function name already suggests it (which IMO is not the case
>> here).
>
> Or simply keep the comment that was already there?
>
> Jan

Anyway, comments "Doesn't return." and "not reached" are almost the same.
To simplify patch, I'm going to leave old comment "not reached" and move
description into commit message.

Dmytro.

>
>> The longer explanation may be put in the commit message.
>>
>> With that addressed:
>>
>> Reviewed-by: Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
>>
>

 


Rackspace

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