From: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
To: <gitster@pobox.com>
Cc: <git@vger.kernel.org>, Rahul Bedarkar <rahul.bedarkar@imgtec.com>,
Brandon Williams <bmwill@google.com>
Subject: [PATCH] grep: fix build with no thread support
Date: Fri, 17 Mar 2017 11:17:36 +0530 [thread overview]
Message-ID: <1489729656-17709-1-git-send-email-rahul.bedarkar@imgtec.com> (raw)
Commit 0281e487fd91 ("grep: optionally recurse into submodules")
added functions grep_submodule() and grep_submodule_launch() which
uses "struct work_item" which is defined only when thread support
is available.
When building git with toolchain that don't have thread support, we
get following build errors:
CC builtin/hash-object.o
builtin/grep.c: In function 'grep_submodule_launch':
builtin/grep.c:596:34: error: dereferencing pointer to incomplete type 'struct work_item'
status = capture_command(&cp, &w->out, 0);
^
builtin/grep.c: In function 'grep_submodule':
builtin/grep.c:644:20: error: storage size of 'w' isn't known
struct work_item w;
^
make[2]: *** [builtin/grep.o] Error 1
make[2]: *** Waiting for unfinished jobs....
This commit fixes above build issue by using "struct grep_source" and
"struct strbuf" instead of "struct work_item" in grep_submodule() and
grep_submodule_launch() when thread support is not available.
This build failure is detected by Buildroot Autobuilder:
http://autobuild.buildroot.net/results/94b/94bce9a99a5ce9894a6918774ab75e23d12c1394/
Cc: Brandon Williams <bmwill@google.com>
Fixes: 0281e487fd91 ("grep: optionally recurse into submodules")
Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
---
This patch is tested by running t7814-grep-recurse-submodules.sh with
both with/without thread support builds.
builtin/grep.c | 30 ++++++++++++++++--------------
1 file changed, 16 insertions(+), 14 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index 2c727ef..4373d79 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -183,11 +183,13 @@ static void *run(void *arg)
if (!w)
break;
- opt->output_priv = w;
- if (w->source.type == GREP_SOURCE_SUBMODULE)
+ if (w->source.type == GREP_SOURCE_SUBMODULE) {
+ opt->output_priv = &w->out;
hit |= grep_submodule_launch(opt, &w->source);
- else
+ } else {
+ opt->output_priv = w;
hit |= grep_source(opt, &w->source);
+ }
grep_source_clear_data(&w->source);
work_done(w);
}
@@ -538,7 +540,7 @@ static int grep_submodule_launch(struct grep_opt *opt,
int status, i;
const char *end_of_base;
const char *name;
- struct work_item *w = opt->output_priv;
+ struct strbuf *w = opt->output_priv;
end_of_base = strchr(gs->name, ':');
if (gs->identifier && end_of_base)
@@ -593,10 +595,10 @@ static int grep_submodule_launch(struct grep_opt *opt,
* child process. A '0' indicates a hit, a '1' indicates no hit and
* anything else is an error.
*/
- status = capture_command(&cp, &w->out, 0);
+ status = capture_command(&cp, w, 0);
if (status && (status != 1)) {
/* flush the buffer */
- write_or_die(1, w->out.buf, w->out.len);
+ write_or_die(1, w->buf, w->len);
die("process for submodule '%s' failed with exit code: %d",
gs->name, status);
}
@@ -641,19 +643,19 @@ static int grep_submodule(struct grep_opt *opt, const unsigned char *sha1,
} else
#endif
{
- struct work_item w;
+ struct grep_source gs;
int hit;
+ struct strbuf outbuf = STRBUF_INIT;
- grep_source_init(&w.source, GREP_SOURCE_SUBMODULE,
+ grep_source_init(&gs, GREP_SOURCE_SUBMODULE,
filename, path, sha1);
- strbuf_init(&w.out, 0);
- opt->output_priv = &w;
- hit = grep_submodule_launch(opt, &w.source);
+ opt->output_priv = &outbuf;
+ hit = grep_submodule_launch(opt, &gs);
- write_or_die(1, w.out.buf, w.out.len);
+ write_or_die(1, outbuf.buf, outbuf.len);
- grep_source_clear(&w.source);
- strbuf_release(&w.out);
+ grep_source_clear(&gs);
+ strbuf_release(&outbuf);
return hit;
}
}
--
2.6.2
next reply other threads:[~2017-03-17 5:48 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 5:47 Rahul Bedarkar [this message]
2017-03-17 17:53 ` [PATCH] grep: fix build with no thread support Junio C Hamano
2017-03-17 18:24 ` Brandon Williams
2017-03-17 18:41 ` [PATCH 1/2] grep: set default output method Brandon Williams
2017-03-17 18:41 ` [PATCH 2/2] grep: fix builds with with no thread support Brandon Williams
2017-03-17 23:00 ` Jonathan Nieder
2017-03-20 5:55 ` Rahul Bedarkar
2017-03-17 18:47 ` [PATCH] grep: fix build " Brandon Williams
2017-03-17 22:37 ` Jeff King
2017-03-17 22:42 ` Brandon Williams
2017-03-17 22:58 ` Jeff King
2017-03-17 23:03 ` Brandon Williams
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489729656-17709-1-git-send-email-rahul.bedarkar@imgtec.com \
--to=rahul.bedarkar@imgtec.com \
--cc=bmwill@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).