virtual_region: address Misra C:2012 rule 18.3

find_text_region() tests whether an arbitrary address lies inside
[text_start, text_end). The address and those bounds are not known to
point into one object, so relational operators on the pointers are
undefined behaviour and violate Misra C:2012 rule 18.3.

The bounds are cast to unsigned long because addr already has that
type. The type is wide enough to hold a pointer, so the comparison
result stays the same.

No functional changes.

Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Dmytro Prokopchuk authored and Jan Beulich committed 2026-10-12 09:42:16 +02:00
1 parent c161c11875
commit 581445c19b
1 file changed
+2 -2
+2 -2
View File
@@ -83,8 +83,8 @@ const struct virtual_region *find_text_region(unsigned long addr)
rcu_read_lock(&rcu_virtual_region_lock);
list_for_each_entry_rcu ( iter, &virtual_region_list, list )
{
if ( (void *)addr >= iter->text_start &&
(void *)addr < iter->text_end )
if ( addr >= (unsigned long)iter->text_start &&
addr < (unsigned long)iter->text_end )
{
region = iter;
break;
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.