From a1ad0db8a6d829eddf1478cee44ae976bbcd325f Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Apr 2026 14:48:54 +0100 Subject: Fix integer conversions in code, tests and some tools --- test/010_math_permtoindex/permtoindex_tests.c | 2 +- test/012_math_permsign/permsign_tests.c | 2 +- test/013_math_digitstosumzero/digitstosumzero_tests.c | 4 ++-- test/014_math_sumzerotodigits/sumzerotodigits.c | 4 ++-- test/090_allowedmoves/allowedmoves_tests.c | 4 ++-- test/114_cocsep_ttrep/cocsep_ttrep_tests.c | 4 ++-- test/122_gendata_h48short/gendata_h48short_tests.c | 2 +- test/131_coorddata_dr/coorddata_dr.c | 6 +++--- test/132_coorddata_dreo/coorddata_dreo.c | 6 +++--- test/133_coordata_drfinnoe/coorddata_drfinnoe.c | 6 +++--- test/140_appendsolution/appendsolution_tests.c | 8 ++++---- 11 files changed, 24 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/010_math_permtoindex/permtoindex_tests.c b/test/010_math_permtoindex/permtoindex_tests.c index 383150d..2a7ecf3 100644 --- a/test/010_math_permtoindex/permtoindex_tests.c +++ b/test/010_math_permtoindex/permtoindex_tests.c @@ -11,7 +11,7 @@ void run(void) { n = atoll(str); for (i = 0; i < n; i++) { fgets(str, STRLENMAX, stdin); - a[i] = atoi(str); + a[i] = (uint8_t)atoi(str); } p = permtoindex(n, a); diff --git a/test/012_math_permsign/permsign_tests.c b/test/012_math_permsign/permsign_tests.c index 8c652b5..f5a52d0 100644 --- a/test/012_math_permsign/permsign_tests.c +++ b/test/012_math_permsign/permsign_tests.c @@ -13,7 +13,7 @@ void run(void) { for (i = 0; i < n; i++) { fgets(str, STRLENMAX, stdin); - a[i] = atoi(str); + a[i] = (uint8_t)atoi(str); } p = permsign(n, a); diff --git a/test/013_math_digitstosumzero/digitstosumzero_tests.c b/test/013_math_digitstosumzero/digitstosumzero_tests.c index ced466a..8df1848 100644 --- a/test/013_math_digitstosumzero/digitstosumzero_tests.c +++ b/test/013_math_digitstosumzero/digitstosumzero_tests.c @@ -11,10 +11,10 @@ void run(void) { fgets(str, STRLENMAX, stdin); n = atoi(str); fgets(str, STRLENMAX, stdin); - b = atoi(str); + b = (uint8_t)atoi(str); for (i = 0; i < n; i++) { fgets(str, STRLENMAX, stdin); - a[i] = atoi(str); + a[i] = (uint8_t)atoi(str); } p = digitstosumzero(n, a, b); diff --git a/test/014_math_sumzerotodigits/sumzerotodigits.c b/test/014_math_sumzerotodigits/sumzerotodigits.c index 401d157..256ca5a 100644 --- a/test/014_math_sumzerotodigits/sumzerotodigits.c +++ b/test/014_math_sumzerotodigits/sumzerotodigits.c @@ -8,9 +8,9 @@ void run(void) { uint64_t d; fgets(str, STRLENMAX, stdin); - n = atoi(str); + n = (uint8_t)atoi(str); fgets(str, STRLENMAX, stdin); - b = atoi(str); + b = (uint8_t)atoi(str); fgets(str, STRLENMAX, stdin); d = atoll(str); diff --git a/test/090_allowedmoves/allowedmoves_tests.c b/test/090_allowedmoves/allowedmoves_tests.c index 6bc0e33..cff8303 100644 --- a/test/090_allowedmoves/allowedmoves_tests.c +++ b/test/090_allowedmoves/allowedmoves_tests.c @@ -13,8 +13,8 @@ static char *moves[] = { void run(void) { char movestr[STRLENMAX]; - uint8_t m[100]; - int n, i, j; + uint8_t j, m[100]; + int n, i; fgets(movestr, STRLENMAX, stdin); n = atoi(movestr); diff --git a/test/114_cocsep_ttrep/cocsep_ttrep_tests.c b/test/114_cocsep_ttrep/cocsep_ttrep_tests.c index c5c1bb5..936dac3 100644 --- a/test/114_cocsep_ttrep/cocsep_ttrep_tests.c +++ b/test/114_cocsep_ttrep/cocsep_ttrep_tests.c @@ -6,9 +6,9 @@ uint64_t coord_cocsep(cube_t); size_t gendata_cocsep(unsigned char *, uint64_t *, cube_t *); void run(void) { - uint8_t t; + uint8_t t, tt; unsigned char buf[2000000]; - uint32_t *cocsepdata, tt; + uint32_t *cocsepdata; uint64_t i, selfsim[COCSEP_CLASSES]; uint64_t j, k, l; cube_t rep[COCSEP_CLASSES], c, d; diff --git a/test/122_gendata_h48short/gendata_h48short_tests.c b/test/122_gendata_h48short/gendata_h48short_tests.c index efd378b..0996f8c 100644 --- a/test/122_gendata_h48short/gendata_h48short_tests.c +++ b/test/122_gendata_h48short/gendata_h48short_tests.c @@ -34,7 +34,7 @@ void run(void) { capacity = readl(); randomizer = readl(); - arg.maxdepth = readl(); + arg.maxdepth = (uint8_t)readl(); arg.crep = crep; arg.selfsim = selfsim; arg.map = ↦ diff --git a/test/131_coorddata_dr/coorddata_dr.c b/test/131_coorddata_dr/coorddata_dr.c index d8ac94a..d262fe3 100644 --- a/test/131_coorddata_dr/coorddata_dr.c +++ b/test/131_coorddata_dr/coorddata_dr.c @@ -11,7 +11,7 @@ size_t coordinate_dr_gendata(unsigned char *); void run(void) { bool found; - uint64_t t; + uint8_t t; char str[STRLENMAX]; unsigned char *data; size_t size; @@ -33,8 +33,8 @@ void run(void) { goto cleanup; } - for (t = 0, found = false; t < 48; t++) { - if (!((UINT64_C(1) << t) & TGROUP)) + for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) { + if (!((UINT64_C(1) << (uint8_t)t) & TGROUP)) continue; coord2 = coordinate_dr_coord(transform(cube, t), data); diff --git a/test/132_coorddata_dreo/coorddata_dreo.c b/test/132_coorddata_dreo/coorddata_dreo.c index 2b99b7f..50294ff 100644 --- a/test/132_coorddata_dreo/coorddata_dreo.c +++ b/test/132_coorddata_dreo/coorddata_dreo.c @@ -11,7 +11,7 @@ size_t coordinate_dreo_gendata(unsigned char *); void run(void) { bool found; - uint64_t t; + uint8_t t; char str[STRLENMAX]; unsigned char *data; size_t size; @@ -33,8 +33,8 @@ void run(void) { goto cleanup; } - for (t = 0, found = false; t < 48; t++) { - if (!((UINT64_C(1) << t) & TGROUP)) + for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) { + if (!((UINT64_C(1) << (uint64_t)t) & TGROUP)) continue; coord2 = coordinate_dreo_coord(transform(cube, t), data); diff --git a/test/133_coordata_drfinnoe/coorddata_drfinnoe.c b/test/133_coordata_drfinnoe/coorddata_drfinnoe.c index 11ae9f7..7d19361 100644 --- a/test/133_coordata_drfinnoe/coorddata_drfinnoe.c +++ b/test/133_coordata_drfinnoe/coorddata_drfinnoe.c @@ -10,7 +10,7 @@ size_t coordinate_drfinnoe_gendata(unsigned char *); void run(void) { bool found; - uint64_t t; + uint8_t t; char str[STRLENMAX]; unsigned char *data; size_t size; @@ -32,8 +32,8 @@ void run(void) { goto cleanup; } - for (t = 0, found = false; t < 48; t++) { - if (!((UINT64_C(1) << t) & TGROUP)) + for (t = 0, found = false, coord2 = UINT64_MAX; t < 48; t++) { + if (!((UINT64_C(1) << (uint64_t)t) & TGROUP)) continue; coord2 = coordinate_drfinnoe_coord(transform(cube, t), data); diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c index 9f9e9f4..3f4fb15 100644 --- a/test/140_appendsolution/appendsolution_tests.c +++ b/test/140_appendsolution/appendsolution_tests.c @@ -39,7 +39,7 @@ void run(void) { .unniss = false, .maxmoves = 20, .maxsolutions = 100, - .optimal = -1, + .optimal = 0, }; fgets(str, STRLENMAX, stdin); @@ -48,8 +48,8 @@ void run(void) { printf("Test error reading moves\n"); return; } - moves.nmoves = nm; - moves.npremoves = np; + moves.nmoves = (uint8_t)nm; + moves.npremoves = (uint8_t)np; fgets(str, STRLENMAX, stdin); settings.unniss = (bool)atoi(str); @@ -64,7 +64,7 @@ void run(void) { } } fgets(str, STRLENMAX, stdin); - settings.orientation = atoi(str); + settings.orientation = (uint8_t)atoi(str); appendsolution(&moves, nnt, tmask, &settings, &list); -- cgit v1.3