diff mbox series

[v1,2/2] gpio: sim: Print boolean as unsigned integer

Message ID 20230309184636.84124-2-andriy.shevchenko@linux.intel.com
State New
Headers show
Series [v1,1/2] gpio: sim: Deactivate device in reversed order | expand

Commit Message

Andy Shevchenko March 9, 2023, 6:46 p.m. UTC
Print boolean as unsigned integer instead of using %c and manually
converting to a character.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bartosz Golaszewski March 10, 2023, 3:56 p.m. UTC | #1
On Thu, Mar 9, 2023 at 7:46 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> Print boolean as unsigned integer instead of using %c and manually
> converting to a character.
>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/gpio/gpio-sim.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> index a1c8702f362c..5ac1de5db751 100644
> --- a/drivers/gpio/gpio-sim.c
> +++ b/drivers/gpio/gpio-sim.c
> @@ -684,7 +684,7 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page)
>         live = gpio_sim_device_is_live_unlocked(dev);
>         mutex_unlock(&dev->lock);
>
> -       return sprintf(page, "%c\n", live ? '1' : '0');
> +       return sprintf(page, "%u\n", live);
>  }
>
>  static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,
> --
> 2.39.1
>

Sorry but NACK. At first glance the current version is more readable.
With the one you're proposing, I need to look at the type of "live" to
understand what it will print.

Bart
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
index a1c8702f362c..5ac1de5db751 100644
--- a/drivers/gpio/gpio-sim.c
+++ b/drivers/gpio/gpio-sim.c
@@ -684,7 +684,7 @@  gpio_sim_device_config_live_show(struct config_item *item, char *page)
 	live = gpio_sim_device_is_live_unlocked(dev);
 	mutex_unlock(&dev->lock);
 
-	return sprintf(page, "%c\n", live ? '1' : '0');
+	return sprintf(page, "%u\n", live);
 }
 
 static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,