aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-21 14:33:01 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-21 14:44:07 +0200
commit510a7471348788fccba6b7c4b9f7b7cc9aee6ba9 (patch)
tree58df7791242d9a4f52e80da93ad3af20ed5e3528 /tools
parent1d9b8acfeece68c4f55d2499d8aed127f98a383c (diff)
downloadnissy-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.c3
-rw-r--r--tools/100_checkdata/checkdata.c3
-rw-r--r--tools/300_solve_small/solve_small.c2
-rw-r--r--tools/301_solve_file/solve_file.c2
-rw-r--r--tools/302_solve_multisol/solve_multisol.c2
-rw-r--r--tools/400_solvetest/solve_test.c3
-rw-r--r--tools/expected_distributions.h8
-rw-r--r--tools/nissy_extra.h5
-rw-r--r--tools/tool.h24
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
8run(void) { 8run(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;
6static void 6static void
7run(void) { 7run(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
5char *solver; 5char *solver;
6int64_t size = 0; 6int64_t size = 0;
7char *buf; 7unsigned char *buf;
8 8
9char *scrambles[] = { 9char *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
7char *solver; 7char *solver;
8int64_t size = 0, N = 0; 8int64_t size = 0, N = 0;
9char *buf; 9unsigned char *buf;
10char scrambles[MAX_SCR][MAX_SCR_LEN]; 10char scrambles[MAX_SCR][MAX_SCR_LEN];
11 11
12void run(void) { 12void 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 @@
5int nsol; 5int nsol;
6char *solver; 6char *solver;
7int64_t size = 0; 7int64_t size = 0;
8char *buf; 8unsigned char *buf;
9 9
10char *scrambles[] = { 10char *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
6char *solver; 6char *solver;
7int64_t size = 0; 7int64_t size = 0;
8char *buf; 8unsigned char *buf;
9
10 9
11bool check_one(char *actual, char *expected) { 10bool 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
199static bool 199static bool
200check_cocsep(size_t data_size, const void *data) 200check_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
221STATIC bool 221STATIC bool
222check_distribution(const char *solver, size_t data_size, const void *data) 222check_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
12size_t gendata_h48_derive(uint8_t, const void *, void *); 12size_t gendata_h48_derive(uint8_t, const unsigned char *, unsigned char *);
13int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]); 13int parse_h48_solver(const char *, uint8_t [static 1], uint8_t [static 1]);
14long long int nissy_datainfo(uint64_t, const char *); 14long long int nissy_datainfo(uint64_t, const unsigned char *);
15long 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
12static void log_stderr(const char *, void *); 12static void log_stderr(const char *, void *);
13static double timerun(void (*)(void)); 13static double timerun(void (*)(void));
14static void writetable(const char *, int64_t, const char *); 14static void writetable(const unsigned char *, int64_t, const char *);
15static long long int generatetable(const char *, char **, 15static long long int generatetable(const char *, unsigned char **,
16 char [static NISSY_SIZE_DATAID]); 16 char [static NISSY_SIZE_DATAID]);
17static long long int derivetable( 17static long long int derivetable(
18 const char *, const char *, const char *, char **); 18 const char *, const char *, const char *, unsigned char **);
19static int getdata(const char *, char **, const char *); 19static int getdata(const char *, unsigned char **, const char *);
20static void gendata_run(const char *, uint64_t[static 21]); 20static void gendata_run(const char *, uint64_t[static 21]);
21static void derivedata_run( 21static 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
59static void 59static void
60writetable(const char *buf, int64_t size, const char *filename) 60writetable(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)
74static long long int 74static long long int
75generatetable( 75generatetable(
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:
149static int 150static int
150getdata( 151getdata(
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);

Generated with cgit - Back to sebastiano.tronto.net