[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2] hypfs: add ASSERT_UNREACHABLE() in hypfs_get_entry_rel()
- To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>
- Date: Tue, 28 Apr 2026 18:19:23 +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=s/8ETfaR1Eca5iRdOa4d7CLlQAmv+d0HpoYpF9dtQoU=; b=hZOTFutNIW7G1kYAzOS23MNL581OeCcK9/Q87OhzHttlX4C/x6k4PICJGA/RsJeiwMegT0jfJcnelvcT2OzrnqGBAZCmWMSAYnSI+xoWAGjdqAun3lB7J9nZR3B2Z0kg74gHH4LJPTigQRwEmWKTTr392S37/MCEjWfPDha5EVCQvMbj6sXNfawEZ2m1aWbbmf/vvQfjTpkl+zdvtN/bprJbksI1YOHwE0MzMWSvGbaADSkVruX9EkPkcvsRMGI8sHv+PWgIpSMhrMfugOYgE46wCf/xPz2IfxK36YHlVc1pXzFiv7oh6S+N19Xu3HIp2UAI9kiJ177vJvUA6R3mmw==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G0bqprHb5T1rr6oJfN31N3qtHHInVdiT8rE0CF4GOujZNuOgeKAF2tNo1PGMirotB81ld2NZEZaLX1+PIqy+8uYvXqsiWPJEgTi3hWKci2SvJuCw7IIv9h3jbC4IYwNISe26M2O7tkCqsMiWeReOLwRbe+laBy7VXkzmuRAXRQa1NdJtVt4OlEcu/SoIwwFZdF3pSqpDcqyxEO605n4ud6Y79HZ8AzdLC+pqcTHUk9m8AoPOvP7GrlmoRBl9B+8WypGg4KX7k/8vijvZhmcWT9XXUcsWkkxIM0APgZqOTq1y8RgWHRGrU3dOqTcfAGvAxdKRkkhTQ1A4ujLwKSpsmA==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
- Cc: Dmytro Prokopchuk1 <dmytro_prokopchuk1@xxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
- Delivery-date: Tue, 28 Apr 2026 18:19:47 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
- Thread-index: AQHc1zuKSCUJ+s/V9k2YkPF8TK6+Gg==
- Thread-topic: [PATCH v2] hypfs: add ASSERT_UNREACHABLE() in hypfs_get_entry_rel()
The statement 'return ERR_PTR(-ENOENT);' on the final line of the
function 'hypfs_get_entry_rel()' is unreachable because the logic within
the infinite loop 'for (;;)' provides all possible exit paths for the
function. So there is no execution path to exit the loop and reach the
final that statement.
This unreachable code violates MISRA C Rule 2.1 which states: "A project
shall not contain unreachable code".
To fix that and potential compilers "control reaches end of non-void
function" warning, mark the code path as unreachable using macro
'ASSERT_UNREACHABLE()'.
Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
Changes in v2:
- add ASSERT_UNREACHABLE() before the final return statement instead of
removing it
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2485661910
Link to v1:
https://patchew.org/Xen/341811ced2943fb79d0235c27781c564c7bdaf02.1775749146.git.dmytro._5Fprokopchuk1@xxxxxxxx/
---
xen/common/hypfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c
index cdf4ee0171..02fb234568 100644
--- a/xen/common/hypfs.c
+++ b/xen/common/hypfs.c
@@ -348,6 +348,7 @@ static struct hypfs_entry *hypfs_get_entry_rel(struct
hypfs_entry_dir *dir,
dir = container_of(entry, struct hypfs_entry_dir, e);
}
+ ASSERT_UNREACHABLE();
return ERR_PTR(-ENOENT);
}
--
2.43.0
|