perf tools: Remove trim() implementation, use tools/lib's strim()

Moving more stuff out of tools/perf/util/ and using the kernel idiom.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-wpj8rktj62yse5dq6ckny6de@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 45bfd0ac
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "string2.h" #include "string2.h"
#include "symbol.h" #include "symbol.h"
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/string.h>
#include <subcmd/exec-cmd.h> #include <subcmd/exec-cmd.h>
static bool dont_fork; static bool dont_fork;
...@@ -438,7 +439,7 @@ static const char *shell_test__description(char *description, size_t size, ...@@ -438,7 +439,7 @@ static const char *shell_test__description(char *description, size_t size,
description = fgets(description, size, fp); description = fgets(description, size, fp);
fclose(fp); fclose(fp);
return description ? trim(description + 1) : NULL; return description ? strim(description + 1) : NULL;
} }
#define for_each_shell_test(dir, base, ent) \ #define for_each_shell_test(dir, base, ent) \
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/string.h>
#include <sys/ttydefaults.h> #include <sys/ttydefaults.h>
#include <linux/time64.h> #include <linux/time64.h>
...@@ -1686,7 +1687,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows ...@@ -1686,7 +1687,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL); ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL);
dummy_hpp.buf[ret] = '\0'; dummy_hpp.buf[ret] = '\0';
start = trim(dummy_hpp.buf); start = strim(dummy_hpp.buf);
ret = strlen(start); ret = strlen(start);
if (start != dummy_hpp.buf) if (start != dummy_hpp.buf)
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "../string2.h" #include "../string2.h"
#include "gtk.h" #include "gtk.h"
#include <signal.h> #include <signal.h>
#include <linux/string.h>
#define MAX_COLUMNS 32 #define MAX_COLUMNS 32
...@@ -459,7 +460,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists, ...@@ -459,7 +460,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists,
advance_hpp(hpp, ret + 2); advance_hpp(hpp, ret + 2);
} }
gtk_tree_store_set(store, &iter, col_idx, trim(bf), -1); gtk_tree_store_set(store, &iter, col_idx, strim(bf), -1);
if (!he->leaf) { if (!he->leaf) {
hpp->buf = bf; hpp->buf = bf;
...@@ -555,7 +556,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists, ...@@ -555,7 +556,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
first_col = false; first_col = false;
fmt->header(fmt, &hpp, hists, 0, NULL); fmt->header(fmt, &hpp, hists, 0, NULL);
strcat(buf, trim(hpp.buf)); strcat(buf, strim(hpp.buf));
} }
} }
......
...@@ -620,7 +620,7 @@ static int hists__fprintf_hierarchy_headers(struct hists *hists, ...@@ -620,7 +620,7 @@ static int hists__fprintf_hierarchy_headers(struct hists *hists,
fmt->header(fmt, hpp, hists, 0, NULL); fmt->header(fmt, hpp, hists, 0, NULL);
header_width += fprintf(fp, "%s", trim(hpp->buf)); header_width += fprintf(fp, "%s", strim(hpp->buf));
} }
} }
......
...@@ -25,11 +25,6 @@ char *strxfrchar(char *s, char from, char to); ...@@ -25,11 +25,6 @@ char *strxfrchar(char *s, char from, char to);
char *rtrim(char *s); char *rtrim(char *s);
static inline char *trim(char *s)
{
return skip_spaces(rtrim(s));
}
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints); char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints) static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment