Commit 32858480 authored by Arnaldo Carvalho de Melo's avatar Arnaldo Carvalho de Melo
Browse files

perf tools: Ditch rtrim(), use skip_spaces() to get closer to the kernel

No change in behaviour, just using the same kernel idiom for such
operation.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: André Goddard Rosa <andre.goddard@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lkml.kernel.org/n/tip-a85lkptkt0ru40irpga8yf54@git.kernel.org


Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 526bbbdd
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -2880,7 +2880,7 @@ static int read_script_info(struct script_desc *desc, const char *filename)
		return -1;

	while (fgets(line, sizeof(line), fp)) {
		p = ltrim(line);
		p = skip_spaces(line);
		if (strlen(p) == 0)
			continue;
		if (*p != '#')
@@ -2889,19 +2889,19 @@ static int read_script_info(struct script_desc *desc, const char *filename)
		if (strlen(p) && *p == '!')
			continue;

		p = ltrim(p);
		p = skip_spaces(p);
		if (strlen(p) && p[strlen(p) - 1] == '\n')
			p[strlen(p) - 1] = '\0';

		if (!strncmp(p, "description:", strlen("description:"))) {
			p += strlen("description:");
			desc->half_liner = strdup(ltrim(p));
			desc->half_liner = strdup(skip_spaces(p));
			continue;
		}

		if (!strncmp(p, "args:", strlen("args:"))) {
			p += strlen("args:");
			desc->args = strdup(ltrim(p));
			desc->args = strdup(skip_spaces(p));
			continue;
		}
	}
@@ -3008,7 +3008,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
		return -1;

	while (fgets(line, sizeof(line), fp)) {
		p = ltrim(line);
		p = skip_spaces(line);
		if (*p == '#')
			continue;

@@ -3018,7 +3018,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
				break;

			p += 2;
			p = ltrim(p);
			p = skip_spaces(p);
			len = strcspn(p, " \t");
			if (!len)
				break;
+1 −1
Original line number Diff line number Diff line
@@ -594,7 +594,7 @@ static int ui_browser__color_config(const char *var, const char *value,
			break;

		*bg = '\0';
		bg = ltrim(++bg);
		bg = skip_spaces(bg + 1);
		ui_browser__colorsets[i].bg = bg;
		ui_browser__colorsets[i].fg = fg;
		return 0;
+1 −1
Original line number Diff line number Diff line
@@ -1470,7 +1470,7 @@ static int hist_browser__show_hierarchy_entry(struct hist_browser *browser,
				int i = 0;

				width -= fmt->entry(fmt, &hpp, entry);
				ui_browser__printf(&browser->b, "%s", ltrim(s));
				ui_browser__printf(&browser->b, "%s", skip_spaces(s));

				while (isspace(s[i++]))
					width++;
+2 −2
Original line number Diff line number Diff line
@@ -459,7 +459,7 @@ static void perf_gtk__add_hierarchy_entries(struct hists *hists,
			advance_hpp(hpp, ret + 2);
		}

		gtk_tree_store_set(store, &iter, col_idx, ltrim(rtrim(bf)), -1);
		gtk_tree_store_set(store, &iter, col_idx, trim(bf), -1);

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

			fmt->header(fmt, &hpp, hists, 0, NULL);
			strcat(buf, ltrim(rtrim(hpp.buf)));
			strcat(buf, trim(hpp.buf));
		}
	}

+1 −1
Original line number Diff line number Diff line
@@ -516,7 +516,7 @@ static int hist_entry__hierarchy_fprintf(struct hist_entry *he,
		 * dynamic entries are right-aligned but we want left-aligned
		 * in the hierarchy mode
		 */
		printed += fprintf(fp, "%s%s", sep ?: "  ", ltrim(buf));
		printed += fprintf(fp, "%s%s", sep ?: "  ", skip_spaces(buf));
	}
	printed += putc('\n', fp);

Loading