summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-07-05 20:39:01 -0400
committerDavid Robillard <d@drobilla.net>2022-07-17 17:31:56 -0400
commitc6f05ca4a012642012235e67da166f9833f6c56b (patch)
treea10f49e9e7d951ba34e2c19a64150b3065087e9e
parent9abde85ec5ac5be7978c9d23aa7554e8aa37a74b (diff)
downloadsord-c6f05ca4a012642012235e67da166f9833f6c56b.tar.gz
sord-c6f05ca4a012642012235e67da166f9833f6c56b.tar.bz2
sord-c6f05ca4a012642012235e67da166f9833f6c56b.zip
Fix conversion warnings
-rw-r--r--src/sord.c2
-rw-r--r--src/sord_test.c17
-rw-r--r--src/sord_validate.c17
3 files changed, 19 insertions, 17 deletions
diff --git a/src/sord.c b/src/sord.c
index f447627..4ca022f 100644
--- a/src/sord.c
+++ b/src/sord.c
@@ -1351,7 +1351,7 @@ sord_erase(SordModel* model, SordIter* iter)
if (zix_btree_remove(model->indices[i],
tup,
(void**)&quad,
- i == iter->order ? &iter->cur : NULL)) {
+ (SordOrder)i == iter->order ? &iter->cur : NULL)) {
return (i == 0) ? SERD_ERR_NOT_FOUND : SERD_ERR_INTERNAL;
}
}
diff --git a/src/sord_test.c b/src/sord_test.c
index 6b38ef7..e451049 100644
--- a/src/sord_test.c
+++ b/src/sord_test.c
@@ -43,15 +43,14 @@ typedef struct {
#define USTR(s) ((const uint8_t*)(s))
static SordNode*
-uri(SordWorld* world, int num)
+uri(SordWorld* world, unsigned num)
{
if (num == 0) {
return 0;
}
- char str[] = "eg:000";
- char* uri_num = str + 3; // First `0'
- snprintf(uri_num, DIGITS + 1, "%0*d", DIGITS, num);
+ char str[16];
+ snprintf(str, sizeof(str), "eg:%0*u", DIGITS, num);
return sord_new_uri(world, (const uint8_t*)str);
}
@@ -68,15 +67,15 @@ test_fail(const char* fmt, ...)
}
static int
-generate(SordWorld* world, SordModel* sord, size_t n_quads, SordNode* graph)
+generate(SordWorld* world, SordModel* sord, unsigned n_quads, SordNode* graph)
{
fprintf(stderr,
- "Generating %zu (S P *) quads with %u objects each\n",
+ "Generating %u (S P *) quads with %u objects each\n",
n_quads,
N_OBJECTS_PER);
- for (size_t i = 0; i < n_quads; ++i) {
- int num = (i * N_OBJECTS_PER) + 1;
+ for (unsigned i = 0; i < n_quads; ++i) {
+ unsigned num = (i * N_OBJECTS_PER) + 1;
SordNode* ids[2 + N_OBJECTS_PER];
for (unsigned j = 0; j < 2 + N_OBJECTS_PER; ++j) {
@@ -400,7 +399,7 @@ finished(SordWorld* world, SordModel* sord, int status)
int
main(void)
{
- static const size_t n_quads = 300;
+ static const unsigned n_quads = 300U;
sord_free(NULL); // Shouldn't crash
diff --git a/src/sord_validate.c b/src/sord_validate.c
index e30924a..e5b6b25 100644
--- a/src/sord_validate.c
+++ b/src/sord_validate.c
@@ -29,9 +29,9 @@
# include <windows.h>
#endif
+#include <inttypes.h>
#include <stdarg.h>
#include <stdbool.h>
-#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -209,7 +209,8 @@ regexp_match(const uint8_t* pat, const char* str)
return false;
}
- const bool ret = pcre_exec(re, NULL, str, strlen(str), 0, 0, NULL, 0) >= 0;
+ const bool ret =
+ pcre_exec(re, NULL, str, (int)strlen(str), 0, 0, NULL, 0) >= 0;
pcre_free(re);
return ret;
#endif // USE_PCRE
@@ -496,18 +497,19 @@ check_properties(SordModel* model, URIs* uris)
if (is_FunctionalProperty) {
SordIter* o = sord_search(model, subj, pred, NULL, NULL);
- const unsigned n = count_non_blanks(o, SORD_OBJECT);
+ const uint64_t n = count_non_blanks(o, SORD_OBJECT);
if (n > 1) {
- st = errorf(quad, "Functional property with %u objects", n);
+ st = errorf(quad, "Functional property with %" PRIu64 " objects", n);
}
sord_iter_free(o);
}
if (is_InverseFunctionalProperty) {
SordIter* s = sord_search(model, NULL, pred, obj, NULL);
- const unsigned n = count_non_blanks(s, SORD_SUBJECT);
+ const uint64_t n = count_non_blanks(s, SORD_SUBJECT);
if (n > 1) {
- st = errorf(quad, "Inverse functional property with %u subjects", n);
+ st = errorf(
+ quad, "Inverse functional property with %" PRIu64 " subjects", n);
}
sord_iter_free(s);
}
@@ -564,7 +566,8 @@ check_instance(SordModel* model,
return 0;
}
- const unsigned values = sord_count(model, instance, prop, NULL, NULL);
+ const unsigned values =
+ (unsigned)sord_count(model, instance, prop, NULL, NULL);
// Check exact cardinality
const SordNode* card =