Fix warnings

This change fixes Cosmopolitan so it has fewer opinions about compiler
warnings. The whole repository had to be cleaned up to be buildable in
-Werror -Wall mode. This lets us benefit from things like strict const
checking. Some actual bugs might have been caught too.
This commit is contained in:
Justine Tunney 2023-09-01 20:49:13 -07:00
parent e2b3c3618e
commit 0d748ad58e
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
571 changed files with 1306 additions and 1888 deletions

View file

@ -178,8 +178,8 @@ static void GetOpts(int *argc, char *argv[]) {
g_winsize.ws_col = 80;
g_winsize.ws_row = 24;
if (!g_flags.full && (!g_flags.width || !g_flags.height)) {
tcgetwinsize(STDIN_FILENO, &g_winsize) != -1 ||
tcgetwinsize(STDOUT_FILENO, &g_winsize);
(void)(tcgetwinsize(STDIN_FILENO, &g_winsize) != -1 ||
tcgetwinsize(STDOUT_FILENO, &g_winsize));
}
ttyquantsetup(g_flags.quant, kTtyQuantRgb, g_flags.blocks);
}
@ -220,11 +220,10 @@ static void PrintImageImpl(long syn, long sxn, unsigned char RGB[3][syn][sxn],
long y0, long yn, long x0, long xn, long dy,
long dx) {
long y, x;
bool didhalfy, didfirstx;
bool didhalfy;
unsigned char a[3], b[3];
didhalfy = false;
for (y = y0; y < yn; y += dy) {
didfirstx = false;
if (y) printf("\e[0m\n");
for (x = x0; x < xn; x += dx) {
a[0] = RGB[0][y][x];
@ -239,7 +238,6 @@ static void PrintImageImpl(long syn, long sxn, unsigned char RGB[3][syn][sxn],
}
printf("\e[48;2;%d;%d;%d;38;2;%d;%d;%dm%lc", a[0], a[1], a[2], b[0], b[1],
b[2], dy > 1 ? u'' : u'');
didfirstx = true;
}
printf("\e[0m");
if (g_flags.ruler) {
@ -363,7 +361,7 @@ static void ProcessImage(long yn, long xn, unsigned char RGB[3][yn][xn]) {
void WithImageFile(const char *path,
void fn(long yn, long xn, unsigned char RGB[3][yn][xn])) {
struct stat st;
void *map, *data, *data2;
void *map, *data;
int fd, yn, xn, cn, dyn, dxn, syn, sxn, wyn, wxn;
CHECK_NE(-1, (fd = open(path, O_RDONLY)), "%s", path);
CHECK_NE(-1, fstat(fd, &st));