summaryrefslogtreecommitdiff
path: root/src/irmd
diff options
context:
space:
mode:
authordimitri staessens <[email protected]>2016-10-21 20:13:41 +0200
committerdimitri staessens <[email protected]>2016-10-22 13:27:02 +0200
commit3cafbf3cfe5c58a6988dbfc4c29148ebb804f5c2 (patch)
tree881da180b8d801c38ba0fbad2fc9f387a70ec016 /src/irmd
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/irmd')
-rw-r--r--src/irmd/irm_flow.h2
-rw-r--r--src/irmd/main.c40
-rw-r--r--src/irmd/registry.c2
3 files changed, 32 insertions, 12 deletions
diff --git a/src/irmd/irm_flow.h b/src/irmd/irm_flow.h
index 507295bd..40a6bb8d 100644
--- a/src/irmd/irm_flow.h
+++ b/src/irmd/irm_flow.h
@@ -56,7 +56,7 @@ struct irm_flow {
pthread_mutex_t state_lock;
};
-struct irm_flow * irm_flow_create();
+struct irm_flow * irm_flow_create(void);
void irm_flow_destroy(struct irm_flow * f);
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 12da81aa..4dee4b91 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -129,7 +129,7 @@ static struct irm_flow * get_irm_flow_n(pid_t n_api)
return NULL;
}
-static struct ipcp_entry * ipcp_entry_create()
+static struct ipcp_entry * ipcp_entry_create(void)
{
struct ipcp_entry * e = malloc(sizeof(*e));
if (e == NULL)
@@ -694,7 +694,7 @@ static int unbind_api(pid_t api, char * name)
static ssize_t list_ipcps(char * name, pid_t ** apis)
{
struct list_head * pos = NULL;
- ssize_t count = 0;
+ size_t count = 0;
int i = 0;
pthread_rwlock_rdlock(&irmd->state_lock);
@@ -1163,10 +1163,18 @@ static struct irm_flow * flow_alloc(pid_t api,
pthread_rwlock_wrlock(&irmd->flows_lock);
port_id = f->port_id = bmp_allocate(irmd->port_ids);
- f->n_1_api = ipcp;
+ if (!bmp_is_id_valid(irmd->port_ids, (ssize_t) port_id)) {
+ pthread_rwlock_unlock(&irmd->flows_lock);
+ pthread_rwlock_unlock(&irmd->state_lock);
+ LOG_ERR("Could not allocate port_id.");
+ irm_flow_destroy(f);
+ return NULL;
+ }
+ f->n_1_api = ipcp;
f->n_rb = shm_rbuff_create(api, port_id);
if (f->n_rb == NULL) {
+ bmp_release(irmd->port_ids, port_id);
pthread_rwlock_unlock(&irmd->flows_lock);
pthread_rwlock_unlock(&irmd->state_lock);
LOG_ERR("Could not create ringbuffer for AP-I %d.", api);
@@ -1176,6 +1184,7 @@ static struct irm_flow * flow_alloc(pid_t api,
f->n_1_rb = shm_rbuff_create(ipcp, port_id);
if (f->n_1_rb == NULL) {
+ bmp_release(irmd->port_ids, port_id);
pthread_rwlock_unlock(&irmd->flows_lock);
pthread_rwlock_unlock(&irmd->state_lock);
LOG_ERR("Could not create ringbuffer for AP-I %d.", ipcp);
@@ -1461,6 +1470,13 @@ static struct irm_flow * flow_req_arr(pid_t api,
pthread_rwlock_wrlock(&irmd->flows_lock);
f->port_id = bmp_allocate(irmd->port_ids);
+ if (!bmp_is_id_valid(irmd->port_ids, f->port_id)) {
+ pthread_rwlock_unlock(&irmd->flows_lock);
+ pthread_rwlock_unlock(&irmd->state_lock);
+ LOG_ERR("Could not create ringbuffer for AP-I %d.", f->n_api);
+ irm_flow_destroy(f);
+ return NULL;
+ }
f->n_rb = shm_rbuff_create(f->n_api, f->port_id);
if (f->n_rb == NULL) {
@@ -1546,7 +1562,7 @@ static int flow_alloc_reply(int port_id, int response)
return 0;
}
-static void irm_destroy()
+static void irm_destroy(void)
{
struct list_head * p;
struct list_head * h;
@@ -1653,7 +1669,7 @@ void irmd_sig_handler(int sig, siginfo_t * info, void * c)
}
}
-void * irm_sanitize()
+void * irm_sanitize(void * o)
{
struct timespec now;
struct list_head * p = NULL;
@@ -1663,6 +1679,8 @@ void * irm_sanitize()
IRMD_CLEANUP_TIMER % BILLION};
int s;
+ (void) o;
+
while (true) {
if (clock_gettime(CLOCK_MONOTONIC, &now) < 0)
LOG_WARN("Failed to get time.");
@@ -1762,10 +1780,12 @@ void * irm_sanitize()
}
}
-void * mainloop()
+void * mainloop(void * o)
{
uint8_t buf[IRM_MSG_BUF_SIZE];
+ (void) o;
+
while (true) {
int cli_sockfd;
irm_msg_t * msg;
@@ -1971,7 +1991,7 @@ void * mainloop()
return (void *) 0;
}
-static int irm_create()
+static int irm_create(void)
{
struct stat st = {0};
struct timeval timeout = {(IRMD_ACCEPT_TIMEOUT / 1000),
@@ -2057,7 +2077,7 @@ static int irm_create()
if (kill(lockfile_owner(irmd->lf), 0) < 0) {
LOG_INFO("IRMd didn't properly shut down last time.");
/* FIXME: do this for each QOS_CUBE in the system */
- shm_rdrbuff_destroy(shm_rdrbuff_open(QOS_CUBE_BE));
+ shm_rdrbuff_destroy(shm_rdrbuff_open());
LOG_INFO("Stale resources cleaned");
lockfile_destroy(irmd->lf);
irmd->lf = lockfile_create();
@@ -2076,7 +2096,7 @@ static int irm_create()
}
/* FIXME: create an rdrb for each QOS_CUBE in the system */
- if ((irmd->rdrb = shm_rdrbuff_create(QOS_CUBE_BE)) == NULL) {
+ if ((irmd->rdrb = shm_rdrbuff_create()) == NULL) {
irm_destroy();
return -1;
}
@@ -2088,7 +2108,7 @@ static int irm_create()
return 0;
}
-static void usage()
+static void usage(void)
{
LOG_ERR("Usage: irmd \n\n"
" [--stdout (Print to stdout instead of logs)]\n");
diff --git a/src/irmd/registry.c b/src/irmd/registry.c
index f57d833a..9442f3db 100644
--- a/src/irmd/registry.c
+++ b/src/irmd/registry.c
@@ -42,7 +42,7 @@ struct reg_dif {
enum ipcp_type type;
};
-static struct reg_entry * reg_entry_create()
+static struct reg_entry * reg_entry_create(void)
{
struct reg_entry * e = malloc(sizeof(*e));
if (e == NULL)