Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Remove some unused functions from color.c

Removes some functions that are not used anywhere:

color_parse_mem()
color_parse()

This was partially found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ramkumar Ramachandra <artagnon@gmail.com>
Link: http://lkml.kernel.org/r/1419079865-354-1-git-send-email-rickard_strandqvist@spectrumdigital.se
[ Remove now unused parse_{attr,color} routines too ]
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Rickard Strandqvist and committed by
Arnaldo Carvalho de Melo
c8defe24 590cd344

-128
-126
tools/perf/util/color.c
··· 5 5 6 6 int perf_use_color_default = -1; 7 7 8 - static int parse_color(const char *name, int len) 9 - { 10 - static const char * const color_names[] = { 11 - "normal", "black", "red", "green", "yellow", 12 - "blue", "magenta", "cyan", "white" 13 - }; 14 - char *end; 15 - int i; 16 - 17 - for (i = 0; i < (int)ARRAY_SIZE(color_names); i++) { 18 - const char *str = color_names[i]; 19 - if (!strncasecmp(name, str, len) && !str[len]) 20 - return i - 1; 21 - } 22 - i = strtol(name, &end, 10); 23 - if (end - name == len && i >= -1 && i <= 255) 24 - return i; 25 - return -2; 26 - } 27 - 28 - static int parse_attr(const char *name, int len) 29 - { 30 - static const int attr_values[] = { 1, 2, 4, 5, 7 }; 31 - static const char * const attr_names[] = { 32 - "bold", "dim", "ul", "blink", "reverse" 33 - }; 34 - unsigned int i; 35 - 36 - for (i = 0; i < ARRAY_SIZE(attr_names); i++) { 37 - const char *str = attr_names[i]; 38 - if (!strncasecmp(name, str, len) && !str[len]) 39 - return attr_values[i]; 40 - } 41 - return -1; 42 - } 43 - 44 - void color_parse(const char *value, const char *var, char *dst) 45 - { 46 - color_parse_mem(value, strlen(value), var, dst); 47 - } 48 - 49 - void color_parse_mem(const char *value, int value_len, const char *var, 50 - char *dst) 51 - { 52 - const char *ptr = value; 53 - int len = value_len; 54 - int attr = -1; 55 - int fg = -2; 56 - int bg = -2; 57 - 58 - if (!strncasecmp(value, "reset", len)) { 59 - strcpy(dst, PERF_COLOR_RESET); 60 - return; 61 - } 62 - 63 - /* [fg [bg]] [attr] */ 64 - while (len > 0) { 65 - const char *word = ptr; 66 - int val, wordlen = 0; 67 - 68 - while (len > 0 && !isspace(word[wordlen])) { 69 - wordlen++; 70 - len--; 71 - } 72 - 73 - ptr = word + wordlen; 74 - while (len > 0 && isspace(*ptr)) { 75 - ptr++; 76 - len--; 77 - } 78 - 79 - val = parse_color(word, wordlen); 80 - if (val >= -1) { 81 - if (fg == -2) { 82 - fg = val; 83 - continue; 84 - } 85 - if (bg == -2) { 86 - bg = val; 87 - continue; 88 - } 89 - goto bad; 90 - } 91 - val = parse_attr(word, wordlen); 92 - if (val < 0 || attr != -1) 93 - goto bad; 94 - attr = val; 95 - } 96 - 97 - if (attr >= 0 || fg >= 0 || bg >= 0) { 98 - int sep = 0; 99 - 100 - *dst++ = '\033'; 101 - *dst++ = '['; 102 - if (attr >= 0) { 103 - *dst++ = '0' + attr; 104 - sep++; 105 - } 106 - if (fg >= 0) { 107 - if (sep++) 108 - *dst++ = ';'; 109 - if (fg < 8) { 110 - *dst++ = '3'; 111 - *dst++ = '0' + fg; 112 - } else { 113 - dst += sprintf(dst, "38;5;%d", fg); 114 - } 115 - } 116 - if (bg >= 0) { 117 - if (sep++) 118 - *dst++ = ';'; 119 - if (bg < 8) { 120 - *dst++ = '4'; 121 - *dst++ = '0' + bg; 122 - } else { 123 - dst += sprintf(dst, "48;5;%d", bg); 124 - } 125 - } 126 - *dst++ = 'm'; 127 - } 128 - *dst = 0; 129 - return; 130 - bad: 131 - die("bad color value '%.*s' for variable '%s'", value_len, value, var); 132 - } 133 - 134 8 int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty) 135 9 { 136 10 if (value) {
-2
tools/perf/util/color.h
··· 30 30 int perf_color_default_config(const char *var, const char *value, void *cb); 31 31 32 32 int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty); 33 - void color_parse(const char *value, const char *var, char *dst); 34 - void color_parse_mem(const char *value, int len, const char *var, char *dst); 35 33 int color_vsnprintf(char *bf, size_t size, const char *color, 36 34 const char *fmt, va_list args); 37 35 int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args);