Browse Source

Fix -Wconversion warnings in headers.

zrythm_meson
David Robillard 9 years ago
parent
commit
0824237942
  1. 5
      lv2/lv2plug.in/ns/ext/atom/forge.h
  2. 8
      lv2/lv2plug.in/ns/ext/atom/util.h
  3. 33
      lv2/lv2plug.in/ns/ext/event/event-helpers.h
  4. 2
      lv2/lv2plug.in/ns/meta/meta.ttl
  5. 2
      plugins/eg02-midigate.lv2/midigate.c
  6. 8
      plugins/eg03-metro.lv2/metro.c
  7. 12
      plugins/eg04-sampler.lv2/sampler.c
  8. 2
      plugins/eg04-sampler.lv2/uris.h
  9. 3
      wscript

5
lv2/lv2plug.in/ns/ext/atom/forge.h

@ -248,7 +248,7 @@ static inline void @@ -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) @@ -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);
}
}

8
lv2/lv2plug.in/ns/ext/atom/util.h

@ -41,14 +41,14 @@ extern "C" { @@ -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) @@ -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));
}
/**

33
lv2/lv2plug.in/ns/ext/event/event-helpers.h

@ -50,7 +50,7 @@ extern "C" { @@ -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) @@ -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) @@ -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, @@ -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, @@ -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, @@ -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, @@ -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;
}

2
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 @@ -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."
]
]
] , [

2
plugins/eg02-midigate.lv2/midigate.c

@ -173,7 +173,7 @@ run(LV2_Handle instance, uint32_t sample_count) @@ -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);

8
plugins/eg03-metro.lv2/metro.c

@ -179,17 +179,17 @@ instantiate(const LV2_Descriptor* descriptor, @@ -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;

12
plugins/eg04-sampler.lv2/sampler.c

@ -48,10 +48,10 @@ enum { @@ -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 { @@ -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) @@ -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;

2
plugins/eg04-sampler.lv2/uris.h

@ -72,7 +72,7 @@ static inline LV2_Atom* @@ -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(

3
wscript

@ -47,6 +47,9 @@ def configure(conf): @@ -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

Loading…
Cancel
Save