Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf tools: Remove unused color_fwrite_lines
@ 2024-10-09  0:39 linux
  2024-10-09  0:48 ` Ian Rogers
  2024-10-10 15:51 ` Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: linux @ 2024-10-09  0:39 UTC (permalink / raw)
  To: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, irogers, adrian.hunter, kan.liang
  Cc: linux-perf-users, linux-kernel, Dr. David Alan Gilbert

From: "Dr. David Alan Gilbert" <linux@treblig.org>

color_fwrite_lines() was added by 2009's commit
8fc0321f1ad0 ("perf_counter tools: Add color terminal output support")

but has never been used.

Remove it.

Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>
---
 tools/perf/util/color.c | 28 ----------------------------
 tools/perf/util/color.h |  1 -
 2 files changed, 29 deletions(-)

diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index bffbdd216a6a..e51f0a676a22 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -93,34 +93,6 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...)
 	return r;
 }
 
-/*
- * This function splits the buffer by newlines and colors the lines individually.
- *
- * Returns 0 on success.
- */
-int color_fwrite_lines(FILE *fp, const char *color,
-		size_t count, const char *buf)
-{
-	if (!*color)
-		return fwrite(buf, count, 1, fp) != 1;
-
-	while (count) {
-		char *p = memchr(buf, '\n', count);
-
-		if (p != buf && (fputs(color, fp) < 0 ||
-				fwrite(buf, p ? (size_t)(p - buf) : count, 1, fp) != 1 ||
-				fputs(PERF_COLOR_RESET, fp) < 0))
-			return -1;
-		if (!p)
-			return 0;
-		if (fputc('\n', fp) < 0)
-			return -1;
-		count -= p + 1 - buf;
-		buf = p + 1;
-	}
-	return 0;
-}
-
 const char *get_percent_color(double percent)
 {
 	const char *color = PERF_COLOR_NORMAL;
diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
index 01f7bed21c9b..aecf56dae73f 100644
--- a/tools/perf/util/color.h
+++ b/tools/perf/util/color.h
@@ -39,7 +39,6 @@ int color_vsnprintf(char *bf, size_t size, const char *color,
 int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args);
 int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
 int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
-int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
 int value_color_snprintf(char *bf, size_t size, const char *fmt, double value);
 int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
 int percent_color_len_snprintf(char *bf, size_t size, const char *fmt, ...);
-- 
2.46.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf tools: Remove unused color_fwrite_lines
  2024-10-09  0:39 [PATCH] perf tools: Remove unused color_fwrite_lines linux
@ 2024-10-09  0:48 ` Ian Rogers
  2024-10-10 15:51 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2024-10-09  0:48 UTC (permalink / raw)
  To: linux
  Cc: peterz, mingo, acme, namhyung, mark.rutland, alexander.shishkin,
	jolsa, adrian.hunter, kan.liang, linux-perf-users, linux-kernel

On Tue, Oct 8, 2024 at 5:39 PM <linux@treblig.org> wrote:
>
> From: "Dr. David Alan Gilbert" <linux@treblig.org>
>
> color_fwrite_lines() was added by 2009's commit
> 8fc0321f1ad0 ("perf_counter tools: Add color terminal output support")
>
> but has never been used.
>
> Remove it.
>
> Signed-off-by: Dr. David Alan Gilbert <linux@treblig.org>

Reviewed-by: Ian Rogers <irogers@google.com>

Thanks,
Ian

> ---
>  tools/perf/util/color.c | 28 ----------------------------
>  tools/perf/util/color.h |  1 -
>  2 files changed, 29 deletions(-)
>
> diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
> index bffbdd216a6a..e51f0a676a22 100644
> --- a/tools/perf/util/color.c
> +++ b/tools/perf/util/color.c
> @@ -93,34 +93,6 @@ int color_fprintf(FILE *fp, const char *color, const char *fmt, ...)
>         return r;
>  }
>
> -/*
> - * This function splits the buffer by newlines and colors the lines individually.
> - *
> - * Returns 0 on success.
> - */
> -int color_fwrite_lines(FILE *fp, const char *color,
> -               size_t count, const char *buf)
> -{
> -       if (!*color)
> -               return fwrite(buf, count, 1, fp) != 1;
> -
> -       while (count) {
> -               char *p = memchr(buf, '\n', count);
> -
> -               if (p != buf && (fputs(color, fp) < 0 ||
> -                               fwrite(buf, p ? (size_t)(p - buf) : count, 1, fp) != 1 ||
> -                               fputs(PERF_COLOR_RESET, fp) < 0))
> -                       return -1;
> -               if (!p)
> -                       return 0;
> -               if (fputc('\n', fp) < 0)
> -                       return -1;
> -               count -= p + 1 - buf;
> -               buf = p + 1;
> -       }
> -       return 0;
> -}
> -
>  const char *get_percent_color(double percent)
>  {
>         const char *color = PERF_COLOR_NORMAL;
> diff --git a/tools/perf/util/color.h b/tools/perf/util/color.h
> index 01f7bed21c9b..aecf56dae73f 100644
> --- a/tools/perf/util/color.h
> +++ b/tools/perf/util/color.h
> @@ -39,7 +39,6 @@ int color_vsnprintf(char *bf, size_t size, const char *color,
>  int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args);
>  int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
>  int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
> -int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
>  int value_color_snprintf(char *bf, size_t size, const char *fmt, double value);
>  int percent_color_snprintf(char *bf, size_t size, const char *fmt, ...);
>  int percent_color_len_snprintf(char *bf, size_t size, const char *fmt, ...);
> --
> 2.46.2
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf tools: Remove unused color_fwrite_lines
  2024-10-09  0:39 [PATCH] perf tools: Remove unused color_fwrite_lines linux
  2024-10-09  0:48 ` Ian Rogers
@ 2024-10-10 15:51 ` Namhyung Kim
  1 sibling, 0 replies; 3+ messages in thread
From: Namhyung Kim @ 2024-10-10 15:51 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	irogers, adrian.hunter, kan.liang, linux
  Cc: linux-perf-users, linux-kernel


On Wed, 09 Oct 2024 01:39:38 +0100, linux@treblig.org wrote:
> color_fwrite_lines() was added by 2009's commit
> 8fc0321f1ad0 ("perf_counter tools: Add color terminal output support")
> 
> but has never been used.
> 
> Remove it.
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-10-10 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-09  0:39 [PATCH] perf tools: Remove unused color_fwrite_lines linux
2024-10-09  0:48 ` Ian Rogers
2024-10-10 15:51 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox