Skip to contentSkip to conversation

perf tools: Remove unused color_fwrite_lines

PATCH Applied [email protected] 3 participants 3 messages Oct 9, 2024 – Oct 10, 2024 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf tools: Remove unused color_fwrite_lines

From: "Dr. David Alan Gilbert" <[email protected]>

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.

---
 tools/perf/util/color.c | 28 ----------------------------
 tools/perf/util/color.h |  1 -
 2 files changed, 29 deletions(-)
tools/perf/util/color.c +0 -28
index bffbdd216a6a..e51f0a676a22 100644
@@ -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;
tools/perf/util/color.h +0 -1
index 01f7bed21c9b..aecf56dae73f 100644
@@ -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, ...);
Signature · 1 line
2.46.2
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · On Tue, Oct 8, 2024 at 5:39 PM <[email protected]> wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

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.

Thanks,
Ian

Quoted 59 lines
---
 tools/perf/util/color.c | 28 ----------------------------
 tools/perf/util/color.h |  1 -
 2 files changed, 29 deletions(-)
tools/perf/util/color.c +0 -28
index bffbdd216a6a..e51f0a676a22 100644
@@ -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;
tools/perf/util/color.h +0 -2
index 01f7bed21c9b..aecf56dae73f 100644
@@ -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

maintainer Applied
#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Wed, 09 Oct 2024 01:39:38 +0100, [email protected] 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