summaryrefslogtreecommitdiff
path: root/src/lib/dev.c
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-10-21 20:13:41 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-10-22 13:27:02 +0200
commit3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2 (patch)
tree881da180b8d801c38ba0fbad2fc9f387a70ec016 /src/lib/dev.c
parentd5a52f3951fff7ee272bd0d4cd95cd122d07fa64 (diff)
downloadouroboros-3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2.tar.gz
ouroboros-3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2.zip
build: Compile with strict conversion
This has the code checked with -Wcast-qual and -Wconversion flags. These flags were removed because SWIG generated code fails.
Diffstat (limited to 'src/lib/dev.c')
-rw-r--r--src/lib/dev.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index c349846f..86a5913e 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -285,7 +285,7 @@ void ap_fini()
for (i = 0; i < AP_MAX_FLOWS; ++i) {
if (ai.flows[i].tx_rb != NULL) {
- int idx;
+ ssize_t idx;
while ((idx = shm_rbuff_read(ai.flows[i].rx_rb)) >= 0)
shm_rdrbuff_remove(ai.rdrb, idx);
shm_rbuff_close(ai.flows[i].rx_rb);
@@ -758,7 +758,7 @@ ssize_t flow_write(int fd, void * buf, size_t count)
ssize_t flow_read(int fd, void * buf, size_t count)
{
- int idx = -1;
+ ssize_t idx = -1;
ssize_t n;
uint8_t * sdu;
@@ -797,7 +797,7 @@ ssize_t flow_read(int fd, void * buf, size_t count)
return -1;
}
- memcpy(buf, sdu, MIN(n, (ssize_t) count));
+ memcpy(buf, sdu, MIN((size_t) n, count));
shm_rdrbuff_remove(ai.rdrb, idx);
@@ -952,7 +952,7 @@ int flow_event_wait(struct flow_set * set,
struct fqueue * fq,
const struct timespec * timeout)
{
- int ret;
+ ssize_t ret;
if (set == NULL)
return -EINVAL;
@@ -964,9 +964,6 @@ int flow_event_wait(struct flow_set * set,
if (ret == -ETIMEDOUT)
return -ETIMEDOUT;
- if (ret < 0)
- return ret;
-
fq->fqsize = ret;
fq->next = 0;
@@ -1217,7 +1214,7 @@ int ipcp_flow_alloc_reply(int fd, int response)
int ipcp_flow_read(int fd, struct shm_du_buff ** sdb)
{
- int idx = -1;
+ ssize_t idx = -1;
int port_id = -1;
pthread_rwlock_rdlock(&ai.data_lock);
@@ -1252,7 +1249,7 @@ int ipcp_flow_read(int fd, struct shm_du_buff ** sdb)
int ipcp_flow_write(int fd, struct shm_du_buff * sdb)
{
- ssize_t idx;
+ size_t idx;
if (sdb == NULL)
return -EINVAL;
@@ -1288,7 +1285,7 @@ ssize_t local_flow_read(int fd)
return shm_rbuff_read(ai.flows[fd].rx_rb);
}
-int local_flow_write(int fd, ssize_t idx)
+int local_flow_write(int fd, size_t idx)
{
if (fd < 0)
return -EINVAL;
@@ -1326,6 +1323,12 @@ int ipcp_read_shim(int fd, struct shm_du_buff ** sdb)
}
idx = shm_rbuff_read(ai.flows[fd].rx_rb);
+ if (idx < 0) {
+ pthread_rwlock_unlock(&ai.flows_lock);
+ pthread_rwlock_unlock(&ai.data_lock);
+ return -EAGAIN;
+ }
+
*sdb = shm_rdrbuff_get(ai.rdrb, idx);
pthread_rwlock_unlock(&ai.flows_lock);