From: "Xaver Hörl" <hoe.dom@gmx.de>
To: linux-modules@vger.kernel.org
Cc: Lucas De Marchi <lucas.de.marchi@gmail.com>
Subject: [PATCH] modinfo: dont print module name when --field is given
Date: Wed, 26 Aug 2020 11:36:27 +0200 [thread overview]
Message-ID: <20200826093627.ukw4hwff2wxb6ykh@blumerang> (raw)
In-Reply-To: <CAKi4VALERCR92nf+D00knka4NOrUM+P2TY7Rs+zoLOvi_8iQtQ@mail.gmail.com>
On Tue, Aug 25, 2020 at 10:27:46AM -0700, Lucas De Marchi wrote:
> the name would be handled by the next if/else branch. Unconditionally printing
> the name at the beginning for built-in modules doesn't seem something important
> to retain. I'd rather handle it in the `if (is_builtin && err ==
> -ENOENT) {` below just
> not to exit without printing anything. In that case, printing both
> name and filename
> would be preferred, so the user knows why there isn't additional information
Dropping the "name:" part with --field seems the right thing (updated
patch below implements this). But I don't know what exactly to do about
the error case, not sure if I get your intention right there.
If --field is not given, the name and filename (i.e. "(builtin)" in
this case) will be there anyway, on the other hand if --field
_is_ given it seems a bit inconsistent to give additional output.
Unless you consider this case an error condition of sorts, but the
return value being 0 suggests otherwise.
Thanks for having a look at this!
Xaver Hörl
---
tools/modinfo.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/modinfo.c b/tools/modinfo.c
index 0231bb0..b49f622 100644
--- a/tools/modinfo.c
+++ b/tools/modinfo.c
@@ -178,14 +178,21 @@ static int modinfo_do(struct kmod_module *mod)
is_builtin = (filename == NULL);
if (is_builtin) {
- printf("%-16s%s%c", "name:", kmod_module_get_name(mod), separator);
filename = "(builtin)";
}
- if (field != NULL && streq(field, "filename")) {
+ if (field != NULL && streq(field, "name")) {
+ printf("%s%c", kmod_module_get_name(mod),
+ separator);
+ return 0;
+ } else if (field != NULL && streq(field, "filename")) {
printf("%s%c", filename, separator);
return 0;
} else if (field == NULL) {
+ if (is_builtin) {
+ printf("%-16s%s%c", "name:",
+ kmod_module_get_name(mod), separator);
+ }
printf("%-16s%s%c", "filename:",
filename, separator);
}
--
2.28.0
next prev parent reply other threads:[~2020-08-26 9:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-23 21:54 [PATCH] modinfo: dont print module name when --field is given Xaver Hörl
2020-08-25 17:27 ` Lucas De Marchi
2020-08-26 9:36 ` Xaver Hörl [this message]
2020-08-26 10:12 ` Lucas De Marchi
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=20200826093627.ukw4hwff2wxb6ykh@blumerang \
--to=hoe.dom@gmx.de \
--cc=linux-modules@vger.kernel.org \
--cc=lucas.de.marchi@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).