From: Liu Jing <liujing@cmss.chinamobile.com>
In amd_fam14h_get_nb_power(), the expression `1 << 31` performs a
signed integer shift, which is undefined behavior in C.
Fix it by using `1U << 31` to perform an unsigned shift.
Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
---
--- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
+++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
@@ -270,7 +270,7 @@
{
uint32_t val;
val = pci_read_long(amd_fam14h_pci_dev, PCI_NBP1_CAP_OFFSET);
- return val & (1 << 31);
+ return val & (1U << 31);
}
struct cpuidle_monitor *amd_fam14h_register(void)
On 9/3/26 02:26, liujing wrote:
> From: Liu Jing <liujing@cmss.chinamobile.com>
>
> In amd_fam14h_get_nb_power(), the expression `1 << 31` performs a
> signed integer shift, which is undefined behavior in C.
>
> Fix it by using `1U << 31` to perform an unsigned shift.
How did you find this problem?
>
> Signed-off-by: Liu Jing <liujing@cmss.chinamobile.com>
> ---
> --- a/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
> +++ b/tools/power/cpupower/utils/idle_monitor/amd_fam14h_idle.c
> @@ -270,7 +270,7 @@
> {
> uint32_t val;
> val = pci_read_long(amd_fam14h_pci_dev, PCI_NBP1_CAP_OFFSET);
> - return val & (1 << 31);
> + return val & (1U << 31);
> }
>
> struct cpuidle_monitor *amd_fam14h_register(void)
>
>
>
>
thanks,
-- Shuah
© 2016 - 2026 Red Hat, Inc.