X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fcrcsync%2Ftest%2Frun-crash.c;h=3bf49f64410341cd4eee62a26cb068cd10e59f40;hb=d26475dcfc3182030c664e6cdaff5aafbcaa159d;hp=9987f8dc1d91d34e1d7af3199f532a310bec5651;hpb=9e837118e0613742d6a6138fa905899e837b78d5;p=ccan diff --git a/ccan/crcsync/test/run-crash.c b/ccan/crcsync/test/run-crash.c index 9987f8dc..3bf49f64 100644 --- a/ccan/crcsync/test/run-crash.c +++ b/ccan/crcsync/test/run-crash.c @@ -1,8 +1,8 @@ /* This used to crash us on 64-bit; submitted by Alex Wulms */ -#include "crcsync/crcsync.h" -#include "crcsync/crcsync.c" -#include "tap/tap.h" +#include +#include +#include #include #include @@ -11,14 +11,14 @@ typedef struct { int block_count; - unsigned int *crcs; + uint64_t *crcs; } crc_info_t; -static void crcblocks(crc_info_t *crc_info, char *data, int datalen, int blocksize) +static void crcblocks(crc_info_t *crc_info, const char *data, int datalen, int blocksize) { crc_info->block_count = (datalen+blocksize-1)/blocksize; - crc_info->crcs = malloc(sizeof(unsigned int)*(crc_info->block_count + 1)); - crc_of_blocks(data, datalen, blocksize, 30, crc_info->crcs); + crc_info->crcs = malloc(sizeof(uint64_t)*(crc_info->block_count + 1)); + crc_of_blocks(data, datalen, blocksize, 60, crc_info->crcs); } #define BLOCKSIZE 5 @@ -26,11 +26,11 @@ static void crcblocks(crc_info_t *crc_info, char *data, int datalen, int blocksi int main(int argc, char *argv[]) { /* Divided into BLOCKSIZE blocks */ - char *data1 = + const char *data1 = "abcde" "fghij" "klmno" "pqrst" "uvwxy" "z ABC" "DEFGH" "IJKLM" "NOPQR" "STUVW" "XYZ 0" "12345" "6789"; /* Divided into blocks that match. */ - char *data2 = + const char *data2 = /* NO MATCH */ "acde" /* MATCH */ @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) plan_tests(ARRAY_SIZE(expected) + 2); crcblocks(&crc_info1, data1, strlen(data1), BLOCKSIZE); - crcctx = crc_context_new(BLOCKSIZE, 30, crc_info1.crcs, crc_info1.block_count, + crcctx = crc_context_new(BLOCKSIZE, 60, crc_info1.crcs, crc_info1.block_count, tailsize); while ( offset < len2) { @@ -92,6 +92,7 @@ int main(int argc, char *argv[]) } } ok1(expected_i == ARRAY_SIZE(expected)); - + crc_context_free(crcctx); + free(crc_info1.crcs); return 0; }