Commit 6520175e authored by sin's avatar sin

Fix type inconsistencies and remove hacky compiler options

-Os generates lots of false positives and it is not worth it much
for such a small set of tools.
parent 6c6d1a3d
......@@ -7,7 +7,7 @@ PREFIX = /usr/local
LIBS = -lpng
# flags
CFLAGS = -std=c90 -pedantic -ansi -Wall -Wextra -Wno-pointer-sign -Wno-maybe-uninitialized -Wno-clobbered -Os
CFLAGS = -std=c90 -ansi -pedantic -Wall -Wextra
LDFLAGS = -s ${LIBS}
# compiler and linker
......
......@@ -26,7 +26,8 @@ main(int argc, char *argv[])
png_structp png_struct_p;
png_infop png_info_p;
uint8_t hdr[17], *png_row;
uint32_t width, height, png_row_len, i;
png_uint_32 width, height, i;
png_size_t png_row_len;
ARGBEGIN {
default:
......@@ -41,7 +42,7 @@ main(int argc, char *argv[])
fprintf(stderr, "failed to read from stdin or input too short\n");
goto err;
}
if (strcmp("imagefile", hdr)) {
if (memcmp("imagefile", hdr, 9)) {
fprintf(stderr, "invalid header\n");
goto err;
}
......
......@@ -24,7 +24,10 @@ main(int argc, char *argv[])
png_structp png_struct_p;
png_infop png_info_p;
png_bytepp png_row_p;
uint32_t width, height, val_be, depth, color, interlace, png_row_len, r;
png_uint_32 width, height, i;
png_size_t png_row_len;
uint32_t val_be;
int depth, color, interlace;
ARGBEGIN {
default:
......@@ -60,8 +63,8 @@ main(int argc, char *argv[])
fwrite(&val_be, sizeof(uint32_t), 1, stdout);
/* write data */
for (r = 0; r < height; ++r) {
if (fwrite(png_row_p[r], 1, (size_t)png_row_len, stdout) != png_row_len) {
for (i = 0; i < height; i++) {
if (fwrite(png_row_p[i], 1, png_row_len, stdout) != png_row_len) {
fprintf(stderr, "fwrite() failed\n");
goto err;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment