diff options
author | Abraham Samuel Adekunle <abrahamadekunle50@gmail.com> | 2025-04-18 12:47:55 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-04-18 13:40:15 +0300 |
commit | a5df13cd7b05f87f864c2d575020d287879659aa (patch) | |
tree | 07328feb6d0d0df8380bc2971ba2ac9d70472ee3 /tools/perf/scripts/python/stackcollapse.py | |
parent | 28925280ed6c12705a9273cc9853c97b22ef2176 (diff) | |
download | linux-a5df13cd7b05f87f864c2d575020d287879659aa.tar.xz |
staging: rtl8723bs: Use % 4096 instead of & 0xfff
The sequence number is constrained to a range of [0, 4095], which
is a total of 4096 values. The bitmask operation using `& 0xfff` is
used to perform this wrap-around. While this is functionally correct,
it obscures the intended semantic of a 4096-based wrap.
Using a modulo operation `% 4096u` makes the wrap-around logic
explicit and easier to understand. It clearly signals that the
sequence number cycles through a range of 4096 values.
It also makes the code robust against potential changes of the 4096
upper limit, especially when it becomes a non power-of-2 value while
the AND(&) works solely for power-of-2 values.
The use of `% 4096u` also guarantees that the modulo operation is
performed with unsigned arithmetic, preventing potential issues with
the signed types.
Found by Coccinelle.
Suggested-by: Andy Shevchenko <andy@kernel.org>
Suggested-by: David Laight <david.laight.linux@gmail.com>
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Link: https://lore.kernel.org/r/e8d515539ba560961003eae15d301d03e6cdd17d.1744966511.git.abrahamadekunle50@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions