All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josh Triplett <josh@joshtriplett.org>
To: linux-modules@vger.kernel.org
Cc: 810367@bugs.debian.org, kmod@packages.debian.org
Subject: [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty
Date: Sun, 10 Jan 2016 07:10:25 -0800	[thread overview]
Message-ID: <20160110151023.GA9659@x> (raw)

This allows tools to detect the file as empty, such as via systemd's
ConditionFileNotEmpty.
---

The string constant extends past 80 columns, per CODING-STYLE.

The motivation for this patch came from Debian bug 810367.  This change
would allow kmod-static-nodes.service to use ConditionFileNotEmpty
instead of ConditionPathExists.

 tools/depmod.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/depmod.c b/tools/depmod.c
index a585d47..6e9bb4d 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -1999,8 +1999,7 @@ static int output_builtin_bin(struct depmod *depmod, FILE *out)
 static int output_devname(struct depmod *depmod, FILE *out)
 {
 	size_t i;
-
-	fputs("# Device nodes to trigger on-demand module loading.\n", out);
+	bool empty = true;
 
 	for (i = 0; i < depmod->modules.count; i++) {
 		const struct mod *mod = depmod->modules.array[i];
@@ -2036,10 +2035,15 @@ static int output_devname(struct depmod *depmod, FILE *out)
 		}
 
 		if (devname != NULL) {
-			if (type != '\0')
+			if (type != '\0') {
+				if (empty) {
+					fputs("# Device nodes to trigger on-demand module loading.\n",
+					      out);
+					empty = false;
+				}
 				fprintf(out, "%s %s %c%u:%u\n", mod->modname,
 					devname, type, major, minor);
-			else
+                        } else
 				ERR("Module '%s' has devname (%s) but "
 				    "lacks major and minor information. "
 				    "Ignoring.\n", mod->modname, devname);
-- 
2.7.0.rc3


             reply	other threads:[~2016-01-10 15:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-10 15:10 Josh Triplett [this message]
2016-01-11 12:43 ` [PATCH] depmod: Don't insert comment in modules.devname if otherwise empty Lucas De Marchi
2016-01-11 15:55   ` Bug#810367: " Martin Pitt
2016-01-11 16:06     ` 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=20160110151023.GA9659@x \
    --to=josh@joshtriplett.org \
    --cc=810367@bugs.debian.org \
    --cc=kmod@packages.debian.org \
    --cc=linux-modules@vger.kernel.org \
    /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.