mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-18 08:32:11 +01:00
Separate status and status_msg local variables
This commit is contained in:
1 parent
fb54ba452f
commit
c50f16e58b
10 files changed
+213
-212
No files matched your search
@@ -273,8 +273,8 @@ const char* try_allocate(wuffs_gif__decoder* dec,
|
||||
}
|
||||
|
||||
const char* allocate(wuffs_gif__decoder* dec, wuffs_base__image_config* ic) {
|
||||
const char* status = try_allocate(dec, ic);
|
||||
if (status) {
|
||||
const char* status_msg = try_allocate(dec, ic);
|
||||
if (status_msg) {
|
||||
free(printbuf.ptr);
|
||||
printbuf = wuffs_base__make_slice_u8(NULL, 0);
|
||||
free(workbuf.ptr);
|
||||
@@ -287,7 +287,7 @@ const char* allocate(wuffs_gif__decoder* dec, wuffs_base__image_config* ic) {
|
||||
curr_dst_buffer = NULL;
|
||||
dst_len = 0;
|
||||
}
|
||||
return status;
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
const char* play() {
|
||||
@@ -446,16 +446,16 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
const char* status = read_stdin();
|
||||
if (status) {
|
||||
fprintf(stderr, "%s\n", status);
|
||||
const char* status_msg = read_stdin();
|
||||
if (status_msg) {
|
||||
fprintf(stderr, "%s\n", status_msg);
|
||||
return 1;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
status = play();
|
||||
if (status) {
|
||||
fprintf(stderr, "%s\n", status);
|
||||
status_msg = play();
|
||||
if (status_msg) {
|
||||
fprintf(stderr, "%s\n", status_msg);
|
||||
return 1;
|
||||
}
|
||||
if (num_loops_remaining == 0) {
|
||||
|
||||
@@ -118,9 +118,9 @@ static const char* decode() {
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
const char* status = decode();
|
||||
if (status) {
|
||||
fprintf(stderr, "%s\n", status);
|
||||
const char* status_msg = decode();
|
||||
if (status_msg) {
|
||||
fprintf(stderr, "%s\n", status_msg);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
+2
-2
@@ -163,8 +163,8 @@ int main(int argc, char** argv) {
|
||||
prctl(PR_SET_SECCOMP, SECCOMP_MODE_STRICT);
|
||||
#endif
|
||||
|
||||
const char* status = decode();
|
||||
int status_code = status ? fail(status) : 0;
|
||||
const char* status_msg = decode();
|
||||
int status_code = status_msg ? fail(status_msg) : 0;
|
||||
|
||||
#if defined(WUFFS_EXAMPLE_USE_SECCOMP)
|
||||
// Call SYS_exit explicitly instead of SYS_exit_group implicitly.
|
||||
|
||||
@@ -122,15 +122,15 @@ const char* test_wuffs_adler32_golden() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status = read_file(&src, test_cases[i].filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, test_cases[i].filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
int j;
|
||||
for (j = 0; j < 2; j++) {
|
||||
wuffs_adler32__hasher checksum;
|
||||
status = wuffs_adler32__hasher__initialize(
|
||||
wuffs_base__status status = wuffs_adler32__hasher__initialize(
|
||||
&checksum, sizeof checksum, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
|
||||
+4
-4
@@ -122,15 +122,15 @@ const char* test_wuffs_crc32_ieee_golden() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status = read_file(&src, test_cases[i].filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, test_cases[i].filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
int j;
|
||||
for (j = 0; j < 2; j++) {
|
||||
wuffs_crc32__ieee_hasher checksum;
|
||||
status = wuffs_crc32__ieee_hasher__initialize(
|
||||
wuffs_base__status status = wuffs_crc32__ieee_hasher__initialize(
|
||||
&checksum, sizeof checksum, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
|
||||
+41
-41
@@ -230,11 +230,11 @@ const char* test_wuffs_deflate_decode_deflate_huffman_primlen_9() {
|
||||
CHECK_FOCUS(__func__);
|
||||
|
||||
// First, treat this like any other compare-to-golden test.
|
||||
const char* status = do_test_io_buffers(wuffs_deflate_decode,
|
||||
&deflate_deflate_huffman_primlen_9_gt,
|
||||
UINT64_MAX, UINT64_MAX);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = do_test_io_buffers(
|
||||
wuffs_deflate_decode, &deflate_deflate_huffman_primlen_9_gt, UINT64_MAX,
|
||||
UINT64_MAX);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
// Second, check that the decoder's huffman table sizes match those predicted
|
||||
@@ -247,13 +247,13 @@ const char* test_wuffs_deflate_decode_deflate_huffman_primlen_9() {
|
||||
});
|
||||
|
||||
golden_test* gt = &deflate_deflate_huffman_primlen_9_gt;
|
||||
status = read_file(&src, gt->src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&src, gt->src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_deflate__decoder dec;
|
||||
status = wuffs_deflate__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_deflate__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION, WUFFS_INITIALIZE__DEFAULT_OPTIONS);
|
||||
if (status) {
|
||||
RETURN_FAIL("initialize: \"%s\"", status);
|
||||
@@ -337,15 +337,15 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
.data = global_want_slice,
|
||||
});
|
||||
|
||||
const char* status;
|
||||
const char* status_msg;
|
||||
golden_test* gt = &deflate_256_bytes_gt;
|
||||
status = read_file(&src, gt->src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&src, gt->src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
status = read_file(&want, gt->want_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&want, gt->want_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
int i;
|
||||
@@ -357,7 +357,7 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
got.meta.wi = 0;
|
||||
|
||||
wuffs_deflate__decoder dec;
|
||||
status = wuffs_deflate__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_deflate__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -387,9 +387,9 @@ const char* test_wuffs_deflate_decode_split_src() {
|
||||
|
||||
char prefix[64];
|
||||
snprintf(prefix, 64, "i=%d: ", i);
|
||||
status = check_io_buffers_equal(prefix, &got, &want);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = check_io_buffers_equal(prefix, &got, &want);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -436,33 +436,33 @@ const char* test_wuffs_deflate_history_full() {
|
||||
.data = global_want_slice,
|
||||
});
|
||||
|
||||
const char* status;
|
||||
const char* status_msg;
|
||||
golden_test* gt = &deflate_pi_gt;
|
||||
status = read_file(&src, gt->src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&src, gt->src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
status = read_file(&want, gt->want_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&want, gt->want_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
const int full_history_size = 0x8000;
|
||||
int i;
|
||||
for (i = -2; i <= +2; i++) {
|
||||
wuffs_deflate__decoder dec;
|
||||
status = wuffs_deflate__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_deflate__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
RETURN_FAIL("initialize: \"%s\"", status);
|
||||
}
|
||||
|
||||
status = do_test_wuffs_deflate_history(
|
||||
status_msg = do_test_wuffs_deflate_history(
|
||||
i, gt, &src, &got, &dec, 0, want.meta.wi + i,
|
||||
i >= 0 ? NULL : wuffs_base__suspension__short_write);
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
uint32_t want_history_index = i >= 0 ? 0 : full_history_size;
|
||||
@@ -492,9 +492,9 @@ const char* test_wuffs_deflate_history_full() {
|
||||
});
|
||||
history_want.meta.wi = full_history_size;
|
||||
|
||||
status = check_io_buffers_equal("", &history_got, &history_want);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = check_io_buffers_equal("", &history_got, &history_want);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -511,9 +511,9 @@ const char* test_wuffs_deflate_history_partial() {
|
||||
});
|
||||
|
||||
golden_test* gt = &deflate_pi_gt;
|
||||
const char* status = read_file(&src, gt->src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, gt->src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
uint32_t starting_history_indexes[] = {
|
||||
@@ -532,18 +532,18 @@ const char* test_wuffs_deflate_history_partial() {
|
||||
wuffs_deflate__decoder dec;
|
||||
memset(&(dec.private_data.f_history), 0,
|
||||
sizeof(dec.private_data.f_history));
|
||||
status = wuffs_deflate__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_deflate__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
RETURN_FAIL("initialize: \"%s\"", status);
|
||||
}
|
||||
|
||||
status = do_test_wuffs_deflate_history(
|
||||
status_msg = do_test_wuffs_deflate_history(
|
||||
i, gt, &src, &got, &dec, starting_history_index, fragment_length,
|
||||
wuffs_base__suspension__short_write);
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
bool got_full = dec.private_impl.f_history_index >= 0x8000;
|
||||
|
||||
+131
-130
@@ -234,10 +234,10 @@ const char* wuffs_gif_decode(wuffs_base__io_buffer* dst,
|
||||
RETURN_FAIL("decode_frame: \"%s\"", status);
|
||||
}
|
||||
|
||||
status = copy_to_io_buffer_from_pixel_buffer(
|
||||
const char* status_msg = copy_to_io_buffer_from_pixel_buffer(
|
||||
dst, &pb, wuffs_base__frame_config__bounds(&fc));
|
||||
if (status) {
|
||||
RETURN_FAIL("copy_to_io_buffer_from_pixel_buffer: \"%s\"", status);
|
||||
if (status_msg) {
|
||||
RETURN_FAIL("copy_to_io_buffer_from_pixel_buffer: \"%s\"", status_msg);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
@@ -255,13 +255,13 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -367,10 +367,10 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
}
|
||||
}
|
||||
|
||||
status = copy_to_io_buffer_from_pixel_buffer(
|
||||
status_msg = copy_to_io_buffer_from_pixel_buffer(
|
||||
&got, &pb, wuffs_base__frame_config__bounds(&fc));
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
if (rlimit < UINT64_MAX) {
|
||||
@@ -390,32 +390,32 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
.len = 1024,
|
||||
}),
|
||||
});
|
||||
status = read_file(&pal_want, palette_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&pal_want, palette_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
if (dst_pixfmt == WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY) {
|
||||
wuffs_base__io_buffer pal_got = ((wuffs_base__io_buffer){
|
||||
.data = wuffs_base__pixel_buffer__palette(&pb),
|
||||
});
|
||||
pal_got.meta.wi = pal_got.data.len;
|
||||
status = check_io_buffers_equal("palette ", &pal_got, &pal_want);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = check_io_buffers_equal("palette ", &pal_got, &pal_want);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
}
|
||||
|
||||
wuffs_base__io_buffer ind_want = ((wuffs_base__io_buffer){
|
||||
.data = global_want_slice,
|
||||
});
|
||||
status = read_file(&ind_want, indexes_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&ind_want, indexes_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
if (dst_pixfmt == WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY) {
|
||||
status = check_io_buffers_equal("indexes ", &got, &ind_want);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = check_io_buffers_equal("indexes ", &got, &ind_want);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
} else {
|
||||
wuffs_base__io_buffer expanded_want = ((wuffs_base__io_buffer){
|
||||
@@ -467,9 +467,9 @@ const char* do_test_wuffs_gif_decode(const char* filename,
|
||||
return "unsupported pixel format";
|
||||
}
|
||||
|
||||
status = check_io_buffers_equal("pixels ", &got, &expanded_want);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = check_io_buffers_equal("pixels ", &got, &expanded_want);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -544,13 +544,13 @@ const char* test_wuffs_gif_call_interleaved() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, "test/data/bricks-dither.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/bricks-dither.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -589,13 +589,13 @@ const char* test_wuffs_gif_call_sequence() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, "test/data/bricks-dither.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/bricks-dither.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -624,13 +624,13 @@ const char* do_test_wuffs_gif_decode_animated(
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -747,9 +747,9 @@ const char* test_wuffs_gif_decode_delay_num_frames_decoded() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status = read_file(&src, "test/data/animated-red-blue.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/animated-red-blue.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
if (src.meta.wi < 1) {
|
||||
return "src file is too short";
|
||||
@@ -769,7 +769,7 @@ const char* test_wuffs_gif_decode_delay_num_frames_decoded() {
|
||||
src.meta.ri = 0;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -800,17 +800,17 @@ const char* test_wuffs_gif_decode_empty_palette() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-empty-palette.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
int q;
|
||||
for (q = 0; q < 2; q++) {
|
||||
src.meta.ri = 0;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -871,17 +871,17 @@ const char* test_wuffs_gif_decode_background_color() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-background-color.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
int q;
|
||||
for (q = 0; q < 2; q++) {
|
||||
src.meta.ri = 0;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -912,17 +912,17 @@ const char* test_wuffs_gif_decode_first_frame_is_opaque() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-frame-out-of-bounds.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
int q;
|
||||
for (q = 0; q < 2; q++) {
|
||||
src.meta.ri = 0;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -953,10 +953,10 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-frame-out-of-bounds.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
int q;
|
||||
@@ -964,7 +964,7 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
||||
src.meta.ri = 0;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1125,17 +1125,17 @@ const char* test_wuffs_gif_decode_zero_width_frame() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-zero-width-frame.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
int q;
|
||||
for (q = 0; q < 3; q++) {
|
||||
src.meta.ri = 0;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1256,13 +1256,13 @@ const char* test_wuffs_gif_decode_input_is_a_png() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, "test/data/bricks-dither.png");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/bricks-dither.png");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1285,14 +1285,14 @@ const char* test_wuffs_gif_decode_interlaced_truncated() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/hippopotamus.interlaced.truncated.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1361,11 +1361,11 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, full ? "test/data/artificial/gif-metadata-full.gif"
|
||||
: "test/data/artificial/gif-metadata-empty.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
int iccp;
|
||||
@@ -1376,7 +1376,7 @@ const char* do_test_wuffs_gif_decode_metadata(bool full) {
|
||||
bool seen_xmp = false;
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1530,9 +1530,9 @@ const char* test_wuffs_gif_decode_missing_two_src_bytes() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, "test/data/pjw-thumbnail.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/pjw-thumbnail.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
// Trim the final two bytes: the 0x00 end-of-block and the 0x3B trailer.
|
||||
@@ -1550,14 +1550,14 @@ const char* test_wuffs_gif_decode_multiple_graphic_controls() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-multiple-graphic-controls.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1583,14 +1583,14 @@ const char* test_wuffs_gif_decode_multiple_loop_counts() {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-multiple-loop-counts.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1651,10 +1651,10 @@ const char* test_wuffs_gif_decode_pixel_data_none() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-pixel-data-none.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
@@ -1668,10 +1668,10 @@ const char* test_wuffs_gif_decode_pixel_data_not_enough() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-pixel-data-not-enough.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
@@ -1685,10 +1685,10 @@ const char* test_wuffs_gif_decode_pixel_data_too_much_sans_quirk() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-pixel-data-too-much.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
@@ -1702,10 +1702,10 @@ const char* test_wuffs_gif_decode_pixel_data_too_much_with_quirk() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-pixel-data-too-much.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
return do_test_wuffs_gif_decode_expecting(
|
||||
@@ -1719,13 +1719,14 @@ const char* test_wuffs_gif_frame_dirty_rect() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, "test/data/hippopotamus.interlaced.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/hippopotamus.interlaced.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1785,13 +1786,13 @@ const char* do_test_wuffs_gif_num_decoded(bool frame_config) {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, "test/data/animated-red-blue.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/animated-red-blue.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -1866,13 +1867,13 @@ const char* do_test_wuffs_gif_io_position(bool chunked) {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status = read_file(&src, "test/data/animated-red-blue.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, "test/data/animated-red-blue.gif");
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -2031,14 +2032,14 @@ const char* test_wuffs_gif_small_frame_interlaced() {
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status =
|
||||
const char* status_msg =
|
||||
read_file(&src, "test/data/artificial/gif-small-frame-interlaced.gif");
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
wuffs_gif__decoder dec;
|
||||
status = wuffs_gif__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gif__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -2101,34 +2102,34 @@ const char* do_test_mimic_gif_decode(const char* filename) {
|
||||
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||
.data = global_src_slice,
|
||||
});
|
||||
const char* status = read_file(&src, filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
src.meta.ri = 0;
|
||||
wuffs_base__io_buffer got = ((wuffs_base__io_buffer){
|
||||
.data = global_got_slice,
|
||||
});
|
||||
status = wuffs_gif_decode(
|
||||
status_msg = wuffs_gif_decode(
|
||||
&got, 0, WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY, &src);
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
src.meta.ri = 0;
|
||||
wuffs_base__io_buffer want = ((wuffs_base__io_buffer){
|
||||
.data = global_want_slice,
|
||||
});
|
||||
status = mimic_gif_decode(
|
||||
status_msg = mimic_gif_decode(
|
||||
&want, 0, WUFFS_BASE__PIXEL_FORMAT__INDEXED__BGRA_BINARY, &src);
|
||||
if (status) {
|
||||
return status;
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
status = check_io_buffers_equal("", &got, &want);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = check_io_buffers_equal("", &got, &want);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
// TODO: check the palette RGB values, not just the palette indexes
|
||||
@@ -2222,9 +2223,9 @@ const char* do_bench_gif_decode(
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
bench_start();
|
||||
@@ -2234,9 +2235,9 @@ const char* do_bench_gif_decode(
|
||||
for (i = 0; i < iters; i++) {
|
||||
got.meta.wi = 0;
|
||||
src.meta.ri = 0;
|
||||
status = decode_func(&got, wuffs_initialize_flags, pixfmt, &src);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = decode_func(&got, wuffs_initialize_flags, pixfmt, &src);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
n_bytes += got.meta.wi;
|
||||
}
|
||||
|
||||
+4
-4
@@ -124,9 +124,9 @@ const char* do_test_wuffs_gzip_checksum(bool ignore_checksum,
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, gzip_midsummer_gt.src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, gzip_midsummer_gt.src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
|
||||
// Flip a bit in the gzip checksum, which is in the last 8 bytes of the file.
|
||||
@@ -140,7 +140,7 @@ const char* do_test_wuffs_gzip_checksum(bool ignore_checksum,
|
||||
int end_limit; // The rlimit, relative to the end of the data.
|
||||
for (end_limit = 0; end_limit < 10; end_limit++) {
|
||||
wuffs_gzip__decoder dec;
|
||||
status = wuffs_gzip__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_gzip__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
|
||||
+11
-11
@@ -82,9 +82,9 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
if (src.meta.wi != src_size) {
|
||||
RETURN_FAIL("src size: got %d, want %d", (int)(src.meta.wi),
|
||||
@@ -98,9 +98,9 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
}
|
||||
src.meta.ri++;
|
||||
|
||||
status = read_file(&want, want_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
status_msg = read_file(&want, want_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
if (want.meta.wi != want_size) {
|
||||
RETURN_FAIL("want size: got %d, want %d", (int)(want.meta.wi),
|
||||
@@ -108,7 +108,7 @@ const char* do_test_wuffs_lzw_decode(const char* src_filename,
|
||||
}
|
||||
|
||||
wuffs_lzw__decoder dec;
|
||||
status = wuffs_lzw__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_lzw__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
@@ -388,9 +388,9 @@ const char* do_bench_wuffs_lzw_decode(const char* filename,
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
if (src.meta.wi <= 0) {
|
||||
RETURN_FAIL("src size: got %d, want > 0", (int)(src.meta.wi));
|
||||
@@ -409,7 +409,7 @@ const char* do_bench_wuffs_lzw_decode(const char* filename,
|
||||
got.meta.wi = 0;
|
||||
src.meta.ri = 1; // Skip the literal width.
|
||||
wuffs_lzw__decoder dec;
|
||||
status = wuffs_lzw__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_lzw__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
|
||||
+4
-4
@@ -135,9 +135,9 @@ const char* do_test_wuffs_zlib_checksum(bool ignore_checksum,
|
||||
.data = global_src_slice,
|
||||
});
|
||||
|
||||
const char* status = read_file(&src, zlib_midsummer_gt.src_filename);
|
||||
if (status) {
|
||||
return status;
|
||||
const char* status_msg = read_file(&src, zlib_midsummer_gt.src_filename);
|
||||
if (status_msg) {
|
||||
return status_msg;
|
||||
}
|
||||
// Flip a bit in the zlib checksum, which is in the last 4 bytes of the file.
|
||||
if (src.meta.wi < 4) {
|
||||
@@ -150,7 +150,7 @@ const char* do_test_wuffs_zlib_checksum(bool ignore_checksum,
|
||||
int end_limit; // The rlimit, relative to the end of the data.
|
||||
for (end_limit = 0; end_limit < 10; end_limit++) {
|
||||
wuffs_zlib__decoder dec;
|
||||
status = wuffs_zlib__decoder__initialize(
|
||||
wuffs_base__status status = wuffs_zlib__decoder__initialize(
|
||||
&dec, sizeof dec, WUFFS_VERSION,
|
||||
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||
if (status) {
|
||||
|
||||
Reference in new issue
Block a user