Skip to content

Commit 3ca43b6

Browse files
committed
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.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 45bfd0a commit 3ca43b6

5 files changed

Lines changed: 8 additions & 10 deletions

File tree

‎tools/perf/tests/builtin-test.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "string2.h"
2323
#include "symbol.h"
2424
#include <linux/kernel.h>
25+
#include <linux/string.h>
2526
#include <subcmd/exec-cmd.h>
2627

2728
static bool dont_fork;
@@ -438,7 +439,7 @@ static const char *shell_test__description(char *description, size_t size,
438439
description = fgets(description, size, fp);
439440
fclose(fp);
440441

441-
return description ? trim(description + 1) : NULL;
442+
return description ? strim(description + 1) : NULL;
442443
}
443444

444445
#define for_each_shell_test(dir, base, ent) \

‎tools/perf/ui/browsers/hists.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <stdlib.h>
77
#include <string.h>
88
#include <linux/rbtree.h>
9+
#include <linux/string.h>
910
#include <sys/ttydefaults.h>
1011
#include <linux/time64.h>
1112

@@ -1686,7 +1687,7 @@ static int hists_browser__scnprintf_hierarchy_headers(struct hist_browser *brows
16861687
ret = fmt->header(fmt, &dummy_hpp, hists, 0, NULL);
16871688
dummy_hpp.buf[ret] = '\0';
16881689

1689-
start = trim(dummy_hpp.buf);
1690+
start = strim(dummy_hpp.buf);
16901691
ret = strlen(start);
16911692

16921693
if (start != dummy_hpp.buf)

‎tools/perf/ui/gtk/hists.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "../string2.h"
1010
#include "gtk.h"
1111
#include <signal.h>
12+
#include <linux/string.h>
1213

1314
#define MAX_COLUMNS 32
1415

@@ -459,7 +460,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists,
459460
advance_hpp(hpp, ret + 2);
460461
}
461462

462-
gtk_tree_store_set(store, &iter, col_idx, trim(bf), -1);
463+
gtk_tree_store_set(store, &iter, col_idx, strim(bf), -1);
463464

464465
if (!he->leaf) {
465466
hpp->buf = bf;
@@ -555,7 +556,7 @@ static void perf_gtk__show_hierarchy(GtkWidget *window, struct hists *hists,
555556
first_col = false;
556557

557558
fmt->header(fmt, &hpp, hists, 0, NULL);
558-
strcat(buf, trim(hpp.buf));
559+
strcat(buf, strim(hpp.buf));
559560
}
560561
}
561562

‎tools/perf/ui/stdio/hist.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static int hists__fprintf_hierarchy_headers(struct hists *hists,
620620

621621
fmt->header(fmt, hpp, hists, 0, NULL);
622622

623-
header_width += fprintf(fp, "%s", trim(hpp->buf));
623+
header_width += fprintf(fp, "%s", strim(hpp->buf));
624624
}
625625
}
626626

‎tools/perf/util/string2.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ char *strxfrchar(char *s, char from, char to);
2525

2626
char *rtrim(char *s);
2727

28-
static inline char *trim(char *s)
29-
{
30-
return skip_spaces(rtrim(s));
31-
}
32-
3328
char *asprintf_expr_inout_ints(const char *var, bool in, size_t nints, int *ints);
3429

3530
static inline char *asprintf_expr_in_ints(const char *var, size_t nints, int *ints)

0 commit comments

Comments
 (0)