|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] radix-tree: don't left-shift negative values
commit 61ee1a8151fc55113d50064e0cc825a55b83160c
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Feb 25 08:45:14 2025 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Feb 25 08:45:14 2025 +0100
radix-tree: don't left-shift negative values
Any (signed) integer is okay to pass into radix_tree_int_to_ptr(), yet
left shifting negative values is UB. Use an unsigned intermediate type,
reducing the impact to implementation defined behavior (for the
unsigned->signed conversion).
Also please Misra C:2012 rule 7.3 by dropping the lower case numeric 'l'
tag.
No difference in generated code, at least on x86.
Fixes: b004883e29bb ("Simplify and build-fix (for some gcc versions)
radix_tree_int_to_ptr()")
Reported-by: Teddy Astie <teddy.astie@xxxxxxxxxx>
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
xen/include/xen/radix-tree.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/xen/include/xen/radix-tree.h b/xen/include/xen/radix-tree.h
index 4077365972..634737eaf5 100644
--- a/xen/include/xen/radix-tree.h
+++ b/xen/include/xen/radix-tree.h
@@ -172,7 +172,7 @@ static inline void radix_tree_replace_slot(void **pslot,
void *item)
*/
static inline void *radix_tree_int_to_ptr(int val)
{
- long _ptr = ((long)val << 2) | 0x2l;
+ long _ptr = ((unsigned long)val << 2) | 2;
ASSERT((_ptr >> 2) == val);
return (void *)_ptr;
}
--
generated by git-patchbot for /home/xen/git/xen.git#staging
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |