From a3a477870cdbdb4b9c4c8b403c09b13502291234 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 19 Oct 2024 19:17:13 +0200 Subject: Finished Python module --- src/nissy.c | 13 +++++++++---- src/solvers/tables.h | 3 ++- 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/nissy.c b/src/nissy.c index c5cf1d5..793d659 100644 --- a/src/nissy.c +++ b/src/nissy.c @@ -71,7 +71,10 @@ checkdata(const char *buf, const tableinfo_t *info) { uint64_t distr[INFO_DISTRIBUTION_LEN]; - if (!strncmp(info->solver, "cocsep", 6)) { + if (info == NULL) { + LOG("checkdata: error reading table info\n"); + return false; + } else if (!strncmp(info->solver, "cocsep", 6)) { getdistribution_cocsep( (uint32_t *)((char *)buf + INFOSIZE), distr); } else if (!strncmp(info->solver, "h48", 3)) { @@ -442,21 +445,23 @@ nissy_checkdata( { char *buf; tableinfo_t info; + int64_t err; for (buf = (char *)data; - readtableinfo(data_size, buf, &info); + (err = readtableinfo(data_size, buf, &info)) == NISSY_OK; buf += info.next, data_size -= info.next) { if (!checkdata(buf, &info)) { - LOG("Error: data for %s is inconsistent with info!\n", + LOG("Error: data for solver '%s' is corrupted!\n", info.solver); return NISSY_ERROR_DATA; } + if (info.next == 0) break; } - return NISSY_OK; + return err; } long long diff --git a/src/solvers/tables.h b/src/solvers/tables.h index 060b018..3147416 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h @@ -35,7 +35,8 @@ readtableinfo(uint64_t buf_size, const char *buf, tableinfo_t *info) if (buf_size < INFOSIZE) { LOG("Error reading table: buffer size is too small " - "(smaller than INFOSIZE = %" PRId64 ")\n", INFOSIZE); + "(given size %" PRIu64 " is smaller than INFOSIZE = %" + PRId64 ")\n", buf_size, INFOSIZE); return NISSY_ERROR_BUFFER_SIZE; } -- cgit v1.3