All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas De Marchi <lucas.demarchi@intel.com>
To: linux-modules@vger.kernel.org
Cc: Joe Buehler <aspam@cox.net>,
	Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
Subject: [PATCH 1/3] depmod: unconditionally write builtin.alias.bin
Date: Fri, 18 Dec 2020 08:02:07 -0800	[thread overview]
Message-ID: <20201218160209.4037174-2-lucas.demarchi@intel.com> (raw)
In-Reply-To: <20201218160209.4037174-1-lucas.demarchi@intel.com>

The file is always created and unless we return an error, the temporary
file is renamed to its final destination. All other places write the
index without checking if the index is empty, so just do the same.

Reported-by: Joe Buehler <aspam@cox.net>
---
 tools/depmod.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/depmod.c b/tools/depmod.c
index 2c03dfe..3f31cdf 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -2419,7 +2419,7 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
 	if (ret < 0) {
 		if (ret == -ENOENT)
 			ret = 0;
-		goto fail;
+		goto out;
 	}
 
 	kmod_list_foreach(l, builtin) {
@@ -2429,7 +2429,7 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
 
 		ret = kmod_module_get_info(mod, &info_list);
 		if (ret < 0)
-			goto fail;
+			goto out;
 
 		kmod_list_foreach(ll, info_list) {
 			char alias[PATH_MAX];
@@ -2454,9 +2454,11 @@ static int output_builtin_alias_bin(struct depmod *depmod, FILE *out)
 		count++;
 	}
 
-	if (count)
+out:
+	/* do not bother writing the index if we are going to discard it */
+	if (!ret)
 		index_write(idx, out);
-fail:
+
 	if (builtin)
 		kmod_module_unref_list(builtin);
 
-- 
2.29.2


  reply	other threads:[~2020-12-18 16:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-18 16:02 [PATCH 0/3] Fix kmod_load_resources without modules.builtin.modinfo Lucas De Marchi
2020-12-18 16:02 ` Lucas De Marchi [this message]
2020-12-18 16:02 ` [PATCH 2/3] shared: fix UNIQ definition Lucas De Marchi
2020-12-18 16:02 ` [PATCH 3/3] testsuite: add test for empty modules.builtin.aliases.bin Lucas De Marchi
2020-12-28  1:04 ` [PATCH 0/3] Fix kmod_load_resources without modules.builtin.modinfo 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=20201218160209.4037174-2-lucas.demarchi@intel.com \
    --to=lucas.demarchi@intel.com \
    --cc=aspam@cox.net \
    --cc=linux-modules@vger.kernel.org \
    --cc=yauheni.kaliuta@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.