]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - tools/perf/util/color.c
perf_counter tools: Add more warnings and fix/annotate them
[mirror_ubuntu-artful-kernel.git] / tools / perf / util / color.c
index 9a8c20ccc53e28dd99ab6bd2f27f548fe85532fe..26f82318b86bbc7fd70f1d1335c1cdf947ea48d0 100644 (file)
@@ -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)