[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] common/efi: deviate Rule 2.1 violation in read_file()
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
- Date: Wed, 20 Aug 2025 18:05:16 +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=CSUJrm7Fx6wELtcDAKEV3aI9aIz402pWT08PIGG+1EA=; b=sq8QbVmW/d/eMPsz17Qb6rwbHyrJnpUXqvyQDeBkHkfbaLpXBYA2b26SgL/Pkuaq9sS/eZtOV9U5cMtREjiIQpJ/2gsBtowrEfgiOjEEaVojg48QCC9O/9Bim6yUNRY+TXNWQaMh4opgtQlbgasfRPND6vGV2re+n2VXU5Ysh9Ie2vQgtcmbokmgOzyNAIDAtpoojk9V2s7ZNQGvOvsFxMFKh/A1Hk/Dc+Bhli3GB/pK4fCAfQlL/BYIgbtjPjGQc3LMdiuEEzWCeFHmjvHu0Z0KlDUeYADKD81Bfzw76lea+u5UgCkdZtm27eqokZYWFXUE4aQfCMiCNPw1mX7BZg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=uvSC/PKDex6n0dCkpJV+ZCvpsbsm8QuzKHtA+8kvstNhJDe0IFrSUqFVHpdYzyssUUtgY5l8eyfWO3xt0gSOzOVbBgez5vw4vrqWu8CYpMhsCclOtHZhyv9Hcf+wE8N9o0Gp29lwnnyPUlTBSPT8BHQPIekc87tmLeTtUyNfrBT/qK+lCWuth+Mu/co573+K6PDa7MyOlvrpSyT4adlW6eG590MR8gtfj9jbQLaYAA6dKOn2+BshQfrQJoHHUOWVgPrNZz6hjReurw3ciK9q2HM2/c2lanzCkagnJ4BB3+rp/jZ0BYgOiPZ0ribnaKYEc7EXaLbHcUXj9scrMjzAOQ==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>
- Delivery-date: Wed, 20 Aug 2025 18:05:36 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcEfz7XSs2OBYVOkGOyX+FE8ObGA==
- Thread-topic: [PATCH] common/efi: deviate Rule 2.1 violation in read_file()
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 is noreturn:
PrintErrMesg(name, ret);
/* not reached */
return false;
This is deviated using a SAF-xx-safe comment (specified in the file
'docs/misra/safe.json').
No functional change.
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
Previous thread:
https://patchew.org/Xen/5944d87aae330246b7dab6eebd04d5d71a7d7e8f.1755608417.git.dmytro._5Fprokopchuk1@xxxxxxxx/
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/1994619131
---
docs/misra/safe.json | 8 ++++++++
xen/common/efi/boot.c | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/docs/misra/safe.json b/docs/misra/safe.json
index 3584cb90c6..2b3178de2d 100644
--- a/docs/misra/safe.json
+++ b/docs/misra/safe.json
@@ -124,6 +124,14 @@
},
{
"id": "SAF-15-safe",
+ "analyser": {
+ "eclair": "MC3A2.R2.1"
+ },
+ "name": "Rule 2.1: unreachable code",
+ "text": "This is a deliberate use of unreachable code. The return
statement is retained to improve code clarity and readability by explicitly
specifying the intended behavior for a case if PrintErrMesg() was to return."
+ },
+ {
+ "id": "SAF-16-safe",
"analyser": {},
"name": "Sentinel",
"text": "Next ID to be used"
diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index 50ff1d1bd2..860c41c8e7 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -852,7 +852,7 @@ static bool __init read_file(EFI_FILE_HANDLE dir_handle,
CHAR16 *name,
PrintErr(L" failed for ");
PrintErrMesg(name, ret);
- /* not reached */
+ /* SAF-15-safe deliberately unreachable code */
return false;
}
--
2.43.0
|