Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [libgpiod][PATCH] tools: gpiomon: fix setting event clock type
@ 2023-03-15  8:34 Bartosz Golaszewski
  2023-03-15  8:44 ` Linus Walleij
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2023-03-15  8:34 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski, Wes Tarro

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

Fix an inverted logic bug when parsing event clock type in gpiomon.

Fixes: 8ffb6489286f ("tools: line name focussed rework")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reported-by: Wes Tarro <wes.tarro@azuresummit.com>
---
 tools/gpiomon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/gpiomon.c b/tools/gpiomon.c
index ec177df..c2684c2 100644
--- a/tools/gpiomon.c
+++ b/tools/gpiomon.c
@@ -99,7 +99,7 @@ static int parse_event_clock_or_die(const char *option)
 {
 	if (strcmp(option, "realtime") == 0)
 		return GPIOD_LINE_CLOCK_REALTIME;
-	if (strcmp(option, "hte") != 0)
+	if (strcmp(option, "hte") == 0)
 		return GPIOD_LINE_CLOCK_HTE;
 	if (strcmp(option, "monotonic") != 0)
 		die("invalid event clock: %s", option);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [libgpiod][PATCH] tools: gpiomon: fix setting event clock type
  2023-03-15  8:34 [libgpiod][PATCH] tools: gpiomon: fix setting event clock type Bartosz Golaszewski
@ 2023-03-15  8:44 ` Linus Walleij
  2023-03-15 14:03   ` Andy Shevchenko
  2023-03-15 14:04 ` Andy Shevchenko
  2023-03-15 18:36 ` Bartosz Golaszewski
  2 siblings, 1 reply; 6+ messages in thread
From: Linus Walleij @ 2023-03-15  8:44 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Andy Shevchenko, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski, Wes Tarro

On Wed, Mar 15, 2023 at 9:35 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Fix an inverted logic bug when parsing event clock type in gpiomon.
>
> Fixes: 8ffb6489286f ("tools: line name focussed rework")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Reported-by: Wes Tarro <wes.tarro@azuresummit.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

> -       if (strcmp(option, "hte") != 0)
> +       if (strcmp(option, "hte") == 0)

I tend to code if (!strcmp(option, "hte")) but taste differs.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [libgpiod][PATCH] tools: gpiomon: fix setting event clock type
  2023-03-15  8:44 ` Linus Walleij
@ 2023-03-15 14:03   ` Andy Shevchenko
  2023-03-15 14:10     ` Bartosz Golaszewski
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-03-15 14:03 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Bartosz Golaszewski, Kent Gibson, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski, Wes Tarro

On Wed, Mar 15, 2023 at 09:44:17AM +0100, Linus Walleij wrote:
> On Wed, Mar 15, 2023 at 9:35 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> 
> > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> >
> > Fix an inverted logic bug when parsing event clock type in gpiomon.
> >
> > Fixes: 8ffb6489286f ("tools: line name focussed rework")
> > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > Reported-by: Wes Tarro <wes.tarro@azuresummit.com>
> 
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> 
> > -       if (strcmp(option, "hte") != 0)
> > +       if (strcmp(option, "hte") == 0)
> 
> I tend to code if (!strcmp(option, "hte")) but taste differs.

Pity we don't have match_string() API in a libc or somewhere in the user space.
Allows to avoid such mistakes at once.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [libgpiod][PATCH] tools: gpiomon: fix setting event clock type
  2023-03-15  8:34 [libgpiod][PATCH] tools: gpiomon: fix setting event clock type Bartosz Golaszewski
  2023-03-15  8:44 ` Linus Walleij
@ 2023-03-15 14:04 ` Andy Shevchenko
  2023-03-15 18:36 ` Bartosz Golaszewski
  2 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2023-03-15 14:04 UTC (permalink / raw)
  To: Bartosz Golaszewski
  Cc: Kent Gibson, Linus Walleij, Viresh Kumar, linux-gpio,
	Bartosz Golaszewski, Wes Tarro

On Wed, Mar 15, 2023 at 09:34:56AM +0100, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> 
> Fix an inverted logic bug when parsing event clock type in gpiomon.

Oh, oh. Good catch and fix!

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Fixes: 8ffb6489286f ("tools: line name focussed rework")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Reported-by: Wes Tarro <wes.tarro@azuresummit.com>
> ---
>  tools/gpiomon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/gpiomon.c b/tools/gpiomon.c
> index ec177df..c2684c2 100644
> --- a/tools/gpiomon.c
> +++ b/tools/gpiomon.c
> @@ -99,7 +99,7 @@ static int parse_event_clock_or_die(const char *option)
>  {
>  	if (strcmp(option, "realtime") == 0)
>  		return GPIOD_LINE_CLOCK_REALTIME;
> -	if (strcmp(option, "hte") != 0)
> +	if (strcmp(option, "hte") == 0)
>  		return GPIOD_LINE_CLOCK_HTE;
>  	if (strcmp(option, "monotonic") != 0)
>  		die("invalid event clock: %s", option);
> -- 
> 2.37.2
> 

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [libgpiod][PATCH] tools: gpiomon: fix setting event clock type
  2023-03-15 14:03   ` Andy Shevchenko
