[PATCH] hypfs: remove unreachable statement in the 'hypfs_get_entry_rel()'

Dmytro Prokopchuk1 posted 1 patch 3 days, 5 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/341811ced2943fb79d0235c27781c564c7bdaf02.1775749146.git.dmytro._5Fprokopchuk1@epam.com
xen/common/hypfs.c | 2 --
1 file changed, 2 deletions(-)
[PATCH] hypfs: remove unreachable statement in the 'hypfs_get_entry_rel()'
Posted by Dmytro Prokopchuk1 3 days, 5 hours ago
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.

Remove that statement. This also fixes MISRA C Rule 2.1 which states:
"A project shall not contain unreachable code".

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
---
Test CI pipeline:
https://gitlab.com/xen-project/people/dimaprkp4k/xen/-/pipelines/2440991088
---
 xen/common/hypfs.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/xen/common/hypfs.c b/xen/common/hypfs.c
index cdf4ee0171..fea74d66e1 100644
--- a/xen/common/hypfs.c
+++ b/xen/common/hypfs.c
@@ -347,8 +347,6 @@ static struct hypfs_entry *hypfs_get_entry_rel(struct hypfs_entry_dir *dir,
         path = end + 1;
         dir = container_of(entry, struct hypfs_entry_dir, e);
     }
-
-    return ERR_PTR(-ENOENT);
 }
 
 static struct hypfs_entry *hypfs_get_entry(const char *path)
-- 
2.43.0
Re: [PATCH] hypfs: remove unreachable statement in the 'hypfs_get_entry_rel()'
Posted by Jürgen Groß 2 days, 11 hours ago
On 09.04.26 17:55, Dmytro Prokopchuk1 wrote:
> 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.
> 
> Remove that statement. This also fixes MISRA C Rule 2.1 which states:
> "A project shall not contain unreachable code".
> 
> Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen