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/solvers/tables.h | |
| 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/solvers/tables.h')
| -rw-r--r-- | src/solvers/tables.h | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/solvers/tables.h b/src/solvers/tables.h index db888b5..9147972 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h | |||
| @@ -1,13 +1,14 @@ | |||
| 1 | STATIC uint64_t read_unaligned_u64(const char [static sizeof(uint64_t)]); | 1 | STATIC uint64_t read_unaligned_u64(const unsigned char [static sizeof(uint64_t)]); |
| 2 | STATIC void write_unaligned_u64(char [static sizeof(uint64_t)], uint64_t); | 2 | STATIC void write_unaligned_u64(unsigned char [static sizeof(uint64_t)], uint64_t); |
| 3 | STATIC int64_t readtableinfo(size_t n, const char [n], tableinfo_t [static 1]); | 3 | STATIC int64_t readtableinfo( |
| 4 | size_t n, const unsigned char [n], tableinfo_t [static 1]); | ||
| 4 | STATIC int64_t readtableinfo_n( | 5 | STATIC int64_t readtableinfo_n( |
| 5 | size_t n, const char [n], uint8_t, tableinfo_t [static 1]); | 6 | size_t n, const unsigned char [n], uint8_t, tableinfo_t [static 1]); |
| 6 | STATIC int64_t writetableinfo( | 7 | STATIC int64_t writetableinfo( |
| 7 | const tableinfo_t [static 1], size_t n, char [n]); | 8 | const tableinfo_t [static 1], size_t n, unsigned char [n]); |
| 8 | 9 | ||
| 9 | STATIC uint64_t | 10 | STATIC uint64_t |
| 10 | read_unaligned_u64(const char buf[static sizeof(uint64_t)]) | 11 | read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) |
| 11 | { | 12 | { |
| 12 | uint64_t ret; | 13 | uint64_t ret; |
| 13 | 14 | ||
| @@ -17,7 +18,7 @@ read_unaligned_u64(const char buf[static sizeof(uint64_t)]) | |||
| 17 | } | 18 | } |
| 18 | 19 | ||
| 19 | STATIC void | 20 | STATIC void |
| 20 | write_unaligned_u64(char buf[static sizeof(uint64_t)], uint64_t x) | 21 | write_unaligned_u64(unsigned char buf[static sizeof(uint64_t)], uint64_t x) |
| 21 | { | 22 | { |
| 22 | memcpy(buf, &x, sizeof(uint64_t)); | 23 | memcpy(buf, &x, sizeof(uint64_t)); |
| 23 | } | 24 | } |
| @@ -25,7 +26,7 @@ write_unaligned_u64(char buf[static sizeof(uint64_t)], uint64_t x) | |||
| 25 | STATIC int64_t | 26 | STATIC int64_t |
| 26 | readtableinfo( | 27 | readtableinfo( |
| 27 | size_t buf_size, | 28 | size_t buf_size, |
| 28 | const char buf[buf_size], | 29 | const unsigned char buf[buf_size], |
| 29 | tableinfo_t info[static 1] | 30 | tableinfo_t info[static 1] |
| 30 | ) | 31 | ) |
| 31 | { | 32 | { |
| @@ -69,7 +70,7 @@ readtableinfo( | |||
| 69 | STATIC int64_t | 70 | STATIC int64_t |
| 70 | readtableinfo_n( | 71 | readtableinfo_n( |
| 71 | size_t buf_size, | 72 | size_t buf_size, |
| 72 | const char buf[buf_size], | 73 | const unsigned char buf[buf_size], |
| 73 | uint8_t n, | 74 | uint8_t n, |
| 74 | tableinfo_t info[static 1] | 75 | tableinfo_t info[static 1] |
| 75 | ) | 76 | ) |
| @@ -87,12 +88,12 @@ STATIC int64_t | |||
| 87 | writetableinfo( | 88 | writetableinfo( |
| 88 | const tableinfo_t info[static 1], | 89 | const tableinfo_t info[static 1], |
| 89 | size_t data_size, | 90 | size_t data_size, |
| 90 | char buf[data_size] | 91 | unsigned char buf[data_size] |
| 91 | ) | 92 | ) |
| 92 | { | 93 | { |
| 93 | size_t i; | 94 | size_t i; |
| 94 | bool end; | 95 | bool end; |
| 95 | char *c; | 96 | unsigned char *c; |
| 96 | 97 | ||
| 97 | if (data_size < info->fullsize) { | 98 | if (data_size < info->fullsize) { |
| 98 | LOG("Error writing table: buffer size is too small " | 99 | LOG("Error writing table: buffer size is too small " |
| @@ -125,10 +126,10 @@ writetableinfo( | |||
| 125 | *c = 0; | 126 | *c = 0; |
| 126 | } | 127 | } |
| 127 | 128 | ||
| 128 | *(uint8_t *)OFFSET(buf, INFO_OFFSET_H48H) = info->h48h; | 129 | *OFFSET(buf, INFO_OFFSET_H48H) = (unsigned char)info->h48h; |
| 129 | *(uint8_t *)OFFSET(buf, INFO_OFFSET_BITS) = info->bits; | 130 | *OFFSET(buf, INFO_OFFSET_BITS) = (unsigned char)info->bits; |
| 130 | *(uint8_t *)OFFSET(buf, INFO_OFFSET_BASE) = info->base; | 131 | *OFFSET(buf, INFO_OFFSET_BASE) = (unsigned char)info->base; |
| 131 | *(uint8_t *)OFFSET(buf, INFO_OFFSET_MAXVALUE) = info->maxvalue; | 132 | *OFFSET(buf, INFO_OFFSET_MAXVALUE) = (unsigned char)info->maxvalue; |
| 132 | 133 | ||
| 133 | return NISSY_OK; | 134 | return NISSY_OK; |
| 134 | } | 135 | } |
