]> git.codecow.com Git - Monocypher.git/commit
Corrected failing test on 32-bit systems
authorLoup Vaillant <loup@loup-vaillant.fr>
Tue, 19 Jun 2018 22:26:41 +0000 (00:26 +0200)
committerLoup Vaillant <loup@loup-vaillant.fr>
Tue, 19 Jun 2018 22:26:41 +0000 (00:26 +0200)
commit278c97d778ad68fdbd42a425747ab3b612296ecc
treed13c09e5b5d34275851d00093ca6e69825ef14e8
parenteacb66c62ddfc750005213c24abb2d451b129c8f
Corrected failing test on 32-bit systems

When size_t is not uint64_t, converting "negative" size_t integers to
uint64_t yields nonsensical results.  That is, the following isn't
portable:

    size_t   x = 42;
    uint64_t y = -i;

Because y might be missing the high order bits if size_t is smaller than
uint64_t. Instead, we want to convert to a large sized integer *before*
we negate it:

    size_t   x = 42;
    uint64_t y = -(uint64_t)i;
tests/test.c