Skip to content

Commit 0d748ad

Browse files
committed
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.
1 parent e2b3c36 commit 0d748ad

File tree

571 files changed

+1307
-1889
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

571 files changed

+1307
-1889
lines changed

dsp/core/c121.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ COSMOPOLITAN_C_START_
55

66
__funline unsigned char C121(unsigned char al, unsigned char bl,
77
unsigned char cl) {
8-
unsigned short ax, bx;
8+
unsigned short ax;
99
ax = al;
1010
ax += bl;
1111
ax += bl;

dsp/core/c121s.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#if !(__ASSEMBLER__ + __LINKER__ + 0)
44

55
__funline signed char C121S(signed char al, signed char bl, signed char cl) {
6-
short ax, bx;
6+
short ax;
77
ax = al;
88
ax += bl;
99
ax += bl;

dsp/core/sad16x8n.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,14 @@
3131
* @param y needs to be 16-byte aligned
3232
*/
3333
void sad16x8n(size_t n, short x[n][8], const short y[n][8]) {
34-
size_t i, j;
34+
size_t i;
3535
for (i = 0; i < n; ++i) {
3636
#ifdef __x86_64__
3737
*(__m128i *)x[i] = _mm_adds_epi16(*(__m128i *)x[i], *(__m128i *)y[i]);
3838
#elif defined(__aarch64__)
3939
*(int16x4_t *)x[i] = vqadd_s16(*(int16x4_t *)x[i], *(int16x4_t *)y[i]);
4040
#else
41+
size_t j;
4142
for (j = 0; j < 8; ++j) {
4243
x[i][j] = MIN(MAX(x[i][j] + y[i][j], INT16_MIN), INT16_MAX);
4344
}

dsp/mpeg/idct.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ asm(".include \"libc/disclaimer.inc\"");
4141
* @note discovered by Nasir Ahmed
4242
*/
4343
void plm_video_idct(int block[8][8]) {
44-
int i, j, t1, t2, m0;
44+
int i, t1, t2, m0;
4545
int b1, b3, b4, b6, b7;
4646
int y3, y4, y5, y6, y7;
4747
int x0, x1, x2, x3, x4;

dsp/mpeg/mpeg1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,12 +1105,12 @@ plm_video_t *plm_video_create_with_buffer(plm_buffer_t *buffer,
11051105

11061106
static textstartup void plm_video_init(void) {
11071107
PLM_VIDEO_MACROBLOCK_TYPE[0] = NULL;
1108-
PLM_VIDEO_MACROBLOCK_TYPE[1] = PLM_VIDEO_MACROBLOCK_TYPE_INTRA;
1109-
PLM_VIDEO_MACROBLOCK_TYPE[2] = PLM_VIDEO_MACROBLOCK_TYPE_PREDICTIVE,
1110-
PLM_VIDEO_MACROBLOCK_TYPE[3] = PLM_VIDEO_MACROBLOCK_TYPE_B;
1111-
PLM_VIDEO_DCT_SIZE[0] = PLM_VIDEO_DCT_SIZE_LUMINANCE;
1112-
PLM_VIDEO_DCT_SIZE[1] = PLM_VIDEO_DCT_SIZE_CHROMINANCE;
1113-
PLM_VIDEO_DCT_SIZE[2] = PLM_VIDEO_DCT_SIZE_CHROMINANCE;
1108+
PLM_VIDEO_MACROBLOCK_TYPE[1] = (void *)PLM_VIDEO_MACROBLOCK_TYPE_INTRA;
1109+
PLM_VIDEO_MACROBLOCK_TYPE[2] = (void *)PLM_VIDEO_MACROBLOCK_TYPE_PREDICTIVE;
1110+
PLM_VIDEO_MACROBLOCK_TYPE[3] = (void *)PLM_VIDEO_MACROBLOCK_TYPE_B;
1111+
PLM_VIDEO_DCT_SIZE[0] = (void *)PLM_VIDEO_DCT_SIZE_LUMINANCE;
1112+
PLM_VIDEO_DCT_SIZE[1] = (void *)PLM_VIDEO_DCT_SIZE_CHROMINANCE;
1113+
PLM_VIDEO_DCT_SIZE[2] = (void *)PLM_VIDEO_DCT_SIZE_CHROMINANCE;
11141114
}
11151115

11161116
const void *const plm_video_init_ctor[] initarray = {plm_video_init};

dsp/scale/cdecimate2xuint8x8.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ void *cDecimate2xUint8x8(unsigned long n, unsigned char A[n],
5555
K[4], K[5], K[4], K[5], K[4], K[5], K[4], K[5]};
5656
signed char kMadd4[16] = {K[6], K[7], K[6], K[7], K[6], K[7], K[6], K[7],
5757
K[6], K[7], K[6], K[7], K[6], K[7], K[6], K[7]};
58-
unsigned char in1[16], in2[16], in3[16], in4[32];
5958
unsigned char bv0[16], bv1[16], bv2[16], bv3[16];
59+
unsigned char in1[16], in2[16], in3[16];
6060
short wv0[8], wv1[8], wv2[8], wv3[8];
61-
unsigned long i, j, v, w, o;
61+
unsigned long i, j, w;
6262
if (n >= STRIDE) {
6363
i = 0;
6464
w = (n + RATIO / 2) / RATIO;

dsp/scale/gyarados.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ static bool IsNormalized(int n, double A[n]) {
8282
}
8383

8484
void FreeSamplingSolution(struct SamplingSolution *ss) {
85-
long i;
8685
if (ss) {
8786
free(ss->indices);
8887
free(ss->weights);
@@ -93,7 +92,7 @@ void FreeSamplingSolution(struct SamplingSolution *ss) {
9392
struct SamplingSolution *ComputeSamplingSolution(long dn, long sn, double dar,
9493
double off, double par) {
9594
double *fweights;
96-
double sum, hw, w, x, f;
95+
double sum, hw, x, f;
9796
short *weights, *indices;
9897
struct SamplingSolution *res;
9998
long j, i, k, n, min, max, s, N[6];
@@ -151,8 +150,8 @@ static void GyaradosImpl(long dyw, long dxw, int dst[dyw][dxw], long syw,
151150
const short fyi[dyn][yfn], const short fyw[dyn][yfn],
152151
const short fxi[dxn][xfn], const short fxw[dxn][xfn],
153152
bool sharpen) {
154-
long i, j;
155-
int eax, dy, dx, sy, sx;
153+
long i;
154+
int eax, dy, dx, sx;
156155
for (sx = 0; sx < sxn; ++sx) {
157156
for (dy = 0; dy < dyn; ++dy) {
158157
for (eax = i = 0; i < yfn; ++i) {

dsp/tty/rgb2ansi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ static int uncube(int x) {
9898
}
9999

100100
static textstartup void rgb2ansi_init(void) {
101-
uint8_t c, y;
102-
uint32_t i, j;
101+
uint8_t c;
102+
uint32_t i;
103103
memcpy(g_ansi2rgb_, &kCgaPalette, sizeof(kCgaPalette));
104104
for (i = 16; i < 232; ++i) {
105105
g_ansi2rgb_[i].r = kXtermCube[((i - 020) / 044) % 06];

dsp/tty/ttyraster.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ static struct Pick PickBlockUnicodeAnsi(struct TtyRgb tl, struct TtyRgb tr,
609609
struct TtyRgb tr2 = GetQuant(tr);
610610
struct TtyRgb bl2 = GetQuant(bl);
611611
struct TtyRgb br2 = GetQuant(br);
612-
unsigned i, p1, p2;
612+
unsigned p1, p2;
613613
uint16_t picks1[96] forcealign(32);
614614
uint16_t picks2[32] forcealign(32);
615615
memset(picks1, 0x79, sizeof(picks1));
@@ -646,7 +646,7 @@ static struct Pick PickBlockCp437Ansi(struct TtyRgb tl, struct TtyRgb tr,
646646
struct TtyRgb tr2 = GetQuant(tr);
647647
struct TtyRgb bl2 = GetQuant(bl);
648648
struct TtyRgb br2 = GetQuant(br);
649-
unsigned i, p1, p2;
649+
unsigned p1, p2;
650650
uint16_t picks1[32] forcealign(32);
651651
uint16_t picks2[32] forcealign(32);
652652
memset(picks1, 0x79, sizeof(picks1));
@@ -660,7 +660,6 @@ static struct Pick PickBlockCp437Ansi(struct TtyRgb tl, struct TtyRgb tr,
660660

661661
static struct Pick PickBlockCp437True(struct TtyRgb tl, struct TtyRgb tr,
662662
struct TtyRgb bl, struct TtyRgb br) {
663-
unsigned i;
664663
uint16_t picks[32] forcealign(32);
665664
memset(picks, 0x79, sizeof(picks));
666665
PickCp437(picks, tl, tr, bl, br, tl, tr, bl, br);

dsp/tty/write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838
* @return 0 on success, or -1 w/ errno
3939
*/
4040
ssize_t ttywrite(int fd, const void *data, size_t size) {
41-
char *p;
4241
ssize_t rc;
42+
const char *p;
4343
size_t wrote, n;
4444
p = data;
4545
n = size;

0 commit comments

Comments
 (0)