perf_counter tools: Add more warnings and fix/annotate them
Enable -Wextra. This found a few real bugs plus a number of signed/unsigned type mismatches/uncleanlinesses. It also required a few annotations All things considered it was still worth it so lets try with this enabled for now. Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Mike Galbraith <efault@gmx.de> Cc: Paul Mackerras <paulus@samba.org> Cc: Arnaldo Carvalho de Melo <acme@redhat.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <new-submission> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
@@ -11,7 +11,8 @@ static int parse_color(const char *name, int len)
|
||||
};
|
||||
char *end;
|
||||
int i;
|
||||
for (i = 0; i < ARRAY_SIZE(color_names); i++) {
|
||||
|
||||
for (i = 0; i < (int)ARRAY_SIZE(color_names); i++) {
|
||||
const char *str = color_names[i];
|
||||
if (!strncasecmp(name, str, len) && !str[len])
|
||||
return i - 1;
|
||||
@@ -28,7 +29,8 @@ static int parse_attr(const char *name, int len)
|
||||
static const char * const attr_names[] = {
|
||||
"bold", "dim", "ul", "blink", "reverse"
|
||||
};
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(attr_names); i++) {
|
||||
const char *str = attr_names[i];
|
||||
if (!strncasecmp(name, str, len) && !str[len])
|
||||
@@ -222,10 +224,12 @@ int color_fwrite_lines(FILE *fp, const char *color,
|
||||
{
|
||||
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 ? p - buf : count, 1, fp) != 1 ||
|
||||
fwrite(buf, p ? (size_t)(p - buf) : count, 1, fp) != 1 ||
|
||||
fputs(PERF_COLOR_RESET, fp) < 0))
|
||||
return -1;
|
||||
if (!p)
|
||||
|
Reference in New Issue
Block a user