tools: gpiomon: fix setting event clock type
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.
--- tools/gpiomon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/gpiomon.c +1 -1
@@ -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
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")Signed-off-by Bartosz Golaszewski <[email protected]>Reported-by Wes Tarro <[email protected]>
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
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")Signed-off-by Bartosz Golaszewski <[email protected]>Reported-by Wes Tarro <[email protected]>
Quoted 6 lines
Reviewed-by Linus Walleij <[email protected]>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
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")Signed-off-by Bartosz Golaszewski <[email protected]>Reported-by Wes Tarro <[email protected]>Reviewed-by Linus Walleij <[email protected]>
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
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")Signed-off-by Bartosz Golaszewski <[email protected]>Reported-by Wes Tarro <[email protected]>--- tools/gpiomon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/gpiomon.c +1
-1@@ -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
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")Signed-off-by Bartosz Golaszewski <[email protected]>Reported-by Wes Tarro <[email protected]>--- tools/gpiomon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/gpiomon.c +1
-2@@ -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