diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-21 14:33:01 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-04-21 14:44:07 +0200 |
| commit | 510a7471348788fccba6b7c4b9f7b7cc9aee6ba9 (patch) | |
| tree | 58df7791242d9a4f52e80da93ad3af20ed5e3528 /tools | |
| parent | 1d9b8acfeece68c4f55d2499d8aed127f98a383c (diff) | |
| download | nissy-core-510a7471348788fccba6b7c4b9f7b7cc9aee6ba9.tar.gz nissy-core-510a7471348788fccba6b7c4b9f7b7cc9aee6ba9.zip | |
Always use unsigned char * for data buffers
Before this commit I was inconsistently using one of void *, char *
and uint8_t *.
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/000_gendata/gendata.c | 3 | ||||
| -rw-r--r-- | tools/100_checkdata/checkdata.c | 3 | ||||
| -rw-r--r-- | tools/300_solve_small/solve_small.c | 2 | ||||
| -rw-r--r-- | tools/301_solve_file/solve_file.c | 2 | ||||
| -rw-r--r-- | tools/302_solve_multisol/solve_multisol.c | 2 | ||||
| -rw-r--r-- | tools/400_solvetest/solve_test.c | 3 | ||||
| -rw-r--r-- | tools/expected_distributions.h | 8 | ||||
| -rw-r--r-- | tools/nissy_extra.h | 5 | ||||
| -rw-r--r-- | tools/tool.h | 24 |
9 files changed, 29 insertions, 23 deletions
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 | |||
| 8 | run(void) { | 8 | run(void) { |
| 9 | int64_t size; | 9 | int64_t size; |
| 10 | bool consistent, expected; | 10 | bool consistent, expected; |
| 11 | char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; | 11 | char filename[1024], dataid[NISSY_SIZE_DATAID]; |
| 12 | unsigned char *buf; | ||
| 12 | 13 | ||
| 13 | size = generatetable(solver, &buf, dataid); | 14 | size = generatetable(solver, &buf, dataid); |
| 14 | switch (size) { | 15 | 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; | |||
| 6 | static void | 6 | static void |
| 7 | run(void) { | 7 | run(void) { |
| 8 | long long int size, result; | 8 | long long int size, result; |
| 9 | char *buf, dataid[NISSY_SIZE_DATAID]; | 9 | char dataid[NISSY_SIZE_DATAID]; |
| 10 | unsigned char *buf; | ||
| 10 | FILE *f; | 11 | FILE *f; |
| 11 | 12 | ||
| 12 | size = nissy_solverinfo(solver, dataid); | 13 | 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 @@ | |||
| 4 | 4 | ||
| 5 | char *solver; | 5 | char *solver; |
| 6 | int64_t size = 0; | 6 | int64_t size = 0; |
| 7 | char *buf; | 7 | unsigned char *buf; |
| 8 | 8 | ||
| 9 | char *scrambles[] = { | 9 | char *scrambles[] = { |
| 10 | /* 12 optimal */ | 10 | /* 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 @@ | |||
| 6 | 6 | ||
| 7 | char *solver; | 7 | char *solver; |
| 8 | int64_t size = 0, N = 0; | 8 | int64_t size = 0, N = 0; |
| 9 | char *buf; | 9 | unsigned char *buf; |
| 10 | char scrambles[MAX_SCR][MAX_SCR_LEN]; | 10 | char scrambles[MAX_SCR][MAX_SCR_LEN]; |
| 11 | 11 | ||
| 12 | void run(void) { | 12 | 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 @@ | |||
| 5 | int nsol; | 5 | int nsol; |
| 6 | char *solver; | 6 | char *solver; |
| 7 | int64_t size = 0; | 7 | int64_t size = 0; |
| 8 | char *buf; | 8 | unsigned char *buf; |
| 9 | 9 | ||
| 10 | char *scrambles[] = { | 10 | char *scrambles[] = { |
| 11 | "U2 D2 F2 B2 L2 R2", | 11 | "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 @@ | |||
| 5 | 5 | ||
| 6 | char *solver; | 6 | char *solver; |
| 7 | int64_t size = 0; | 7 | int64_t size = 0; |
| 8 | char *buf; | 8 | unsigned char *buf; |
| 9 | |||
| 10 | 9 | ||
| 11 | bool check_one(char *actual, char *expected) { | 10 | bool check_one(char *actual, char *expected) { |
| 12 | unsigned i; | 11 | 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) | |||
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | static bool | 199 | static bool |
| 200 | check_cocsep(size_t data_size, const void *data) | 200 | check_cocsep(size_t data_size, const unsigned char *data) |
| 201 | { | 201 | { |
| 202 | tableinfo_t info; | 202 | tableinfo_t info; |
| 203 | 203 | ||
| @@ -219,7 +219,11 @@ unknown_h48(uint8_t h, uint8_t k) | |||
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | STATIC bool | 221 | STATIC bool |
| 222 | check_distribution(const char *solver, size_t data_size, const void *data) | 222 | check_distribution( |
| 223 | const char *solver, | ||
| 224 | size_t data_size, | ||
| 225 | const unsigned char *data | ||
| 226 | ) | ||
| 223 | { | 227 | { |
| 224 | const char *str; | 228 | const char *str; |
| 225 | tableinfo_t info = {0}; | 229 | 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. | |||
| 9 | #include "../src/solvers/tables_types_macros.h" | 9 | #include "../src/solvers/tables_types_macros.h" |
| 10 | #include "../src/solvers/tables.h" | 10 | #include "../src/solvers/tables.h" |
| 11 | 11 | ||
| 12 | size_t gendata_h48_derive(uint8_t, const void *, void *); | 12 | size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *); |
| 13 | int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); | 13 | int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); |
| 14 | long long int nissy_datainfo(uint64_t, const char *); | 14 | long long int nissy_datainfo(uint64_t, const unsigned char *); |
| 15 | long long int nissy_derivedata(const char *, const void *, void *); | ||
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 @@ | |||
| 11 | 11 | ||
| 12 | static void log_stderr(const char *, void *); | 12 | static void log_stderr(const char *, void *); |
| 13 | static double timerun(void (*)(void)); | 13 | static double timerun(void (*)(void)); |
| 14 | static void writetable(const char *, int64_t, const char *); | 14 | static void writetable(const unsigned char *, int64_t, const char *); |
| 15 | static long long int generatetable(const char *, char **, | 15 | static long long int generatetable(const char *, unsigned char **, |
| 16 | char [static NISSY_SIZE_DATAID]); | 16 | char [static NISSY_SIZE_DATAID]); |
| 17 | static long long int derivetable( | 17 | static long long int derivetable( |
| 18 | const char *, const char *, const char *, char **); | 18 | const char *, const char *, const char *, unsigned char **); |
| 19 | static int getdata(const char *, char **, const char *); | 19 | static int getdata(const char *, unsigned char **, const char *); |
| 20 | static void gendata_run(const char *, uint64_t[static 21]); | 20 | static void gendata_run(const char *, uint64_t[static 21]); |
| 21 | static void derivedata_run( | 21 | static void derivedata_run( |
| 22 | const char *, const char *, const char *, const char *); | 22 | const char *, const char *, const char *, const char *); |
| @@ -57,7 +57,7 @@ timerun(void (*run)(void)) | |||
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | static void | 59 | static void |
| 60 | writetable(const char *buf, int64_t size, const char *filename) | 60 | writetable(const unsigned char *buf, int64_t size, const char *filename) |
| 61 | { | 61 | { |
| 62 | FILE *f; | 62 | FILE *f; |
| 63 | 63 | ||
| @@ -74,7 +74,7 @@ writetable(const char *buf, int64_t size, const char *filename) | |||
| 74 | static long long int | 74 | static long long int |
| 75 | generatetable( | 75 | generatetable( |
| 76 | const char *solver, | 76 | const char *solver, |
| 77 | char **buf, | 77 | unsigned char **buf, |
| 78 | char dataid[static NISSY_SIZE_DATAID] | 78 | char dataid[static NISSY_SIZE_DATAID] |
| 79 | ) | 79 | ) |
| 80 | { | 80 | { |
| @@ -105,12 +105,13 @@ derivetable( | |||
| 105 | const char *solver_large, | 105 | const char *solver_large, |
| 106 | const char *solver_small, | 106 | const char *solver_small, |
| 107 | const char *filename_large, | 107 | const char *filename_large, |
| 108 | char **buf | 108 | unsigned char **buf |
| 109 | ) | 109 | ) |
| 110 | { | 110 | { |
| 111 | uint8_t h, k; | 111 | uint8_t h, k; |
| 112 | long long int size, gensize; | 112 | long long int size, gensize; |
| 113 | char *fulltable, dataid[NISSY_SIZE_DATAID]; | 113 | char dataid[NISSY_SIZE_DATAID]; |
| 114 | unsigned char *fulltable; | ||
| 114 | 115 | ||
| 115 | if (getdata(solver_large, &fulltable, filename_large) != 0) { | 116 | if (getdata(solver_large, &fulltable, filename_large) != 0) { |
| 116 | printf("Error reading full table.\n"); | 117 | printf("Error reading full table.\n"); |
| @@ -149,7 +150,7 @@ derivetable_error_nofree: | |||
| 149 | static int | 150 | static int |
| 150 | getdata( | 151 | getdata( |
| 151 | const char *solver, | 152 | const char *solver, |
| 152 | char **buf, | 153 | unsigned char **buf, |
| 153 | const char *filename | 154 | const char *filename |
| 154 | ) { | 155 | ) { |
| 155 | long long int size, sizeread; | 156 | long long int size, sizeread; |
| @@ -194,7 +195,8 @@ gendata_run( | |||
| 194 | uint64_t expected[static 21] | 195 | uint64_t expected[static 21] |
| 195 | ) { | 196 | ) { |
| 196 | long long int size; | 197 | long long int size; |
| 197 | char *buf, filename[1024], dataid[NISSY_SIZE_DATAID]; | 198 | char filename[1024], dataid[NISSY_SIZE_DATAID]; |
| 199 | unsigned char *buf; | ||
| 198 | 200 | ||
| 199 | size = generatetable(solver, &buf, dataid); | 201 | size = generatetable(solver, &buf, dataid); |
| 200 | sprintf(filename, "tables/%s", dataid); | 202 | sprintf(filename, "tables/%s", dataid); |
| @@ -227,7 +229,7 @@ derivedata_run( | |||
| 227 | ) | 229 | ) |
| 228 | { | 230 | { |
| 229 | long long int size; | 231 | long long int size; |
| 230 | char *buf; | 232 | unsigned char *buf; |
| 231 | 233 | ||
| 232 | buf = NULL; | 234 | buf = NULL; |
| 233 | size = derivetable(solver_large, solver_small, filename_large, &buf); | 235 | size = derivetable(solver_large, solver_small, filename_large, &buf); |
