From: Wang Liming <liming.wang@windriver.com>
To: mingo@redhat.com, peterz@infradead.org, fweisbec@gmail.com,
mhiramat@redhat.com, linux-kernel@vger.kernel.org
Cc: rostedt@goodmis.org, jbaron@redhat.com, fche@redhat.com,
jkenisto@us.ibm.com, hch@infradead.org, ananth@in.ibm.com,
srikar@linux.vnet.ibm.com, prasad@linux.vnet.ibm.com
Subject: Re: [tip:perf/core] perf probe: Add argv_split() from lib/argv_split.c
Date: Wed, 02 Dec 2009 13:44:56 +0800 [thread overview]
Message-ID: <4B15FED8.2080108@windriver.com> (raw)
In-Reply-To: <tip-e1c01d61a98703fcc80d15b8068ec36d5a215f7e@git.kernel.org>
Hi Masami,
tip-bot for Masami Hiramatsu wrote:
...
> diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
> index 2270435..0977cf4 100644
> --- a/tools/perf/util/string.c
> +++ b/tools/perf/util/string.c
> @@ -127,3 +127,104 @@ out_err:
> out:
> return length;
> }
> +
> +/*
> + * Helper function for splitting a string into an argv-like array.
> + * originaly copied from lib/argv_split.c
> + */
> +static const char *skip_sep(const char *cp)
> +{
> + while (*cp && isspace(*cp))
> + cp++;
> +
> + return cp;
> +}
> +
> +static const char *skip_arg(const char *cp)
> +{
> + while (*cp && !isspace(*cp))
> + cp++;
> +
> + return cp;
> +}
> +
> +static int count_argc(const char *str)
> +{
> + int count = 0;
> +
> + while (*str) {
> + str = skip_sep(str);
> + if (*str) {
> + count++;
> + str = skip_arg(str);
> + }
> + }
> +
> + return count;
> +}
> +
> +/**
> + * argv_free - free an argv
> + * @argv - the argument vector to be freed
> + *
> + * Frees an argv and the strings it points to.
> + */
> +void argv_free(char **argv)
> +{
> + char **p;
> + for (p = argv; *p; p++)
> + free(*p);
> +
> + free(argv);
> +}
> +
> +/**
> + * argv_split - split a string at whitespace, returning an argv
> + * @str: the string to be split
> + * @argcp: returned argument count
> + *
> + * Returns an array of pointers to strings which are split out from
> + * @str. This is performed by strictly splitting on white-space; no
> + * quote processing is performed. Multiple whitespace characters are
> + * considered to be a single argument separator. The returned array
> + * is always NULL-terminated. Returns NULL on memory allocation
> + * failure.
> + */
> +char **argv_split(const char *str, int *argcp)
> +{
> + int argc = count_argc(str);
> + char **argv = zalloc(sizeof(*argv) * (argc+1));
> + char **argvp;
> +
> + if (argv == NULL)
> + goto out;
> +
> + if (argcp)
> + *argcp = argc;
> +
> + argvp = argv;
> +
> + while (*str) {
> + str = skip_sep(str);
> +
> + if (*str) {
> + const char *p = str;
> + char *t;
> +
> + str = skip_arg(str);
> +
> + t = strndup(p, str-p);
When I compiled "perf", I encountered following error:
CC util/string.o
cc1: warnings being treated as errors
util/string.c: In function 'argv_split':
util/string.c:216: warning: implicit declaration of function 'strndup'
util/string.c:216: warning: incompatible implicit declaration of built-in
function 'strndup'
make: *** [util/string.o] Error 1
Do we need to define _GNU_SOURCE in the head? Or maybe I used rather old glibc
version.
diff --git a/tools/perf/util/string.c b/tools/perf/util/string.c
index 0977cf4..ea3eb39 100644
--- a/tools/perf/util/string.c
+++ b/tools/perf/util/string.c
@@ -1,5 +1,8 @@
+#define _GNU_SOURCE
#include <string.h>
#include <stdlib.h>
+
+#undef _GNU_SOURCE
#include "string.h"
#include "util.h"
next prev parent reply other threads:[~2009-12-02 5:42 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-01 0:19 [PATCH -tip 0/9] perf-probe updates Masami Hiramatsu
2009-12-01 0:19 ` [PATCH -tip 1/9] trace_kprobes: Fix a memory leak bug and check kstrdup return value Masami Hiramatsu
2009-12-01 7:31 ` [tip:perf/core] trace_kprobes: Fix a memory leak bug and check kstrdup() " tip-bot for Masami Hiramatsu
2009-12-01 0:19 ` [PATCH -tip 2/9] perf probe: Fix to change a debugging message from pr_info to pr_debug Masami Hiramatsu
2009-12-01 7:31 ` [tip:perf/core] perf probe: Change " tip-bot for Masami Hiramatsu
2009-12-01 0:19 ` [PATCH -tip 3/9] perf probe: Fix to add probe-finder.h without libdwarf Masami Hiramatsu
2009-12-01 7:31 ` [tip:perf/core] perf probe: Add " tip-bot for Masami Hiramatsu
2009-12-01 0:19 ` [PATCH -tip 4/9] perf probe: Fix argv array size in probe parser Masami Hiramatsu
2009-12-01 7:32 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2009-12-01 0:19 ` [PATCH -tip 5/9] perf probe: Fix probe array index for multiple probe point Masami Hiramatsu
2009-12-01 7:32 ` [tip:perf/core] perf probe: Fix probe array index for multiple probe points tip-bot for Masami Hiramatsu
2009-12-01 0:19 ` [PATCH -tip 6/9] perf probe: Move probe event utility functions to probe-event.c Masami Hiramatsu
2009-12-01 7:32 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2009-12-01 0:20 ` [PATCH -tip 7/9] perf probe: Add argv_split() from lib/argv_split.c Masami Hiramatsu
2009-12-01 7:32 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2009-12-02 5:44 ` Wang Liming [this message]
2009-12-02 5:51 ` Frederic Weisbecker
2009-12-01 0:20 ` [PATCH -tip 8/9] perf probe: Add --list option for listing current probe events Masami Hiramatsu
2009-12-01 7:32 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2009-12-02 4:12 ` Wang Liming
2009-12-02 4:56 ` Masami Hiramatsu
2009-12-02 5:35 ` Wang Liming
2009-12-02 6:06 ` Frederic Weisbecker
2009-12-02 6:21 ` Wang Liming
2009-12-02 8:31 ` Ingo Molnar
2009-12-02 8:42 ` [PATCH] perf tools: replace %m with %a in sscanf Liming Wang
2009-12-02 10:44 ` [tip:perf/core] perf tools: Replace " tip-bot for Liming Wang
2009-12-02 16:45 ` [PATCH] perf tools: replace " Masami Hiramatsu
2009-12-01 0:20 ` [PATCH -tip 9/9] perf probe: Simplify event naming Masami Hiramatsu
2009-12-01 7:33 ` [tip:perf/core] " tip-bot for Masami Hiramatsu
2009-12-01 7:29 ` [PATCH -tip 0/9] perf-probe updates Ingo Molnar
2009-12-02 21:53 ` Masami Hiramatsu
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=4B15FED8.2080108@windriver.com \
--to=liming.wang@windriver.com \
--cc=ananth@in.ibm.com \
--cc=fche@redhat.com \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=jbaron@redhat.com \
--cc=jkenisto@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mhiramat@redhat.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=prasad@linux.vnet.ibm.com \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.ibm.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