From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754118AbdECRjo (ORCPT ); Wed, 3 May 2017 13:39:44 -0400 Received: from terminus.zytor.com ([65.50.211.136]:54021 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752451AbdECRjg (ORCPT ); Wed, 3 May 2017 13:39:36 -0400 Date: Wed, 3 May 2017 10:37:17 -0700 From: tip-bot for Arnaldo Carvalho de Melo Message-ID: Cc: acme@redhat.com, linux-kernel@vger.kernel.org, mingo@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, hpa@zytor.com, tglx@linutronix.de, jolsa@kernel.org, wangnan0@huawei.com, jpoimboe@redhat.com, dsahern@gmail.com Reply-To: namhyung@kernel.org, mingo@kernel.org, acme@redhat.com, linux-kernel@vger.kernel.org, dsahern@gmail.com, jpoimboe@redhat.com, wangnan0@huawei.com, jolsa@kernel.org, tglx@linutronix.de, hpa@zytor.com, adrian.hunter@intel.com To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] tools lib string: Adopt prefixcmp() from perf and subcmd Git-Commit-ID: 96395cbbc7e94cbbe4f76cf64cf122fabc19123d X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 96395cbbc7e94cbbe4f76cf64cf122fabc19123d Gitweb: http://git.kernel.org/tip/96395cbbc7e94cbbe4f76cf64cf122fabc19123d Author: Arnaldo Carvalho de Melo AuthorDate: Wed, 26 Apr 2017 15:49:21 -0300 Committer: Arnaldo Carvalho de Melo CommitDate: Wed, 26 Apr 2017 15:49:21 -0300 tools lib string: Adopt prefixcmp() from perf and subcmd Both had copies originating from git.git, move those to tools/lib/string.c, getting both tools/lib/subcmd/ and tools/perf/ to use it. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Josh Poimboeuf Cc: Namhyung Kim Cc: Wang Nan Link: http://lkml.kernel.org/n/tip-uidwtticro1qhttzd2rkrkg1@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/include/linux/string.h | 2 ++ tools/lib/string.c | 9 +++++++++ tools/lib/subcmd/help.c | 1 + tools/lib/subcmd/parse-options.c | 1 + tools/lib/subcmd/subcmd-util.h | 9 --------- tools/perf/util/strbuf.c | 9 --------- tools/perf/util/util.h | 2 -- 7 files changed, 13 insertions(+), 20 deletions(-) diff --git a/tools/include/linux/string.h b/tools/include/linux/string.h index f436d24..d62b56c 100644 --- a/tools/include/linux/string.h +++ b/tools/include/linux/string.h @@ -18,4 +18,6 @@ extern size_t strlcpy(char *dest, const char *src, size_t size); char *str_error_r(int errnum, char *buf, size_t buflen); +int prefixcmp(const char *str, const char *prefix); + #endif /* _LINUX_STRING_H_ */ diff --git a/tools/lib/string.c b/tools/lib/string.c index bd239bc..8e678af 100644 --- a/tools/lib/string.c +++ b/tools/lib/string.c @@ -87,3 +87,12 @@ size_t __weak strlcpy(char *dest, const char *src, size_t size) } return ret; } + +int prefixcmp(const char *str, const char *prefix) +{ + for (; ; str++, prefix++) + if (!*prefix) + return 0; + else if (*str != *prefix) + return (unsigned char)*prefix - (unsigned char)*str; +} diff --git a/tools/lib/subcmd/help.c b/tools/lib/subcmd/help.c index e228c3c..ba970a7 100644 --- a/tools/lib/subcmd/help.c +++ b/tools/lib/subcmd/help.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c index 6bc2402..359bfa7 100644 --- a/tools/lib/subcmd/parse-options.c +++ b/tools/lib/subcmd/parse-options.c @@ -1,4 +1,5 @@ #include +#include #include #include #include diff --git a/tools/lib/subcmd/subcmd-util.h b/tools/lib/subcmd/subcmd-util.h index fc2e45d..8fa5f03 100644 --- a/tools/lib/subcmd/subcmd-util.h +++ b/tools/lib/subcmd/subcmd-util.h @@ -79,13 +79,4 @@ static inline void astrcat(char **out, const char *add) free(tmp); } -static inline int prefixcmp(const char *str, const char *prefix) -{ - for (; ; str++, prefix++) - if (!*prefix) - return 0; - else if (*str != *prefix) - return (unsigned char)*prefix - (unsigned char)*str; -} - #endif /* __SUBCMD_UTIL_H */ diff --git a/tools/perf/util/strbuf.c b/tools/perf/util/strbuf.c index e91b5e8..aafe908 100644 --- a/tools/perf/util/strbuf.c +++ b/tools/perf/util/strbuf.c @@ -3,15 +3,6 @@ #include #include -int prefixcmp(const char *str, const char *prefix) -{ - for (; ; str++, prefix++) - if (!*prefix) - return 0; - else if (*str != *prefix) - return (unsigned char)*prefix - (unsigned char)*str; -} - /* * Used as the default ->buf value, so that people can always assume * buf is non NULL and ->buf is NUL terminated even for a freshly diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index d620719..5dfb9bb 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -30,8 +30,6 @@ void warning(const char *err, ...) __attribute__((format (printf, 1, 2))); void set_warning_routine(void (*routine)(const char *err, va_list params)); -int prefixcmp(const char *str, const char *prefix); - static inline void *zalloc(size_t size) { return calloc(1, size);