aboutsummaryrefslogtreecommitdiffstats
path: root/lv2/lv2plug.in/ns/ext/event/event-helpers.h
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 /lv2/lv2plug.in/ns/ext/event/event-helpers.h
parent1cb9f77d07c998108d0ba54811ac4604a2b49725 (diff)
downloadlv2-0824237942af542431a8348c55c367242d1bf49a.tar.xz
Fix -Wconversion warnings in headers.
Diffstat (limited to 'lv2/lv2plug.in/ns/ext/event/event-helpers.h')
-rw-r--r--lv2/lv2plug.in/ns/ext/event/event-helpers.h33
1 files changed, 18 insertions, 15 deletions
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;
}