X-Git-Url: https://git.distorted.org.uk/~mdw/catacomb/blobdiff_plain/4328f7469ba7f9539368a21107005009aa9d3a43..6a024d24d97cb5d42c0091571735475b849f59f4:/symm/hash.h diff --git a/symm/hash.h b/symm/hash.h index dc0bbaa1..eb3cd75e 100644 --- a/symm/hash.h +++ b/symm/hash.h @@ -68,10 +68,10 @@ \ { \ uint32 _l = U32(_bsz); \ - uint32 _h = ((_bsz & ~MASK32) >> 16) >> 16; \ + uint32 _h = ((_bsz & ~(size_t)MASK32) >> 16) >> 16; \ _bctx->nh += _h; \ _bctx->nl += _l; \ - if (_bctx->nl < _l || _bctx->nl & ~MASK32) \ + if (_bctx->nl < _l || _bctx->nl & ~(uint32)MASK32) \ _bctx->nh++; \ } \ \ @@ -169,7 +169,7 @@ #define HASH_VERIFYX(PRE, pre, name) \ \ -static int vrf_##pre(dstr *v) \ +static int vrf_##pre(dstr *v, const test_type *msgty) \ { \ pre##_ctx ctx; \ int ok = 1; \ @@ -201,8 +201,9 @@ static int vrf_##pre(dstr *v) \ } \ pre##_done(&ctx, d.buf); \ if (memcmp(d.buf, v[1].buf, PRE##_HASHSZ) != 0) { \ - printf("\nfail:\n\tstep = %i\n\tinput = `%s'\n\texpected = ", \ - *ip, v[0].buf); \ + printf("\nfail:\n\tstep = %i\n\tinput = ", *ip); \ + msgty->dump(&v[0], stdout); \ + printf("\n\texpected = "); \ type_hex.dump(&v[1], stdout); \ fputs("\n\tcomputed = ", stdout); \ type_hex.dump(&d, stdout); \ @@ -215,6 +216,11 @@ static int vrf_##pre(dstr *v) \ return (ok); \ } \ \ +static int vrf_##pre##_hex(dstr *v) \ + { return vrf_##pre(v, &type_hex); } \ +static int vrf_##pre##_lit(dstr *v) \ + { return vrf_##pre(v, &type_string); } \ + \ static int vrf_##pre##_rep(dstr *v) \ { \ pre##_ctx ctx; \ @@ -255,7 +261,8 @@ static int vrf_##pre##_rep(dstr *v) \ #define HASH_TESTDEFS(PRE, pre) HASH_TESTDEFSX(PRE, pre, #pre) #define HASH_TESTDEFSX(PRE, pre, name) \ - { name, vrf_##pre, { &type_string, &type_hex, 0 } }, \ + { name, vrf_##pre##_lit, { &type_string, &type_hex, 0 } }, \ + { name "-hex", vrf_##pre##_hex, { &type_hex, &type_hex, 0 } }, \ { name "-rep", vrf_##pre##_rep, \ { &type_string, &type_int, &type_hex, 0 } },