aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2014-01-24 01:49:18 +0000
committerDavid Robillard <d@drobilla.net>2014-01-24 01:49:18 +0000
commit0824237942af542431a8348c55c367242d1bf49a (patch)
treeab9afb3a202b434c2198a071bcb8336f2976f2a3
parent1cb9f77d07c998108d0ba54811ac4604a2b49725 (diff)
downloadlv2-0824237942af542431a8348c55c367242d1bf49a.tar.xz
Fix -Wconversion warnings in headers.
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/forge.h5
-rw-r--r--lv2/lv2plug.in/ns/ext/atom/util.h8
-rw-r--r--lv2/lv2plug.in/ns/ext/event/event-helpers.h33
-rw-r--r--lv2/lv2plug.in/ns/meta/meta.ttl2
-rw-r--r--plugins/eg02-midigate.lv2/midigate.c2
-rw-r--r--plugins/eg03-metro.lv2/metro.c8
-rw-r--r--plugins/eg04-sampler.lv2/sampler.c12
-rw-r--r--plugins/eg04-sampler.lv2/uris.h2
-rw-r--r--wscript3
9 files changed, 42 insertions, 33 deletions
diff --git a/lv2/lv2plug.in/ns/ext/atom/forge.h b/lv2/lv2plug.in/ns/ext/atom/forge.h
index 5fcfa38..3ee3aa7 100644
--- a/lv2/lv2plug.in/ns/ext/atom/forge.h
+++ b/lv2/lv2plug.in/ns/ext/atom/forge.h
@@ -248,7 +248,7 @@ static inline void
lv2_atom_forge_set_buffer(LV2_Atom_Forge* forge, uint8_t* buf, size_t size)
{
forge->buf = buf;
- forge->size = size;
+ forge->size = (uint32_t)size;
forge->offset = 0;
forge->deref = NULL;
forge->sink = NULL;
@@ -370,7 +370,8 @@ lv2_atom_forge_primitive(LV2_Atom_Forge* forge, const LV2_Atom* a)
if (lv2_atom_forge_top_is(forge, forge->Vector)) {
return lv2_atom_forge_raw(forge, LV2_ATOM_BODY_CONST(a), a->size);
} else {
- return lv2_atom_forge_write(forge, a, sizeof(LV2_Atom) + a->size);
+ return lv2_atom_forge_write(
+ forge, a, (uint32_t)sizeof(LV2_Atom) + a->size);
}
}
diff --git a/lv2/lv2plug.in/ns/ext/atom/util.h b/lv2/lv2plug.in/ns/ext/atom/util.h
index 97f6dfb..d306e1c 100644
--- a/lv2/lv2plug.in/ns/ext/atom/util.h
+++ b/lv2/lv2plug.in/ns/ext/atom/util.h
@@ -41,14 +41,14 @@ extern "C" {
static inline uint32_t
lv2_atom_pad_size(uint32_t size)
{
- return (size + 7) & (~7);
+ return (size + 7U) & (~7U);
}
/** Return the total size of @p atom, including the header. */
static inline uint32_t
lv2_atom_total_size(const LV2_Atom* atom)
{
- return sizeof(LV2_Atom) + atom->size;
+ return (uint32_t)sizeof(LV2_Atom) + atom->size;
}
/** Return true iff @p atom is null. */
@@ -207,8 +207,8 @@ lv2_atom_object_next(const LV2_Atom_Property_Body* i)
const LV2_Atom* const value = (const LV2_Atom*)(
(const uint8_t*)i + 2 * sizeof(uint32_t));
return (LV2_Atom_Property_Body*)(
- (const uint8_t*)i + lv2_atom_pad_size(sizeof(LV2_Atom_Property_Body)
- + value->size));
+ (const uint8_t*)i + lv2_atom_pad_size(
+ (uint32_t)sizeof(LV2_Atom_Property_Body) + value->size));
}
/**
diff --git a/lv2/lv2plug.in/ns/ext/event/event-helpers.h b/lv2/lv2plug.in/ns/ext/event/event-helpers.h
index 5420271..b748395 100644
--- a/lv2/lv2plug.in/ns/ext/event/event-helpers.h
+++ b/lv2/lv2plug.in/ns/ext/event/event-helpers.h
@@ -50,7 +50,7 @@ extern "C" {
static inline uint16_t
lv2_event_pad_size(uint16_t size)
{
- return (size + 7) & (~7);
+ return (uint16_t)(size + 7U) & (uint16_t)(~7U);
}
@@ -60,7 +60,7 @@ lv2_event_pad_size(uint16_t size)
static inline void
lv2_event_buffer_reset(LV2_Event_Buffer* buf,
uint16_t stamp_type,
- uint8_t *data)
+ uint8_t* data)
{
buf->data = data;
buf->header_size = sizeof(LV2_Event_Buffer);
@@ -130,7 +130,8 @@ lv2_event_increment(LV2_Event_Iterator* iter)
LV2_Event* const ev = (LV2_Event*)(
(uint8_t*)iter->buf->data + iter->offset);
- iter->offset += lv2_event_pad_size(sizeof(LV2_Event) + ev->size);
+ iter->offset += lv2_event_pad_size(
+ (uint16_t)((uint16_t)sizeof(LV2_Event) + ev->size));
return true;
}
@@ -190,7 +191,7 @@ lv2_event_write(LV2_Event_Iterator* iter,
memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size);
++iter->buf->event_count;
- size = lv2_event_pad_size(sizeof(LV2_Event) + size);
+ size = lv2_event_pad_size((uint16_t)(sizeof(LV2_Event) + size));
iter->buf->size += size;
iter->offset += size;
@@ -208,11 +209,12 @@ lv2_event_reserve(LV2_Event_Iterator* iter,
uint16_t type,
uint16_t size)
{
- if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size)
+ const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + size);
+ if (iter->buf->capacity - iter->buf->size < total_size)
return NULL;
- LV2_Event* const ev = (LV2_Event*)((uint8_t*)iter->buf->data +
- iter->offset);
+ LV2_Event* const ev = (LV2_Event*)(
+ (uint8_t*)iter->buf->data + iter->offset);
ev->frames = frames;
ev->subframes = subframes;
@@ -220,9 +222,9 @@ lv2_event_reserve(LV2_Event_Iterator* iter,
ev->size = size;
++iter->buf->event_count;
- size = lv2_event_pad_size(sizeof(LV2_Event) + size);
- iter->buf->size += size;
- iter->offset += size;
+ const uint16_t padded_size = lv2_event_pad_size(total_size);
+ iter->buf->size += padded_size;
+ iter->offset += padded_size;
return (uint8_t*)ev + sizeof(LV2_Event);
}
@@ -238,19 +240,20 @@ lv2_event_write_event(LV2_Event_Iterator* iter,
const LV2_Event* ev,
const uint8_t* data)
{
- if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + ev->size)
+ const uint16_t total_size = (uint16_t)(sizeof(LV2_Event) + ev->size);
+ if (iter->buf->capacity - iter->buf->size < total_size)
return false;
LV2_Event* const write_ev = (LV2_Event*)(
- (uint8_t*)iter->buf->data + iter->offset);
+ (uint8_t*)iter->buf->data + iter->offset);
*write_ev = *ev;
memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size);
++iter->buf->event_count;
- const uint16_t size = lv2_event_pad_size(sizeof(LV2_Event) + ev->size);
- iter->buf->size += size;
- iter->offset += size;
+ const uint16_t padded_size = lv2_event_pad_size(total_size);
+ iter->buf->size += padded_size;
+ iter->offset += padded_size;
return true;
}
diff --git a/lv2/lv2plug.in/ns/meta/meta.ttl b/lv2/lv2plug.in/ns/meta/meta.ttl
index 6e679cd..ecbf315 100644
--- a/lv2/lv2plug.in/ns/meta/meta.ttl
+++ b/lv2/lv2plug.in/ns/meta/meta.ttl
@@ -53,6 +53,8 @@ THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH R
dcs:changeset [
dcs:item [
rdfs:label "lv2specgen: Display deprecated warning on classes marked owl:deprecated."
+ ] , [
+ rdfs:label "Fix -Wconversion warnings in headers."
]
]
] , [
diff --git a/plugins/eg02-midigate.lv2/midigate.c b/plugins/eg02-midigate.lv2/midigate.c
index 3ed6fbf..8d2bd74 100644
--- a/plugins/eg02-midigate.lv2/midigate.c
+++ b/plugins/eg02-midigate.lv2/midigate.c
@@ -173,7 +173,7 @@ run(LV2_Handle instance, uint32_t sample_count)
}
write_output(self, offset, ev->time.frames - offset);
- offset = ev->time.frames;
+ offset = (uint32_t)ev->time.frames;
}
write_output(self, offset, sample_count - offset);
diff --git a/plugins/eg03-metro.lv2/metro.c b/plugins/eg03-metro.lv2/metro.c
index c2e18af..e7f8ead 100644
--- a/plugins/eg03-metro.lv2/metro.c
+++ b/plugins/eg03-metro.lv2/metro.c
@@ -179,17 +179,17 @@ instantiate(const LV2_Descriptor* descriptor,
// Initialise instance fields
self->rate = rate;
self->bpm = 120.0f;
- self->attack_len = attack_s * rate;
- self->decay_len = decay_s * rate;
+ self->attack_len = (uint32_t)(attack_s * rate);
+ self->decay_len = (uint32_t)(decay_s * rate);
self->state = STATE_OFF;
// Generate one cycle of a sine wave at the desired frequency
const double freq = 440.0 * 2.0;
const double amp = 0.5;
- self->wave_len = rate / freq;
+ self->wave_len = (uint32_t)(rate / freq);
self->wave = (float*)malloc(self->wave_len * sizeof(float));
for (uint32_t i = 0; i < self->wave_len; ++i) {
- self->wave[i] = sin(i * 2 * M_PI * freq / rate) * amp;
+ self->wave[i] = (float)(sin(i * 2 * M_PI * freq / rate) * amp);
}
return (LV2_Handle)self;
diff --git a/plugins/eg04-sampler.lv2/sampler.c b/plugins/eg04-sampler.lv2/sampler.c
index ee17312..54da799 100644
--- a/plugins/eg04-sampler.lv2/sampler.c
+++ b/plugins/eg04-sampler.lv2/sampler.c
@@ -48,10 +48,10 @@ enum {
static const char* default_sample_file = "click.wav";
typedef struct {
- SF_INFO info; // Info about sample from sndfile
- float* data; // Sample data in float
- char* path; // Path of file
- size_t path_len; // Length of path
+ SF_INFO info; // Info about sample from sndfile
+ float* data; // Sample data in float
+ char* path; // Path of file
+ uint32_t path_len; // Length of path
} Sample;
typedef struct {
@@ -111,7 +111,7 @@ typedef struct {
static Sample*
load_sample(Sampler* self, const char* path)
{
- const size_t path_len = strlen(path);
+ const size_t path_len = strlen(path);
lv2_log_trace(&self->logger, "Loading sample %s\n", path);
@@ -138,7 +138,7 @@ load_sample(Sampler* self, const char* path)
// Fill sample struct and return it
sample->data = data;
sample->path = (char*)malloc(path_len + 1);
- sample->path_len = path_len;
+ sample->path_len = (uint32_t)path_len;
memcpy(sample->path, path, path_len + 1);
return sample;
diff --git a/plugins/eg04-sampler.lv2/uris.h b/plugins/eg04-sampler.lv2/uris.h
index c981f9e..f9aa5a7 100644
--- a/plugins/eg04-sampler.lv2/uris.h
+++ b/plugins/eg04-sampler.lv2/uris.h
@@ -72,7 +72,7 @@ static inline LV2_Atom*
write_set_file(LV2_Atom_Forge* forge,
const SamplerURIs* uris,
const char* filename,
- const size_t filename_len)
+ const uint32_t filename_len)
{
LV2_Atom_Forge_Frame frame;
LV2_Atom* set = (LV2_Atom*)lv2_atom_forge_object(
diff --git a/wscript b/wscript
index b85c4c7..30a675a 100644
--- a/wscript
+++ b/wscript
@@ -47,6 +47,9 @@ def configure(conf):
autowaf.configure(conf)
autowaf.set_c99_mode(conf)
+ if Options.options.ultra_strict:
+ conf.env.append_value('CFLAGS', ['-Wconversion'])
+
if Options.platform == 'win32' or not hasattr(os.path, 'relpath'):
Logs.warn('System does not support linking headers, copying')
Options.options.copy_headers = True