For example, VC++ shows the following warnings:
1> xxhsum.c
1>..\..\xxhsum.c(620): warning C4146: unary minus operator applied to unsigned type, result still unsigned
1>..\..\xxhsum.c(621): warning C4146: unary minus operator applied to unsigned type, result still unsigned
The folliwing thread is good pointer for unary minus operators behaviour:
C: unary minus operator behavior with unsigned operands
http://stackoverflow.com/questions/8026694/
> 6.2.5c9 says: A computation involving unsigned operands can never overflow,
> because a result that cannot be represented by the resulting unsigned
> integer type is reduced modulo the number that is one greater than the
> largest value that can be represented by the resulting type.
- gcc -Wswitch-enum warns them. But this is completely false-positive.
xxhsum.c:956:13: warning: enumeration value ‘GetLine_ok’ not handled in switch [-Wswitch-enum]
switch (getLineResult)
^
- Basic logic is same as GNU coreutil's lib/getline.c and lib/getdelim.c
- Since this implementation fully depends on fgetc(), there is possible performance problem.
- Add the following command line switches
- "-c"/"--check" : read XXH32/64 sums from FILEs and check them.
- "--quiet" : Don't print OK.
- "--status" : Don't output anything to stdout/stderr.
- "--strict" : Treat any invalid line as error.
- "--warn" : Show warning message for invalid line.
- If all checksum procedure is succeeded, exit code is 0.
- Otherwise exit code is 1.
All avobe functions basic logics are inherited from md5sum.
- Add hash generation function BMK_hashStream() which generates hash value from file stream.
- First argument void* is not violate strict aliasing, but dedicated union may be good for readability.