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 --- build.bat | 6 +++--- src/arch/avx2.h | 2 +- src/core/moves.h | 8 ++++---- src/core/transform.h | 5 +++-- src/nissy.c | 2 +- src/solvers/coord/common.h | 12 +++++++----- src/solvers/coord/gendata.h | 19 +++++++++++-------- src/solvers/coord/multisolve.h | 12 ++++++------ src/solvers/coord/solve.h | 12 ++++++------ src/solvers/h48/gendata_cocsep.h | 5 ++--- src/solvers/h48/gendata_eoesep.h | 8 +++++--- src/solvers/h48/gendata_h48.h | 4 ++-- src/solvers/h48/solve.h | 8 ++++---- src/solvers/h48/utils.h | 2 +- src/solvers/solutions.h | 2 +- src/solvers/tables.h | 2 +- src/utils/math.h | 6 +++--- 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 ++++---- tools/solvetest.h | 2 +- 29 files changed, 86 insertions(+), 79 deletions(-) diff --git a/build.bat b/build.bat index d5a3bca..3459f6e 100644 --- a/build.bat +++ b/build.bat @@ -49,14 +49,14 @@ exit /b 1 SET CXX=cl SET DFLAGS=/Zi /DDEBUG - SET WARNINGS=/W2 /wd4505 /wd4996 + SET WARNINGS=/W4 /wd4100 /wd4324 /wd4505 /wd4996 SET VARIABLES=/DTHREADS=%THREADS% /D%ARCH% SET OFLAGS=/O2 if %DEBUG%==1 (SET ODFLAGS=%DFLAGS%) else (SET ODFLAGS=%OFLAGS%) if "%ARCH%"=="AVX2" (SET ARCHOPTS=/arch:AVX2) else (SET ARCHOPTS=) - SET CFLAGS=/std:c11 /experimental:c11atomics %ARCHOPTS% %WARNINGS% %VARIABLES% + SET CFLAGS=/std:c11 /experimental:c11atomics /nologo %ARCHOPTS% %WARNINGS% %VARIABLES% SET LFLAGS=/F 16777216 SET CC_NISSY=%CC% %CFLAGS% %ODFLAGS% /c src\nissy.c @@ -64,7 +64,7 @@ exit /b 1 SET CC_PYTHON=%CC% %CFLAGS% %LFLAGS% /I"%PYINCLUDE%" /LD /Fe:python\nissy.pyd python\nissy_module.c nissy.obj /link /LIBPATH:"%PYLIBS%" python3.lib SET CC_TEST=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtest.exe nissy.obj SET CC_TOOL=%CC% %CFLAGS% %ODFLAGS% %LFLAGS% /Fe:runtool.exe nissy.obj - SET CC_CXX=%CXX% /EHsc %ARCHOPTS% %ODFLAGS% %LFLAGS% /std:c++20 /Fe:runcpp.exe nissy_c.obj cpp\nissy.cpp + SET CC_CXX=%CXX% /EHsc /nologo %ARCHOPTS% %ODFLAGS% %LFLAGS% /std:c++20 /Fe:runcpp.exe nissy_c.obj cpp\nissy.cpp goto :compiler_done :set_clang diff --git a/src/arch/avx2.h b/src/arch/avx2.h index 21a6f3b..801419e 100644 --- a/src/arch/avx2.h +++ b/src/arch/avx2.h @@ -37,7 +37,7 @@ popcount_u32(uint32_t x) STATIC_INLINE int popcount_u64(uint64_t x) { - return _mm_popcnt_u64(x); + return (int)_mm_popcnt_u64(x); } STATIC void diff --git a/src/core/moves.h b/src/core/moves.h index c162c1d..9f1f7cc 100644 --- a/src/core/moves.h +++ b/src/core/moves.h @@ -623,10 +623,10 @@ move_variations_lastqt( size_t u; moves_struct_t ss; - in1 = s->nnormal-1; - in2 = s->nnormal-2; - ii1 = s->ninverse-1; - ii2 = s->ninverse-2; + in1 = (uint8_t)(s->nnormal-1); + in2 = (uint8_t)(s->nnormal-2); + ii1 = (uint8_t)(s->ninverse-1); + ii2 = (uint8_t)(s->ninverse-2); n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR; n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR; diff --git a/src/core/transform.h b/src/core/transform.h index 206449b..af4634e 100644 --- a/src/core/transform.h +++ b/src/core/transform.h @@ -407,12 +407,13 @@ inverse_trans(uint8_t t) STATIC uint64_t symmetry_mask(cube_t cube) { - uint64_t t, ret; + uint64_t ret; + uint8_t t; cube_t transformed; for (t = 0, ret = 0; t < NTRANS; t++) { transformed = transform(cube, t); - ret |= ((uint64_t)equal(cube, transformed)) << t; + ret |= ((uint64_t)equal(cube, transformed)) << (uint64_t)t; } return ret; diff --git a/src/nissy.c b/src/nissy.c index b9f2565..0811861 100644 --- a/src/nissy.c +++ b/src/nissy.c @@ -197,7 +197,7 @@ nissy_getcube( getcube_options[i].fix(&ep, &eo, &cp, &co, &orient); oc.cube = getcube(ep, eo, cp, co); - oc.orientation = orient; + oc.orientation = (uint8_t)orient; if (!isconsistent(oc)) { LOG("[getcube] Error: could not get cube with ep=%lld, " diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index 593641f..3a62e85 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h @@ -77,7 +77,8 @@ coord_gendata_generic( unsigned char *data ) { - uint64_t i, j, n, t, nasty; + uint64_t i, j, n, nasty; + uint8_t t; unsigned char *datanoinfo; uint32_t *classttrep, *rep; size_t coord_datasize; @@ -122,16 +123,17 @@ coord_gendata_generic( } for (t = 0; t < NTRANS; t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; j = coord->sym.coord(transform(c, t)); - classttrep[j] = + classttrep[j] = (uint32_t)( (n << COORD_CLASS_SHIFT) | (nasty << COORD_ISNASTY_SHIFT) | - (inverse_trans(t) << COORD_TTREP_SHIFT); + (inverse_trans(t) << COORD_TTREP_SHIFT) + ); } - rep[n++] = i; + rep[n++] = (uint32_t)i; } writetableinfo(&info, coord_datasize, data); diff --git a/src/solvers/coord/gendata.h b/src/solvers/coord/gendata.h index f803044..edf6ce6 100644 --- a/src/solvers/coord/gendata.h +++ b/src/solvers/coord/gendata.h @@ -146,7 +146,8 @@ genptable_coord( unsigned char *table ) { - uint64_t tablesize, i, d, tot, t, nm; + uint64_t tablesize, i, tot, t, nm; + uint8_t d; tableinfo_t info; tablesize = DIV_ROUND_UP(coord->max, 2); @@ -170,7 +171,7 @@ genptable_coord( tot = info.distribution[0] = genptable_coord_init_solved(coord, data, table); - nm = popcount_u32(coord->moves_mask_gendata); + nm = popcount_u64(coord->moves_mask_gendata); for (d = 1; tot < coord->max && d < 15; d++) { t = 0; if (switch_to_fromnew(tot, coord->max, nm)) { @@ -247,20 +248,21 @@ genptable_coord_fillneighbors( { bool isnasty; uint8_t m; - uint64_t ii, j, t, tot; + uint64_t ii, j, tot; + uint8_t t; cube_t c, moved; c = coord->cube(i, data); tot = 0; for (m = 0; m < NMOVES; m++) { - if (!((UINT32_C(1) << (uint32_t)m) & + if (!((UINT64_C(1) << (uint64_t)m) & coord->moves_mask_gendata)) continue; moved = move(c, m); ii = coord->coord(moved, data); isnasty = coord->isnasty(ii, data); for (t = 0; t < NTRANS && (t == 0 || isnasty); t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; j = coord->coord(transform(moved, t), data); @@ -285,14 +287,15 @@ genptable_coord_fillfromnew( { bool found; uint8_t m; - uint64_t tot, t, ii, j, nsim, sim[NTRANS]; + uint64_t tot, j, ii, nsim, sim[NTRANS]; + uint8_t t; cube_t c; tot = 0; c = coord->cube(i, data); for (t = 0, nsim = 0; t < NTRANS; t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; ii = coord->coord(transform(c, t), data); @@ -305,7 +308,7 @@ genptable_coord_fillfromnew( for (j = 0, found = false; j < nsim && !found; j++) { c = coord->cube(sim[j], data); for (m = 0; m < NMOVES; m++) { - if (!((UINT32_C(1) << (uint32_t)m) & + if (!((UINT64_C(1) << (uint64_t)m) & coord->moves_mask_gendata)) continue; ii = coord->coord(move(c, m), data); diff --git a/src/solvers/coord/multisolve.h b/src/solvers/coord/multisolve.h index 28f03bb..efd287d 100644 --- a/src/solvers/coord/multisolve.h +++ b/src/solvers/coord/multisolve.h @@ -72,8 +72,7 @@ STATIC int64_t solve_multicoord_dfs(dfsarg_solve_multicoord_t arg[NON_NULL]) { uint8_t m, l, i; - uint32_t mm; - uint64_t coord; + uint64_t mm, coord; int64_t n, ret; const coord_t *c; cube_t backup_cube, backup_inverse; @@ -108,7 +107,7 @@ solve_multicoord_dfs_notsolved: arg->solution_moves->nmoves++; for (m = 0; m < NMOVES; m++) { - if (!(mm & (UINT32_C(1) << (uint32_t)m))) + if (!(mm & (UINT64_C(1) << (uint64_t)m))) continue; arg->solution_moves->moves[l] = m; @@ -163,9 +162,10 @@ solve_multicoord_dispatch( return NISSY_ERROR_INVALID_SOLVER; } - return solve_multicoord(oc, mcoord, trans, minmoves, - maxmoves, maxsolutions, optimal, threads, data_size, data, - solutions_size, sols, poll_status, poll_status_data); + return solve_multicoord(oc, mcoord, trans, (uint8_t)minmoves, + (uint8_t)maxmoves, (uint8_t)maxsolutions, (uint8_t)optimal, + (uint8_t)threads, data_size, data, solutions_size, sols, + poll_status, poll_status_data); } STATIC int64_t diff --git a/src/solvers/coord/solve.h b/src/solvers/coord/solve.h index fcdb06e..6bb9af2 100644 --- a/src/solvers/coord/solve.h +++ b/src/solvers/coord/solve.h @@ -151,8 +151,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL]) { bool lastbackup; uint8_t m, l, nnbackup, nibackup, nmoves; - uint32_t mm; - uint64_t coord; + uint64_t mm, coord; int64_t n, ret; cube_t backup_cube, backup_inverse; @@ -190,7 +189,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL]) arg->lastisnormal = true; for (m = 0; m < NMOVES; m++) { - if (!(mm & (UINT32_C(1) << (uint32_t)m))) + if (!(mm & (UINT64_C(1) << (uint64_t)m))) continue; arg->solution_moves->moves[l] = m; @@ -221,7 +220,7 @@ solve_coord_dfs(dfsarg_solve_coord_t arg[NON_NULL]) arg->lastisnormal = false; for (m = 0; m < NMOVES; m++) { - if (!(mm & (UINT32_C(1) << (uint32_t)m))) + if (!(mm & (UINT64_C(1) << (uint64_t)m))) continue; arg->solution_moves->premoves[l] = m; @@ -280,8 +279,9 @@ solve_coord_dispatch( return NISSY_ERROR_INVALID_SOLVER; } - return solve_coord(oc, coord, trans, nissflag, minmoves, maxmoves, - maxsolutions, optimal, threads, data_size, data, + return solve_coord(oc, coord, trans, (uint8_t)nissflag, + (uint8_t)minmoves, (uint8_t)maxmoves, (uint8_t)maxsolutions, + (uint8_t)optimal, (uint8_t)threads, data_size, data, solutions_size, sols, poll_status, poll_status_data); } diff --git a/src/solvers/h48/gendata_cocsep.h b/src/solvers/h48/gendata_cocsep.h index 17568ea..f83207b 100644 --- a/src/solvers/h48/gendata_cocsep.h +++ b/src/solvers/h48/gendata_cocsep.h @@ -81,9 +81,8 @@ gendata_cocsep_return_size: STATIC uint32_t gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL]) { - uint8_t m; + uint8_t m, t; uint32_t cc, class, ttrep, depth, olddepth, tinv; - uint64_t t; uint64_t i, j; cube_t d; cocsep_dfs_arg_t nextarg; @@ -105,7 +104,7 @@ gendata_cocsep_dfs(cocsep_dfs_arg_t arg[NON_NULL]) d = transform_corners(arg->cube, t); j = coord_cocsep(d); if (i == j && arg->selfsim != NULL) - arg->selfsim[*arg->n] |= UINT64_C(1) << t; + arg->selfsim[*arg->n] |= UINT64_C(1) << (uint64_t)t; if (COCLASS(arg->buf32[j]) != UINT32_C(0xFFFF)) continue; gendata_cocsep_set_visited(arg->visited, j); diff --git a/src/solvers/h48/gendata_eoesep.h b/src/solvers/h48/gendata_eoesep.h index 271e877..81bbd43 100644 --- a/src/solvers/h48/gendata_eoesep.h +++ b/src/solvers/h48/gendata_eoesep.h @@ -59,7 +59,7 @@ gendata_esep_classes( esep_classes[j] = cl | ti; visited[j] = true; } - rep[class] = i; + rep[class] = (uint16_t)i; class++; } @@ -140,7 +140,8 @@ gendata_eoesep_fromdone( ) { uint8_t pval; - uint64_t i, esep, eo, coord, done; + uint32_t done; + uint64_t i, esep, eo, coord; done = 0; for (i = 0; i < ESEP_CLASSES; i++) { @@ -169,7 +170,8 @@ gendata_eoesep_fromnew( ) { uint8_t pval; - uint64_t i, esep, eo, coord, done; + uint32_t done; + uint64_t i, esep, eo, coord; cube_t c; done = 0; diff --git a/src/solvers/h48/gendata_h48.h b/src/solvers/h48/gendata_h48.h index 283c472..53b1fad 100644 --- a/src/solvers/h48/gendata_h48.h +++ b/src/solvers/h48/gendata_h48.h @@ -264,7 +264,7 @@ gendata_h48_maintable(gendata_h48_arg_t arg[NON_NULL]) velocity = count; /* We plan to log 10 times */ - sleeptime = (100*(nshort-velocity)) / velocity; + sleeptime = (int)((100*(nshort-velocity)) / velocity); done = count; while (nshort - done > (velocity * sleeptime) / 1000) { @@ -320,7 +320,7 @@ gendata_h48_runthread(void *arg) mutex = H48_LINE(coord) % CHUNKS; wrapthread_mutex_lock(dfsarg->table_mutex[mutex]); set_h48_pval(dfsarg->table, coordext, 0); - set_h48_pvalmin(dfsarg->table, coordmin, kv.val); + set_h48_pvalmin(dfsarg->table, coordmin, (uint8_t)kv.val); wrapthread_mutex_unlock(dfsarg->table_mutex[mutex]); } else { dfsarg->cube = invcoord_h48(kv.key, dfsarg->crep, 11); diff --git a/src/solvers/h48/solve.h b/src/solvers/h48/solve.h index 295ef88..ebc5208 100644 --- a/src/solvers/h48/solve.h +++ b/src/solvers/h48/solve.h @@ -111,7 +111,8 @@ STATIC long long solve_h48_dispatch( if (err != NISSY_OK) return err; - return solve_h48(oc, minmoves, maxmoves, maxsols, optimal, threads, + return solve_h48(oc, (uint8_t)minmoves, (uint8_t)maxmoves, + (uint8_t)maxsols, (uint8_t)optimal, (uint8_t)threads, data_size, data, sols_size, sols, stats, poll_status, poll_status_data); } @@ -343,7 +344,7 @@ solve_h48_dfs(dfsarg_solve_h48_t arg[NON_NULL]) backup_inverse = arg->inverse; ret = 0; - if (popcount_u32(mm_normal) <= popcount_u32(mm_inverse)) { + if (popcount_u64(mm_normal) <= popcount_u64(mm_inverse)) { h48_prune_pipeline(arg, prune, target, true); arg->solution_moves->nmoves++; for (m = 0; m < NMOVES; m++) { @@ -456,8 +457,7 @@ solve_h48_maketasks( int ntasks[NON_NULL] ) { - int r; - int64_t appret; + int64_t r, appret; uint8_t m, t; uint64_t mm; cube_t backup_cube; diff --git a/src/solvers/h48/utils.h b/src/solvers/h48/utils.h index d181eab..6d91108 100644 --- a/src/solvers/h48/utils.h +++ b/src/solvers/h48/utils.h @@ -29,7 +29,7 @@ parse_h48h(const char *buf, uint8_t h[NON_NULL]) goto parse_h48h_error; } - *h = atoi(buf); + *h = (uint8_t)atoi(buf); if (*h > H48_HMAX) { LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " "at most %" PRIu8 ")\n", *h, H48_HMAX); diff --git a/src/solvers/solutions.h b/src/solvers/solutions.h index beedc64..b7a848b 100644 --- a/src/solvers/solutions.h +++ b/src/solvers/solutions.h @@ -33,7 +33,7 @@ solution_moves_transform(solution_moves_t moves[NON_NULL], size_t z, uint8_t t) { uint8_t i; - for (i = z; i < moves->nmoves; i++) + for (i = (uint8_t)z; i < moves->nmoves; i++) moves->moves[i] = transform_move(moves->moves[i], t); for (i = 0; i < moves->npremoves; i++) diff --git a/src/solvers/tables.h b/src/solvers/tables.h index 8211ab3..3db1d1e 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h @@ -140,7 +140,7 @@ writetableinfo( STATIC void append_name(tableinfo_t info[NON_NULL], const char *str) { - int i, j; + size_t i, j; for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) info->solver[j] = str[i]; diff --git a/src/utils/math.h b/src/utils/math.h index f2176b6..0c56861 100644 --- a/src/utils/math.h +++ b/src/utils/math.h @@ -73,10 +73,10 @@ indextoperm(uint64_t p, size_t n, uint8_t *r) /* Find k-th unused number */ for (j = 0, c = 0; c <= k; j++) - c += 1 - ((used & (1<> j); + c += UINT64_C(1) - ((used & (UINT64_C(1)<> j); - r[i] = j-1; - used |= 1 << (j-1); + r[i] = (uint8_t)(j-1); + used |= UINT64_C(1) << (j-1); p %= factorial[n-i-1]; } 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); diff --git a/tools/solvetest.h b/tools/solvetest.h index 3c9badc..8c93d21 100644 --- a/tools/solvetest.h +++ b/tools/solvetest.h @@ -130,7 +130,7 @@ int main(int argc, char **argv) { printf("Using user-specified solver %s\n", solver); } - srand(time(NULL)); + srand((unsigned)time(NULL)); nissy_setlogger(log_stderr, NULL); size = nissy_solverinfo(solver, dataid); -- cgit v1.3