[PATCH v1] PM: Remove unnecessary !!

Zihuan Zhang posted 1 patch 9 months, 3 weeks ago
kernel/power/main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v1] PM: Remove unnecessary !!
Posted by Zihuan Zhang 9 months, 3 weeks ago
Double ! or !! are normally required to get 0 or 1 out of a expression.
A comparision always returns 0 or 1 and hence there is no need to apply
double ! over it again.

Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
---
 kernel/power/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/power/main.c b/kernel/power/main.c
index 6254814d4817..97746f08b762 100644
--- a/kernel/power/main.c
+++ b/kernel/power/main.c
@@ -594,7 +594,7 @@ power_attr(pm_print_times);
 
 static inline void pm_print_times_init(void)
 {
-	pm_print_times_enabled = !!initcall_debug;
+	pm_print_times_enabled = initcall_debug;
 }
 
 static ssize_t pm_wakeup_irq_show(struct kobject *kobj,
-- 
2.25.1
Re: [PATCH v1] PM: Remove unnecessary !!
Posted by Rafael J. Wysocki 9 months, 2 weeks ago
On Thu, Apr 24, 2025 at 8:04 AM Zihuan Zhang <zhangzihuan@kylinos.cn> wrote:
>
> Double ! or !! are normally required to get 0 or 1 out of a expression.
> A comparision always returns 0 or 1 and hence there is no need to apply
> double ! over it again.
>
> Signed-off-by: Zihuan Zhang <zhangzihuan@kylinos.cn>
> ---
>  kernel/power/main.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/power/main.c b/kernel/power/main.c
> index 6254814d4817..97746f08b762 100644
> --- a/kernel/power/main.c
> +++ b/kernel/power/main.c
> @@ -594,7 +594,7 @@ power_attr(pm_print_times);
>
>  static inline void pm_print_times_init(void)
>  {
> -       pm_print_times_enabled = !!initcall_debug;
> +       pm_print_times_enabled = initcall_debug;
>  }
>
>  static ssize_t pm_wakeup_irq_show(struct kobject *kobj,
> --

Applied as 6.16 material with edited changelog, thanks!