mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
To: Michal Marek <mmarek@suse.cz>,
	Masahiro Yamada <yamada.m@jp.panasonic.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	Sam Ravnborg <sam@ravnborg.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH 2/2] modpost: sumversions: try to fix "same dir" logic
Date: Thu, 22 Mar 2018 15:59:54 +0100	[thread overview]
Message-ID: <20180322150005.15061-2-linux@rasmusvillemoes.dk> (raw)
In-Reply-To: <20180322150005.15061-1-linux@rasmusvillemoes.dk>

The current logic for deciding whether to parse a file listed in the
.o.cmd file matches neither "is in same dir" (implied by the comment
here), nor the "/* Sum all files in the same dir or subdirs. */" a
little higher up. For example, for an object file in the top-level
crypto/ directory, we end up also parsing anything it includes from
include/crypto/ (though not subdirectories of that) and
arch/x86/include/asm/crypto/. On the other hand, we never parse anything
included from subdirectories of the object file's directory, contrary to
at least one of the comments.

This tries to fix things so that we actually implement "parse stuff
found in $(dirname $objfile) and below" by simply checking whether line
begins with dir. It doesn't quite work, though, because there are some

#include "../blabla"

directives, e.g. in drivers/scsi/libsas/ we have #include
"../scsi_sas_internal.h", and gcc doesn't normalize the path before
printing it, so we have

drivers/scsi/libsas/../scsi_sas_internal.h

in the .o.cmd file. But perhaps that's actually a good thing - then the
logic would be something like "if gcc found the included file using . as
starting point, we include it - otherwise it was found via some -I path,
so do not include it".

In any case, this is mostly just something I stumbled on because I'm
about to change the .o.cmd layout slightly, so I'd like to know what the
rules are really supposed to be.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 scripts/mod/sumversion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 0f6dcb4011a8..e4f83fb9da2f 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -368,7 +368,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
 		}
 
 		/* Check if this file is in same dir as objfile */
-		if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
+		if (strncmp(line, dir, dirlen) == 0) {
 			if (!parse_file(line, md)) {
 				warn("could not open %s: %s\n",
 				     line, strerror(errno));
-- 
2.15.1

  reply	other threads:[~2018-03-22 15:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-22 14:59 [RFC PATCH 1/2] modpost: delete stale comment Rasmus Villemoes
2018-03-22 14:59 ` Rasmus Villemoes [this message]
2018-03-22 21:05   ` [RFC resend " Rasmus Villemoes
2018-03-22 21:05     ` [RFC resend 2/2] modpost: sumversions: try to fix "same dir" logic Rasmus Villemoes
2018-05-02 14:55       ` Masahiro Yamada
2018-05-02 15:51     ` [RFC resend 1/2] modpost: delete stale comment Masahiro Yamada

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=20180322150005.15061-2-linux@rasmusvillemoes.dk \
    --to=linux@rasmusvillemoes.dk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.cz \
    --cc=rusty@rustcorp.com.au \
    --cc=sam@ravnborg.org \
    --cc=yamada.m@jp.panasonic.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

all inboxes | Powered by JetHome®