Skip to contentSkip to conversation

tools: gpiomon: fix setting event clock type

PATCH In review Bartosz Golaszewski 4 participants 6 messages Mar 15, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: gpiomon: fix setting event clock type

From: Bartosz Golaszewski <[email protected]>

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

Fixes 8ffb6489286f ("tools: line name focussed rework")
---
 tools/gpiomon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpiomon.c +1 -1
index ec177df..c2684c2 100644
@@ -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);
Signature · 1 line
2.37.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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

Fixes 8ffb6489286f ("tools: line name focussed rework")

tools/gpiomon.c static int parse_event_clock_or_die(const char *option) · line 102

Quoted 2 lines
tools/gpiomon.c +1 -1
-       if (strcmp(option, "hte") != 0)
+       if (strcmp(option, "hte") == 0)

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

Yours,
Linus Walleij

#2 lore raw
Quoted 10 lines · Linus Walleij
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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

Fixes 8ffb6489286f ("tools: line name focussed rework")
Quoted 6 lines

tools/gpiomon.c static int parse_event_clock_or_die(const char *option) · line 102

Quoted 2 lines
tools/gpiomon.c +1 -1
-       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.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw
Quoted 14 lines · Andy Shevchenko
Quoted 12 lines · Linus Walleij
Quoted 7 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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

Fixes 8ffb6489286f ("tools: line name focussed rework")
Quoted 8 lines
Quoted 4 lines

tools/gpiomon.c static int parse_event_clock_or_die(const char *option) · line 102

Quoted 2 lines
tools/gpiomon.c +1 -1
-       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

Reviewed-by on v1 1/1
#4 lore raw
In reply to Bartosz Golaszewski
Quoted 3 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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

Oh, oh. Good catch and fix!

Quoted 23 lines
Fixes 8ffb6489286f ("tools: line name focussed rework")
---
 tools/gpiomon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpiomon.c +1 -1
index ec177df..c2684c2 100644
@@ -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);
Signature · 1 line
2.37.2
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#5 lore raw
In reply to Bartosz Golaszewski
Quoted 26 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

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

Fixes 8ffb6489286f ("tools: line name focussed rework")
---
 tools/gpiomon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpiomon.c +1 -2
index ec177df..c2684c2 100644
@@ -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);
--
Quoted 2 lines

2.37.2

Patch applied.

Bart