From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
linux-gpio@vger.kernel.org
Subject: [PATCH libgpiod 1/2] tools: gpioinfo: don't implicity unquote unnamed lines
Date: Fri, 21 Mar 2025 12:05:24 +0100 [thread overview]
Message-ID: <20250321-gpioinfo-unnamed-quotes-v1-1-a806e9027adf@linaro.org> (raw)
In-Reply-To: <20250321-gpioinfo-unnamed-quotes-v1-0-a806e9027adf@linaro.org>
From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Consider the following output of `gpioinfo`:
gpiochip1 - 2 lines:
line 0: "foo" output
line 1: unnamed output
Now let's run:
gpioset --chip=gpiochip1 0=active 1=active
The output of `gpioinfo --unquoted` is correct:
gpiochip1 - 2 lines:
line 0: foo output consumer=gpioset
line 1: unnamed output consumer=gpioset
However, without the `unquoted` switch, it's inconsistent:
gpiochip1 - 2 lines:
line 0: "foo" output consumer="gpioset"
line 1: unnamed output consumer=gpioset
This is because gpioinfo drops the quotes for all subsequent attribute
strings when it encounters an unnamed line. We should instead keep a
separate instance of the `unquoted` flag just for the line name and pass
the original value of `unquoted_strings` down to
print_line_attributes().
Fixes: 8ffb6489286f ("tools: line name focussed rework")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
---
tools/gpioinfo.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index d5e4751..4619ca7 100644
--- a/tools/gpioinfo.c
+++ b/tools/gpioinfo.c
@@ -137,6 +137,7 @@ static bool resolve_line(struct line_resolver *resolver,
static void print_line_info(struct gpiod_line_info *info, bool unquoted_strings)
{
+ bool unquoted_name = unquoted_strings;
char quoted_name[17];
const char *name;
int len;
@@ -144,10 +145,10 @@ static void print_line_info(struct gpiod_line_info *info, bool unquoted_strings)
name = gpiod_line_info_get_name(info);
if (!name) {
name = "unnamed";
- unquoted_strings = true;
+ unquoted_name = true;
}
- if (unquoted_strings) {
+ if (unquoted_name) {
printf("%-16s\t", name);
} else {
len = strlen(name);
--
2.45.2
next prev parent reply other threads:[~2025-03-21 11:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 11:05 [PATCH libgpiod 0/2] tools: don't implicity unquote unnamed lines in gpioinfo Bartosz Golaszewski
2025-03-21 11:05 ` Bartosz Golaszewski [this message]
2025-03-21 11:44 ` [PATCH libgpiod 1/2] tools: gpioinfo: don't implicity unquote unnamed lines Kent Gibson
2025-03-21 11:05 ` [PATCH libgpiod 2/2] tools: tests: add a test case for gpioinfo output consistency Bartosz Golaszewski
2025-03-24 9:42 ` [PATCH libgpiod 0/2] tools: don't implicity unquote unnamed lines in gpioinfo Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250321-gpioinfo-unnamed-quotes-v1-1-a806e9027adf@linaro.org \
--to=brgl@bgdev.pl \
--cc=bartosz.golaszewski@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=warthog618@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).