aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-01-07 20:40:44 +0100
committerDavid Robillard <d@drobilla.net>2019-04-13 19:48:23 +0200
commit5d0befa7dd144fc242a96c8bfa4f9233306f2c21 (patch)
tree09a67d7abb84ec7a18121444dc57dbd11a5e215a
parent5ff537bdaf77f0bd8bc7393f8315d91c220f939e (diff)
downloadserd-5d0befa7dd144fc242a96c8bfa4f9233306f2c21.tar.gz
serd-5d0befa7dd144fc242a96c8bfa4f9233306f2c21.tar.bz2
serd-5d0befa7dd144fc242a96c8bfa4f9233306f2c21.zip
Fix MSVC warnings about integer literal conversions
-rw-r--r--src/model.c6
-rw-r--r--src/n3.c6
-rw-r--r--src/reader.c2
-rw-r--r--src/serdi.c10
-rw-r--r--tests/model_test.c4
5 files changed, 14 insertions, 14 deletions
diff --git a/src/model.c b/src/model.c
index 15234e45..3de53c9f 100644
--- a/src/model.c
+++ b/src/model.c
@@ -111,9 +111,9 @@ serd_model_best_index(const SerdModel* model,
{
const bool graph_search = (pat[SERD_GRAPH] != 0);
- const unsigned sig = ((pat[0] ? 1 : 0) * 0x100 +
- (pat[1] ? 1 : 0) * 0x010 +
- (pat[2] ? 1 : 0) * 0x001);
+ const unsigned sig = ((pat[0] ? 1U : 0U) * 0x100 +
+ (pat[1] ? 1U : 0U) * 0x010 +
+ (pat[2] ? 1U : 0U) * 0x001);
SerdOrder good[2] = { (SerdOrder)-1, (SerdOrder)-1 };
diff --git a/src/n3.c b/src/n3.c
index fe11bcfe..ac217c18 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -108,17 +108,17 @@ read_UCHAR(SerdReader* reader, SerdNode* dest, uint32_t* char_code)
uint32_t c = code;
switch (size) {
case 4:
- buf[3] = 0x80 | (uint8_t)(c & 0x3F);
+ buf[3] = 0x80U | (uint8_t)(c & 0x3F);
c >>= 6;
c |= (16 << 12); // set bit 4
// fallthru
case 3:
- buf[2] = 0x80 | (uint8_t)(c & 0x3F);
+ buf[2] = 0x80U | (uint8_t)(c & 0x3F);
c >>= 6;
c |= (32 << 6); // set bit 5
// fallthru
case 2:
- buf[1] = 0x80 | (uint8_t)(c & 0x3F);
+ buf[1] = 0x80U | (uint8_t)(c & 0x3F);
c >>= 6;
c |= 0xC0; // set bits 6 and 7
// fallthru
diff --git a/src/reader.c b/src/reader.c
index 8b79e2e0..c685060d 100644
--- a/src/reader.c
+++ b/src/reader.c
@@ -267,7 +267,7 @@ serd_reader_start_file(SerdReader* reader, const char* uri, bool bulk)
(SerdStreamCloseFunc)fclose,
fd,
name,
- bulk ? SERD_PAGE_SIZE : 1);
+ bulk ? SERD_PAGE_SIZE : 1U);
serd_node_free(name);
return st;
}
diff --git a/src/serdi.c b/src/serdi.c
index 9a1a1848..ce76b88d 100644
--- a/src/serdi.c
+++ b/src/serdi.c
@@ -210,13 +210,13 @@ main(int argc, char** argv)
SerdWorld* world = serd_world_new();
SerdEnv* env = serd_env_new(base);
- const SerdWriterFlags writer_flags = (ascii ? SERD_STYLE_ASCII : 0);
+ const SerdWriterFlags writer_flags = (ascii ? SERD_STYLE_ASCII : 0U);
const SerdSerialisationFlags serialisation_flags =
- no_inline ? SERD_NO_INLINE_OBJECTS : 0;
+ no_inline ? SERD_NO_INLINE_OBJECTS : 0U;
SerdByteSink* byte_sink = serd_byte_sink_new(
- (SerdWriteFunc)fwrite, out_fd, bulk_write ? 4096 : 1);
+ (SerdWriteFunc)fwrite, out_fd, bulk_write ? 4096U : 1U);
SerdWriter* writer = serd_writer_new(world,
output_syntax,
@@ -231,8 +231,8 @@ main(int argc, char** argv)
const SerdSink* sink = NULL;
if (use_model) {
const SerdModelFlags flags =
- SERD_INDEX_SPO | (input_has_graphs ? SERD_INDEX_GRAPHS : 0) |
- (no_inline ? 0 : SERD_INDEX_OPS);
+ SERD_INDEX_SPO | (input_has_graphs ? SERD_INDEX_GRAPHS : 0U) |
+ (no_inline ? 0U : SERD_INDEX_OPS);
model = serd_model_new(world, flags);
inserter = serd_inserter_new(model, env, NULL);
sink = serd_inserter_get_sink(inserter);
diff --git a/tests/model_test.c b/tests/model_test.c
index 952f8026..60dc4579 100644
--- a/tests/model_test.c
+++ b/tests/model_test.c
@@ -572,7 +572,7 @@ static int
test_triple_index_read(SerdWorld* world, const size_t n_quads)
{
for (unsigned i = 0; i < 6; ++i) {
- SerdModel* model = serd_model_new(world, (1 << i));
+ SerdModel* model = serd_model_new(world, (1U << i));
generate(world, model, n_quads, 0);
assert(!test_read(world, model, 0, n_quads));
serd_model_free(model);
@@ -585,7 +585,7 @@ static int
test_quad_index_read(SerdWorld* world, const size_t n_quads)
{
for (unsigned i = 0; i < 6; ++i) {
- SerdModel* model = serd_model_new(world, (1 << i) | SERD_INDEX_GRAPHS);
+ SerdModel* model = serd_model_new(world, (1U << i) | SERD_INDEX_GRAPHS);
const SerdNode* graph = uri(world, 42);
generate(world, model, n_quads, graph);
assert(!test_read(world, model, graph, n_quads));