From 3e1cdd1a83b64ad1af923c2a36352157797eb177 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 2 Jun 2018 13:16:50 +1000 Subject: [PATCH] Rename some error messages --- gen/c/std/gzip.c | 20 ++++++++++---------- gen/c/std/zlib.c | 25 ++++++++++++------------- gen/h/std/gzip.h | 8 ++++---- gen/h/std/zlib.h | 9 ++++----- std/gzip/decode_gzip.wuffs | 12 ++++++------ std/zlib/decode_zlib.wuffs | 16 ++++++++-------- test/c/std/gzip.c | 2 +- test/c/std/zlib.c | 2 +- 8 files changed, 46 insertions(+), 48 deletions(-) diff --git a/gen/c/std/gzip.c b/gen/c/std/gzip.c index f426a2e3..824582ee 100644 --- a/gen/c/std/gzip.c +++ b/gen/c/std/gzip.c @@ -1467,10 +1467,10 @@ typedef int32_t wuffs_gzip__status; #define WUFFS_GZIP__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D #define WUFFS_GZIP__SUSPENSION_END_OF_DATA 14 // 0x0000000E -#define WUFFS_GZIP__ERROR_BAD_HEADER -1080566784 // 0xBF97DC00 -#define WUFFS_GZIP__ERROR_CHECKSUM_MISMATCH -1080566783 // 0xBF97DC01 -#define WUFFS_GZIP__ERROR_INVALID_COMPRESSION_METHOD -1080566782 // 0xBF97DC02 -#define WUFFS_GZIP__ERROR_INVALID_ENCODING_FLAGS -1080566781 // 0xBF97DC03 +#define WUFFS_GZIP__ERROR_BAD_CHECKSUM -1080566784 // 0xBF97DC00 +#define WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD -1080566783 // 0xBF97DC01 +#define WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS -1080566782 // 0xBF97DC02 +#define WUFFS_GZIP__ERROR_BAD_HEADER -1080566781 // 0xBF97DC03 bool wuffs_gzip__status__is_error(wuffs_gzip__status s); @@ -2123,10 +2123,10 @@ bool wuffs_gzip__status__is_error(wuffs_gzip__status s) { } const char* wuffs_gzip__status__strings[4] = { + "gzip: bad checksum", + "gzip: bad compression method", + "gzip: bad encoding flags", "gzip: bad header", - "gzip: checksum mismatch", - "gzip: invalid compression method", - "gzip: invalid encoding flags", }; const char* wuffs_gzip__status__string(wuffs_gzip__status s) { @@ -2306,7 +2306,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self, } uint8_t t_2 = *ioptr_src++; if (t_2 != 8) { - status = WUFFS_GZIP__ERROR_INVALID_COMPRESSION_METHOD; + status = WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD; goto exit; } { @@ -2410,7 +2410,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self, ioptr_src += self->private_impl.c_decode[0].scratch; } if ((v_flags & 224) != 0) { - status = WUFFS_GZIP__ERROR_INVALID_ENCODING_FLAGS; + status = WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS; goto exit; } v_checksum_got = 0; @@ -2516,7 +2516,7 @@ wuffs_gzip__status wuffs_gzip__decoder__decode(wuffs_gzip__decoder* self, if (!self->private_impl.f_ignore_checksum && ((v_checksum_got != v_checksum_want) || (v_decoded_length_got != v_decoded_length_want))) { - status = WUFFS_GZIP__ERROR_CHECKSUM_MISMATCH; + status = WUFFS_GZIP__ERROR_BAD_CHECKSUM; goto exit; } diff --git a/gen/c/std/zlib.c b/gen/c/std/zlib.c index c8f4ddc5..f383e90e 100644 --- a/gen/c/std/zlib.c +++ b/gen/c/std/zlib.c @@ -1468,11 +1468,10 @@ typedef int32_t wuffs_zlib__status; #define WUFFS_ZLIB__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D #define WUFFS_ZLIB__SUSPENSION_END_OF_DATA 14 // 0x0000000E -#define WUFFS_ZLIB__ERROR_CHECKSUM_MISMATCH -33692672 // 0xFDFDE400 -#define WUFFS_ZLIB__ERROR_INVALID_COMPRESSION_METHOD -33692671 // 0xFDFDE401 -#define WUFFS_ZLIB__ERROR_INVALID_COMPRESSION_WINDOW_SIZE \ - -33692670 // 0xFDFDE402 -#define WUFFS_ZLIB__ERROR_INVALID_PARITY_CHECK -33692669 // 0xFDFDE403 +#define WUFFS_ZLIB__ERROR_BAD_CHECKSUM -33692672 // 0xFDFDE400 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD -33692671 // 0xFDFDE401 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE -33692670 // 0xFDFDE402 +#define WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK -33692669 // 0xFDFDE403 #define WUFFS_ZLIB__ERROR_TODO_UNSUPPORTED_PRESET_DICTIONARY \ -33692668 // 0xFDFDE404 @@ -2123,10 +2122,10 @@ bool wuffs_zlib__status__is_error(wuffs_zlib__status s) { } const char* wuffs_zlib__status__strings[5] = { - "zlib: checksum mismatch", - "zlib: invalid compression method", - "zlib: invalid compression window size", - "zlib: invalid parity check", + "zlib: bad checksum", + "zlib: bad compression method", + "zlib: bad compression window size", + "zlib: bad parity check", "zlib: TODO: unsupported preset dictionary", }; @@ -2303,11 +2302,11 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self, v_x = t_1; } if (((v_x >> 8) & 15) != 8) { - status = WUFFS_ZLIB__ERROR_INVALID_COMPRESSION_METHOD; + status = WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD; goto exit; } if ((v_x >> 12) > 7) { - status = WUFFS_ZLIB__ERROR_INVALID_COMPRESSION_WINDOW_SIZE; + status = WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE; goto exit; } if ((v_x & 32) != 0) { @@ -2315,7 +2314,7 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self, goto exit; } if ((v_x % 31) != 0) { - status = WUFFS_ZLIB__ERROR_INVALID_PARITY_CHECK; + status = WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK; goto exit; } v_checksum_got = 0; @@ -2383,7 +2382,7 @@ wuffs_zlib__status wuffs_zlib__decoder__decode(wuffs_zlib__decoder* self, } if (!self->private_impl.f_ignore_checksum && (v_checksum_got != v_checksum_want)) { - status = WUFFS_ZLIB__ERROR_CHECKSUM_MISMATCH; + status = WUFFS_ZLIB__ERROR_BAD_CHECKSUM; goto exit; } diff --git a/gen/h/std/gzip.h b/gen/h/std/gzip.h index a447eba3..df9d5333 100644 --- a/gen/h/std/gzip.h +++ b/gen/h/std/gzip.h @@ -1467,10 +1467,10 @@ typedef int32_t wuffs_gzip__status; #define WUFFS_GZIP__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D #define WUFFS_GZIP__SUSPENSION_END_OF_DATA 14 // 0x0000000E -#define WUFFS_GZIP__ERROR_BAD_HEADER -1080566784 // 0xBF97DC00 -#define WUFFS_GZIP__ERROR_CHECKSUM_MISMATCH -1080566783 // 0xBF97DC01 -#define WUFFS_GZIP__ERROR_INVALID_COMPRESSION_METHOD -1080566782 // 0xBF97DC02 -#define WUFFS_GZIP__ERROR_INVALID_ENCODING_FLAGS -1080566781 // 0xBF97DC03 +#define WUFFS_GZIP__ERROR_BAD_CHECKSUM -1080566784 // 0xBF97DC00 +#define WUFFS_GZIP__ERROR_BAD_COMPRESSION_METHOD -1080566783 // 0xBF97DC01 +#define WUFFS_GZIP__ERROR_BAD_ENCODING_FLAGS -1080566782 // 0xBF97DC02 +#define WUFFS_GZIP__ERROR_BAD_HEADER -1080566781 // 0xBF97DC03 bool wuffs_gzip__status__is_error(wuffs_gzip__status s); diff --git a/gen/h/std/zlib.h b/gen/h/std/zlib.h index 6f55d847..0f99d7c2 100644 --- a/gen/h/std/zlib.h +++ b/gen/h/std/zlib.h @@ -1468,11 +1468,10 @@ typedef int32_t wuffs_zlib__status; #define WUFFS_ZLIB__ERROR_INVALID_CALL_SEQUENCE -2147483635 // 0x8000000D #define WUFFS_ZLIB__SUSPENSION_END_OF_DATA 14 // 0x0000000E -#define WUFFS_ZLIB__ERROR_CHECKSUM_MISMATCH -33692672 // 0xFDFDE400 -#define WUFFS_ZLIB__ERROR_INVALID_COMPRESSION_METHOD -33692671 // 0xFDFDE401 -#define WUFFS_ZLIB__ERROR_INVALID_COMPRESSION_WINDOW_SIZE \ - -33692670 // 0xFDFDE402 -#define WUFFS_ZLIB__ERROR_INVALID_PARITY_CHECK -33692669 // 0xFDFDE403 +#define WUFFS_ZLIB__ERROR_BAD_CHECKSUM -33692672 // 0xFDFDE400 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_METHOD -33692671 // 0xFDFDE401 +#define WUFFS_ZLIB__ERROR_BAD_COMPRESSION_WINDOW_SIZE -33692670 // 0xFDFDE402 +#define WUFFS_ZLIB__ERROR_BAD_PARITY_CHECK -33692669 // 0xFDFDE403 #define WUFFS_ZLIB__ERROR_TODO_UNSUPPORTED_PRESET_DICTIONARY \ -33692668 // 0xFDFDE404 diff --git a/std/gzip/decode_gzip.wuffs b/std/gzip/decode_gzip.wuffs index 6c80e4da..91cc694f 100644 --- a/std/gzip/decode_gzip.wuffs +++ b/std/gzip/decode_gzip.wuffs @@ -17,10 +17,10 @@ packageid "gzip" use "std/crc32" use "std/deflate" +pub error "bad checksum" +pub error "bad compression method" +pub error "bad encoding flags" pub error "bad header" -pub error "checksum mismatch" -pub error "invalid compression method" -pub error "invalid encoding flags" pub struct decoder?( flate deflate.decoder, @@ -41,7 +41,7 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() { return error "bad header" } if in.src.read_u8?() != 0x08 { - return error "invalid compression method" + return error "bad compression method" } var flags base.u8 = in.src.read_u8?() // TODO: API for returning the header's MTIME field. @@ -85,7 +85,7 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() { // Reserved flags bits must be zero. if (flags & 0xE0) != 0 { - return error "invalid encoding flags" + return error "bad encoding flags" } // Decode and checksum the DEFLATE-encoded payload. @@ -107,6 +107,6 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() { var decoded_length_want base.u32 = in.src.read_u32le?() if (not this.ignore_checksum) and ((checksum_got != checksum_want) or (decoded_length_got != decoded_length_want)) { - return error "checksum mismatch" + return error "bad checksum" } } diff --git a/std/zlib/decode_zlib.wuffs b/std/zlib/decode_zlib.wuffs index de5eddf7..902aff08 100644 --- a/std/zlib/decode_zlib.wuffs +++ b/std/zlib/decode_zlib.wuffs @@ -17,10 +17,10 @@ packageid "zlib" use "std/adler32" use "std/deflate" -pub error "checksum mismatch" -pub error "invalid compression method" -pub error "invalid compression window size" -pub error "invalid parity check" +pub error "bad checksum" +pub error "bad compression method" +pub error "bad compression window size" +pub error "bad parity check" pub error "TODO: unsupported preset dictionary" @@ -37,16 +37,16 @@ pub func decoder.set_ignore_checksum!(ic base.bool)() { pub func decoder.decode?(dst base.io_writer, src base.io_reader)() { var x base.u16 = in.src.read_u16be?() if ((x >> 8) & 0x0F) != 0x08 { - return error "invalid compression method" + return error "bad compression method" } if (x >> 12) > 0x07 { - return error "invalid compression window size" + return error "bad compression window size" } if (x & 0x20) != 0 { return error "TODO: unsupported preset dictionary" } if (x % 31) != 0 { - return error "invalid parity check" + return error "bad parity check" } // Decode and checksum the DEFLATE-encoded payload. @@ -64,6 +64,6 @@ pub func decoder.decode?(dst base.io_writer, src base.io_reader)() { } var checksum_want base.u32 = in.src.read_u32be?() if (not this.ignore_checksum) and (checksum_got != checksum_want) { - return error "checksum mismatch" + return error "bad checksum" } } diff --git a/test/c/std/gzip.c b/test/c/std/gzip.c index a2d5abbe..1fd78dfc 100644 --- a/test/c/std/gzip.c +++ b/test/c/std/gzip.c @@ -139,7 +139,7 @@ bool do_test_wuffs_gzip_checksum(bool ignore_checksum, uint32_t bad_checksum) { want = WUFFS_GZIP__SUSPENSION_SHORT_READ; } else { want = (bad_checksum && !ignore_checksum) - ? WUFFS_GZIP__ERROR_CHECKSUM_MISMATCH + ? WUFFS_GZIP__ERROR_BAD_CHECKSUM : WUFFS_GZIP__STATUS_OK; } diff --git a/test/c/std/zlib.c b/test/c/std/zlib.c index 3901c39e..f487ca72 100644 --- a/test/c/std/zlib.c +++ b/test/c/std/zlib.c @@ -153,7 +153,7 @@ bool do_test_wuffs_zlib_checksum(bool ignore_checksum, bool bad_checksum) { want = WUFFS_ZLIB__SUSPENSION_SHORT_READ; } else { want = (bad_checksum && !ignore_checksum) - ? WUFFS_ZLIB__ERROR_CHECKSUM_MISMATCH + ? WUFFS_ZLIB__ERROR_BAD_CHECKSUM : WUFFS_ZLIB__STATUS_OK; }