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 /src/nissy.c | |
| 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 'src/nissy.c')
| -rw-r--r-- | src/nissy.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/nissy.c b/src/nissy.c index f744fa8..dfa1a90 100644 --- a/src/nissy.c +++ b/src/nissy.c | |||
| @@ -14,14 +14,14 @@ | |||
| 14 | 14 | ||
| 15 | long long parse_h48_solver( | 15 | long long parse_h48_solver( |
| 16 | const char *, uint8_t [static 1], uint8_t [static 1]); | 16 | const char *, uint8_t [static 1], uint8_t [static 1]); |
| 17 | STATIC bool checkdata(const char *, const tableinfo_t [static 1]); | 17 | STATIC bool checkdata(const unsigned char *, const tableinfo_t [static 1]); |
| 18 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], | 18 | STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], |
| 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); | 19 | const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); |
| 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); | 20 | STATIC long long write_result(cube_t, char [static NISSY_SIZE_B32]); |
| 21 | STATIC size_t my_strnlen(const char *, size_t); | 21 | STATIC size_t my_strnlen(const char *, size_t); |
| 22 | STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); | 22 | STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); |
| 23 | STATIC long long nissy_gendata_unsafe( | 23 | STATIC long long nissy_gendata_unsafe( |
| 24 | const char *, unsigned long long, char *); | 24 | const char *, unsigned long long, unsigned char *); |
| 25 | 25 | ||
| 26 | #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } | 26 | #define GETCUBE_OPTIONS(S, F) { .option = S, .fix = F } |
| 27 | struct { | 27 | struct { |
| @@ -66,7 +66,7 @@ parse_h48_solver_error: | |||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | STATIC bool | 68 | STATIC bool |
| 69 | checkdata(const char *buf, const tableinfo_t info[static 1]) | 69 | checkdata(const unsigned char *buf, const tableinfo_t info[static 1]) |
| 70 | { | 70 | { |
| 71 | uint64_t distr[INFO_DISTRIBUTION_LEN]; | 71 | uint64_t distr[INFO_DISTRIBUTION_LEN]; |
| 72 | 72 | ||
| @@ -78,10 +78,10 @@ checkdata(const char *buf, const tableinfo_t info[static 1]) | |||
| 78 | getdistribution_cocsep( | 78 | getdistribution_cocsep( |
| 79 | (uint32_t *)((char *)buf + INFOSIZE), distr); | 79 | (uint32_t *)((char *)buf + INFOSIZE), distr); |
| 80 | } else if (!strncmp(info->solver, "h48", 3)) { | 80 | } else if (!strncmp(info->solver, "h48", 3)) { |
| 81 | getdistribution_h48((uint8_t *)buf + INFOSIZE, distr, | 81 | getdistribution_h48(buf + INFOSIZE, distr, |
| 82 | info->h48h, info->bits); | 82 | info->h48h, info->bits); |
| 83 | } else if (!strncmp(info->solver, "coordinate solver for ", 22)) { | 83 | } else if (!strncmp(info->solver, "coordinate solver for ", 22)) { |
| 84 | getdistribution_coord((uint8_t *)buf + INFOSIZE, | 84 | getdistribution_coord(buf + INFOSIZE, |
| 85 | info->solver + 22, distr); | 85 | info->solver + 22, distr); |
| 86 | } else if (!strncmp(info->solver, "eoesep data for h48", 19)) { | 86 | } else if (!strncmp(info->solver, "eoesep data for h48", 19)) { |
| 87 | return true; | 87 | return true; |
| @@ -366,7 +366,7 @@ nissy_getcube( | |||
| 366 | long long | 366 | long long |
| 367 | nissy_datainfo( | 367 | nissy_datainfo( |
| 368 | uint64_t data_size, | 368 | uint64_t data_size, |
| 369 | const char data[data_size] | 369 | const unsigned char data[data_size] |
| 370 | ) | 370 | ) |
| 371 | { | 371 | { |
| 372 | uint8_t i; | 372 | uint8_t i; |
| @@ -405,8 +405,7 @@ nissy_datainfo( | |||
| 405 | } | 405 | } |
| 406 | 406 | ||
| 407 | if (info.next != 0) | 407 | if (info.next != 0) |
| 408 | return nissy_datainfo( | 408 | return nissy_datainfo(data_size - info.next, data + info.next); |
| 409 | data_size - info.next, (char *)data + info.next); | ||
| 410 | 409 | ||
| 411 | LOG("\n---------\n"); | 410 | LOG("\n---------\n"); |
| 412 | 411 | ||
| @@ -452,7 +451,7 @@ long long | |||
| 452 | nissy_gendata( | 451 | nissy_gendata( |
| 453 | const char *solver, | 452 | const char *solver, |
| 454 | unsigned long long data_size, | 453 | unsigned long long data_size, |
| 455 | char data[data_size] | 454 | unsigned char data[data_size] |
| 456 | ) | 455 | ) |
| 457 | { | 456 | { |
| 458 | return nissy_gendata_unsafe(solver, data_size, data); | 457 | return nissy_gendata_unsafe(solver, data_size, data); |
| @@ -462,7 +461,7 @@ STATIC long long | |||
| 462 | nissy_gendata_unsafe( | 461 | nissy_gendata_unsafe( |
| 463 | const char *solver, | 462 | const char *solver, |
| 464 | unsigned long long data_size, | 463 | unsigned long long data_size, |
| 465 | char *data | 464 | unsigned char *data |
| 466 | ) | 465 | ) |
| 467 | { | 466 | { |
| 468 | long long parse_ret; | 467 | long long parse_ret; |
| @@ -497,10 +496,9 @@ nissy_gendata_unsafe( | |||
| 497 | long long | 496 | long long |
| 498 | nissy_checkdata( | 497 | nissy_checkdata( |
| 499 | unsigned long long data_size, | 498 | unsigned long long data_size, |
| 500 | const char data[data_size] | 499 | const unsigned char data[data_size] |
| 501 | ) | 500 | ) |
| 502 | { | 501 | { |
| 503 | char *buf; | ||
| 504 | tableinfo_t info; | 502 | tableinfo_t info; |
| 505 | int64_t err; | 503 | int64_t err; |
| 506 | 504 | ||
| @@ -509,7 +507,7 @@ nissy_checkdata( | |||
| 509 | return NISSY_ERROR_DATA; | 507 | return NISSY_ERROR_DATA; |
| 510 | } | 508 | } |
| 511 | 509 | ||
| 512 | for (buf = (char *)data; | 510 | for (const unsigned char *buf = data; |
| 513 | (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; | 511 | (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; |
| 514 | buf += info.next, data_size -= info.next) | 512 | buf += info.next, data_size -= info.next) |
| 515 | { | 513 | { |
| @@ -537,7 +535,7 @@ nissy_solve( | |||
| 537 | unsigned optimal, | 535 | unsigned optimal, |
| 538 | unsigned threads, | 536 | unsigned threads, |
| 539 | unsigned long long data_size, | 537 | unsigned long long data_size, |
| 540 | const char data[data_size], | 538 | const unsigned char data[data_size], |
| 541 | unsigned sols_size, | 539 | unsigned sols_size, |
| 542 | char sols[sols_size], | 540 | char sols[sols_size], |
| 543 | long long stats[static NISSY_SIZE_SOLVE_STATS] | 541 | long long stats[static NISSY_SIZE_SOLVE_STATS] |
