logo

utils

~/.local/bin tools and git-hooks git clone https://hacktivis.me/git/utils.git
commit: f5b2fdaa30df10d519545b24bceb751265cf6153
parent 28ae095b716ded6f7f6d6c74393ba0fcbe0001e5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sun, 24 Oct 2021 15:02:03 +0200

bin/xcd: Fix conversion warning

Diffstat:

Mbin/xcd.c27++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/bin/xcd.c b/bin/xcd.c @@ -14,7 +14,7 @@ struct rgb { - uint8_t red, green, blue; + double red, green, blue; }; struct rgb @@ -43,22 +43,19 @@ void print_hex_rgb(unsigned char c) { struct rgb color = rgb_char(c); - printf("[38;2;%d;%d;%dm%02hhx ", color.red, color.green, color.blue, c); + printf("[38;2;%d;%d;%dm%02hhx ", (int)color.red, (int)color.green, (int)color.blue, c); } void print_plain_rgb(char *line, size_t len) { - unsigned char c; - LANODAN_XCD_RESET printf(" >"); for(size_t i = 0; i < len; i++) { - c = line[i]; - struct rgb color = rgb_char(c); - printf("[38;2;%d;%d;%dm%c", color.red, color.green, color.blue, isprint(c) ? c : '.'); + struct rgb color = rgb_char((unsigned char)line[i]); + printf("[38;2;%d;%d;%dm%c", (int)color.red, (int)color.green, (int)color.blue, isprint(line[i]) ? line[i] : '.'); } LANODAN_XCD_RESET @@ -72,7 +69,7 @@ concat(FILE *stream) { int cols = 0; char line[WIDTH]; - unsigned char c; + char c; unsigned int bytes = 0; struct rgb pos_rgb; errno = 0; @@ -81,8 +78,8 @@ concat(FILE *stream) LANODAN_XCD_RESET - pos_rgb = rgb_char(bytes); - printf("[38;2;%d;%d;%dm%06x ", pos_rgb.red, pos_rgb.green, pos_rgb.blue, bytes); + pos_rgb = rgb_char((unsigned char)bytes); + printf("[38;2;%d;%d;%dm%06x ", (int)pos_rgb.red, (int)pos_rgb.green, (int)pos_rgb.blue, bytes); while(fread(&c, 1, 1, stream) > 0) { if(cols >= WIDTH) @@ -90,13 +87,13 @@ concat(FILE *stream) print_plain_rgb(line, (size_t)cols); memset(&line, 0, WIDTH); - pos_rgb = rgb_char(bytes); - printf("\n[38;2;%d;%d;%dm%06x ", pos_rgb.red, pos_rgb.green, pos_rgb.blue, bytes); + pos_rgb = rgb_char((unsigned char)bytes); + printf("\n[38;2;%d;%d;%dm%06x ", (int)pos_rgb.red, (int)pos_rgb.green, (int)pos_rgb.blue, bytes); cols = 0; } - print_hex_rgb(c); + print_hex_rgb((unsigned char)c); line[cols] = c; cols++; @@ -110,8 +107,8 @@ concat(FILE *stream) LANODAN_XCD_RESET print_plain_rgb(line, (size_t)cols); - pos_rgb = rgb_char(bytes); - printf("\n[38;2;%d;%d;%dm%06x\n", pos_rgb.red, pos_rgb.green, pos_rgb.blue, bytes); + pos_rgb = rgb_char((unsigned char)bytes); + printf("\n[38;2;%d;%d;%dm%06x\n", (int)pos_rgb.red, (int)pos_rgb.green, (int)pos_rgb.blue, bytes); LANODAN_XCD_RESET return 0;