linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: linux-modules@vger.kernel.org
Cc: Yanko Kaneti <yaneti@declera.com>,
	gladkov.alexey@gmail.com, auke-jan.h.kok@intel.com,
	Lucas De Marchi <lucas.demarchi@intel.com>
Subject: [PATCH 2/6] depmod: do not output .bin to stdout
Date: Mon,  9 Mar 2020 22:00:25 -0700	[thread overview]
Message-ID: <20200310050029.27678-3-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20200310050029.27678-1-lucas.demarchi@intel.com>

index_write() relies on fseek/ftell to manage the position to which we
are write and thus needs the file stream to support it.

Right now when trying to write the index to stdout we fail with:

	depmod: tools/depmod.c:416: index_write: Assertion `initial_offset >= 0' failed.
	Aborted (core dumped)

We have no interest in outputting our index to stdout, so just skip it
like is done with other indexes.

While at it, add/remove some newlines to improve readability.

Reported-by: Yanko Kaneti <yaneti@declera.com>
Fix: b866b2165ae6 ("Lookup aliases in the modules.builtin.modinfo")
---
 tools/depmod.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/depmod.c b/tools/depmod.c
index fbbce10..875e314 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2408,8 +2408,10 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
 	struct index_node *idx;
 	struct kmod_list *l, *builtin = NULL;
 
-	idx = index_create();
+	if (out == stdout)
+		return 0;
 
+	idx = index_create();
 	if (idx == NULL) {
 		ret = -ENOMEM;
 		goto fail;
@@ -2456,7 +2458,9 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
 
 	if (count)
 		index_write(idx, out);
+
 	index_destroy(idx);
+
 fail:
 	if (builtin)
 		kmod_module_unref_list(builtin);
-- 
2.25.1


  parent reply	other threads:[~2020-03-10  5:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  5:00 [PATCH 0/6] Fix modules.builtin.alias handling Lucas De Marchi
2020-03-10  5:00 ` [PATCH 1/6] gitignore: ignore .cache.mk when building modules Lucas De Marchi
2020-03-10  5:00 ` Lucas De Marchi [this message]
2020-03-10  5:00 ` [PATCH 3/6] libkmod: simplify lookup when builtin.modinfo.bin file is missing Lucas De Marchi
2020-03-10  5:00 ` [PATCH 4/6] libkmod: fix return error when opening index Lucas De Marchi
2020-03-10  5:00 ` [PATCH 5/6] libkmod: allow modules.alias.builtin to be optional Lucas De Marchi
2020-03-10  5:00 ` [PATCH 6/6] testsuite: add check for kmod_load_resources Lucas De Marchi
2020-03-23 19:41 ` [PATCH 0/6] Fix modules.builtin.alias handling 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=20200310050029.27678-3-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=auke-jan.h.kok@intel.com \
    --cc=gladkov.alexey@gmail.com \
    --cc=linux-modules@vger.kernel.org \
    --cc=yaneti@declera.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).