From 510a7471348788fccba6b7c4b9f7b7cc9aee6ba9 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 21 Apr 2025 14:33:01 +0200 Subject: Always use unsigned char * for data buffers Before this commit I was inconsistently using one of void *, char * and uint8_t *. --- tools/000_gendata/gendata.c | 3 ++- tools/100_checkdata/checkdata.c | 3 ++- tools/300_solve_small/solve_small.c | 2 +- tools/301_solve_file/solve_file.c | 2 +- tools/302_solve_multisol/solve_multisol.c | 2 +- tools/400_solvetest/solve_test.c | 3 +-- tools/expected_distributions.h | 8 ++++++-- tools/nissy_extra.h | 5 ++--- tools/tool.h | 24 +++++++++++++----------- 9 files changed, 29 insertions(+), 23 deletions(-) (limited to 'tools') diff --git a/tools/000_gendata/gendata.c b/tools/000_gendata/gendata.c index 470fe9b..cd7fb0f 100644 --- a/tools/000_gendata/gendata.c +++ b/tools/000_gendata/gendata.c @@ -8,7 +8,8 @@ static void run(void) { int64_t size; bool consistent, expected; - char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; + char filename[1024], dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; size = generatetable(solver, &buf, dataid); switch (size) { diff --git a/tools/100_checkdata/checkdata.c b/tools/100_checkdata/checkdata.c index cf42cbe..eefb063 100644 --- a/tools/100_checkdata/checkdata.c +++ b/tools/100_checkdata/checkdata.c @@ -6,7 +6,8 @@ char *solver, *filename; static void run(void) { long long int size, result; - char *buf, dataid[NISSY_SIZE_DATAID]; + char dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; FILE *f; size = nissy_solverinfo(solver, dataid); diff --git a/tools/300_solve_small/solve_small.c b/tools/300_solve_small/solve_small.c index d81ed51..2efbcb5 100644 --- a/tools/300_solve_small/solve_small.c +++ b/tools/300_solve_small/solve_small.c @@ -4,7 +4,7 @@ char *solver; int64_t size = 0; -char *buf; +unsigned char *buf; char *scrambles[] = { /* 12 optimal */ diff --git a/tools/301_solve_file/solve_file.c b/tools/301_solve_file/solve_file.c index 110c7d2..fcc018d 100644 --- a/tools/301_solve_file/solve_file.c +++ b/tools/301_solve_file/solve_file.c @@ -6,7 +6,7 @@ char *solver; int64_t size = 0, N = 0; -char *buf; +unsigned char *buf; char scrambles[MAX_SCR][MAX_SCR_LEN]; void run(void) { diff --git a/tools/302_solve_multisol/solve_multisol.c b/tools/302_solve_multisol/solve_multisol.c index e4256de..f6057d7 100644 --- a/tools/302_solve_multisol/solve_multisol.c +++ b/tools/302_solve_multisol/solve_multisol.c @@ -5,7 +5,7 @@ int nsol; char *solver; int64_t size = 0; -char *buf; +unsigned char *buf; char *scrambles[] = { "U2 D2 F2 B2 L2 R2", diff --git a/tools/400_solvetest/solve_test.c b/tools/400_solvetest/solve_test.c index a4121a5..a724320 100644 --- a/tools/400_solvetest/solve_test.c +++ b/tools/400_solvetest/solve_test.c @@ -5,8 +5,7 @@ char *solver; int64_t size = 0; -char *buf; - +unsigned char *buf; bool check_one(char *actual, char *expected) { unsigned i; diff --git a/tools/expected_distributions.h b/tools/expected_distributions.h index 7f33335..12faf1d 100644 --- a/tools/expected_distributions.h +++ b/tools/expected_distributions.h @@ -197,7 +197,7 @@ check_table(uint64_t *exp, tableinfo_t *info) } static bool -check_cocsep(size_t data_size, const void *data) +check_cocsep(size_t data_size, const unsigned char *data) { tableinfo_t info; @@ -219,7 +219,11 @@ unknown_h48(uint8_t h, uint8_t k) } STATIC bool -check_distribution(const char *solver, size_t data_size, const void *data) +check_distribution( + const char *solver, + size_t data_size, + const unsigned char *data +) { const char *str; tableinfo_t info = {0}; diff --git a/tools/nissy_extra.h b/tools/nissy_extra.h index 505f53a..63d171b 100644 --- a/tools/nissy_extra.h +++ b/tools/nissy_extra.h @@ -9,7 +9,6 @@ for testing purposes only. #include "../src/solvers/tables_types_macros.h" #include "../src/solvers/tables.h" -size_t gendata_h48_derive(uint8_t, const void *, void *); +size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *); int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); -long long int nissy_datainfo(uint64_t, const char *); -long long int nissy_derivedata(const char *, const void *, void *); +long long int nissy_datainfo(uint64_t, const unsigned char *); diff --git a/tools/tool.h b/tools/tool.h index 58721a2..77cdf34 100644 --- a/tools/tool.h +++ b/tools/tool.h @@ -11,12 +11,12 @@ static void log_stderr(const char *, void *); static double timerun(void (*)(void)); -static void writetable(const char *, int64_t, const char *); -static long long int generatetable(const char *, char **, +static void writetable(const unsigned char *, int64_t, const char *); +static long long int generatetable(const char *, unsigned char **, char [static NISSY_SIZE_DATAID]); static long long int derivetable( - const char *, const char *, const char *, char **); -static int getdata(const char *, char **, const char *); + const char *, const char *, const char *, unsigned char **); +static int getdata(const char *, unsigned char **, const char *); static void gendata_run(const char *, uint64_t[static 21]); static void derivedata_run( const char *, const char *, const char *, const char *); @@ -57,7 +57,7 @@ timerun(void (*run)(void)) } static void -writetable(const char *buf, int64_t size, const char *filename) +writetable(const unsigned char *buf, int64_t size, const char *filename) { FILE *f; @@ -74,7 +74,7 @@ writetable(const char *buf, int64_t size, const char *filename) static long long int generatetable( const char *solver, - char **buf, + unsigned char **buf, char dataid[static NISSY_SIZE_DATAID] ) { @@ -105,12 +105,13 @@ derivetable( const char *solver_large, const char *solver_small, const char *filename_large, - char **buf + unsigned char **buf ) { uint8_t h, k; long long int size, gensize; - char *fulltable, dataid[NISSY_SIZE_DATAID]; + char dataid[NISSY_SIZE_DATAID]; + unsigned char *fulltable; if (getdata(solver_large, &fulltable, filename_large) != 0) { printf("Error reading full table.\n"); @@ -149,7 +150,7 @@ derivetable_error_nofree: static int getdata( const char *solver, - char **buf, + unsigned char **buf, const char *filename ) { long long int size, sizeread; @@ -194,7 +195,8 @@ gendata_run( uint64_t expected[static 21] ) { long long int size; - char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; + char filename[1024], dataid[NISSY_SIZE_DATAID]; + unsigned char *buf; size = generatetable(solver, &buf, dataid); sprintf(filename, "tables/%s", dataid); @@ -227,7 +229,7 @@ derivedata_run( ) { long long int size; - char *buf; + unsigned char *buf; buf = NULL; size = derivetable(solver_large, solver_small, filename_large, &buf); -- cgit v1.3