[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3] common/efi: fix Rule 2.1 violation in read_file()
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
- Date: Thu, 21 Aug 2025 13:56:28 +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=zjnAPyabuhbFGzDZa6AQffS5/rmzZj4F9F9bNt8eKAk=; b=O9TuCG/2qeqmB/MSP/e9UBieQ5DXQHMM9utwZQJN2tvDjGfUntc1Qngq9nGpydSWYO1gMEEuEmmx7aOQ6+yl9f2nWTzA82bBkisdMFQBwqpRPDvhk89RfXKGqA1DQyY9eoNlw0CUpNAtKkfRpY9grE83IWENQM9ISNqSu1+0QvMvPQF+nAIsW1ZKlDVV9B6TtV652VhaErzyn0lU2iyVNLXjYAglb/tVSMnHiFRDhTbg+ko2mnzEWZueT2QC8U+eqzwrUoL990DPfJNVAGPDLWozR9h9fmI+QuwxvT/DFma+/EtixA2IGGWBxh1N/l4FsWxHCiAJ7qSRvmvj4jRFjA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Xf6KdXASpAa1eatOlEv5eYIZrzMdSUIrbf+OD5Yi4ws+WpKgBA2BRSjdORejJuffxSPjyvhaKl3HSqj7CkvrnAODOla+hgn/uwL3bgx8C8QaUnYJNv43w0GvCJjJ3W7aKpeXgVdkz4gSg8Fe6HYgbt9BDFcSbPTF4H7hNEe3y/o3KLq+U/upGgdZqRPMeiI4rbx16PSpwBVqq9NA7piRDvYN7X5qyQ0aocDGCG4iqmyW9IVlNryV4mgACbwhffq+0mc555QE5G+Be6oY0MNYKBoglufu38iH6l7qL7XmBsBinUGa/mOkPhV0RyU7tlH+SwzoaVN8/64fjOPP7yaJWg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, "Daniel P. Smith" <dpsmith@xxxxxxxxxxxxxxxxxxxx>, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
- Delivery-date: Thu, 21 Aug 2025 13:56:43 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHcEqNkBxL+JigLCU+o9uoHNz/rIQ==
- Thread-topic: [PATCH v3] common/efi: fix 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 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).
+ */
}
static bool __init read_section(const EFI_LOADED_IMAGE *image,
--
2.43.0
|