@ 2023-03-15 14:10     ` Bartosz Golaszewski
  0 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2023-03-15 14:10 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Linus Walleij, Bartosz Golaszewski, Kent Gibson, Viresh Kumar,
	linux-gpio, Wes Tarro

On Wed, 15 Mar 2023 at 15:04, Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
>
> On Wed, Mar 15, 2023 at 09:44:17AM +0100, Linus Walleij wrote:
> > On Wed, Mar 15, 2023 at 9:35 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
> >
> > > From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > >
> > > Fix an inverted logic bug when parsing event clock type in gpiomon.
> > >
> > > Fixes: 8ffb6489286f ("tools: line name focussed rework")
> > > Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> > > Reported-by: Wes Tarro <wes.tarro@azuresummit.com>
> >
> > Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
> >
> > > -       if (strcmp(option, "hte") != 0)
> > > +       if (strcmp(option, "hte") == 0)
> >
> > I tend to code if (!strcmp(option, "hte")) but taste differs.
>
> Pity we don't have match_string() API in a libc or somewhere in the user space.
> Allows to avoid such mistakes at once.
>

We have several instances of such string parsing in tools/ in libgpiod
so feel free to add and use it. You can even port linux code verbatim
- libgpiod is GPL after all. :)

Bart

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [libgpiod][PATCH] tools: gpiomon: fix setting event clock type
  2023-03-15  8:34 [libgpiod][PATCH] tools: gpiomon: fix setting event clock type Bartosz Golaszewski
  2023-03-15  8:44 ` Linus Walleij
  2023-03-15 14:04 ` Andy Shevchenko
@ 2023-03-15 18:36 ` Bartosz Golaszewski
  2 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2023-03-15 18:36 UTC (permalink / raw)
  To: Kent Gibson, Linus Walleij, Andy Shevchenko, Viresh Kumar
  Cc: linux-gpio, Bartosz Golaszewski, Wes Tarro

On Wed, Mar 15, 2023 at 9:35 AM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> Fix an inverted logic bug when parsing event clock type in gpiomon.
>
> Fixes: 8ffb6489286f ("tools: line name focussed rework")
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> Reported-by: Wes Tarro <wes.tarro@azuresummit.com>
> ---
>  tools/gpiomon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/gpiomon.c b/tools/gpiomon.c
> index ec177df..c2684c2 100644
> --- a/tools/gpiomon.c
> +++ b/tools/gpiomon.c
> @@ -99,7 +99,7 @@ static int parse_event_clock_or_die(const char *option)
>  {
>         if (strcmp(option, "realtime") == 0)
>                 return GPIOD_LINE_CLOCK_REALTIME;
> -       if (strcmp(option, "hte") != 0)
> +       if (strcmp(option, "hte") == 0)
>                 return GPIOD_LINE_CLOCK_HTE;
>         if (strcmp(option, "monotonic") != 0)
>                 die("invalid event clock: %s", option);
> --
> 2.37.2
>

Patch applied.

Bart

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-03-15 18:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-15  8:34 [libgpiod][PATCH] tools: gpiomon: fix setting event clock type Bartosz Golaszewski
2023-03-15  8:44 ` Linus Walleij
2023-03-15 14:03   ` Andy Shevchenko
2023-03-15 14:10     ` Bartosz Golaszewski
2023-03-15 14:04 ` Andy Shevchenko
2023-03-15 18:36 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox