summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ipcpd/shim-udp/main.c24
-rw-r--r--src/irmd/main.c16
2 files changed, 23 insertions, 17 deletions
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index a65aa11d..f67c66ca 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -66,7 +66,7 @@ struct ipcp * _ipcp;
#endif
struct ipcp_udp_data {
- /* IPCP_DATA STRUCT MUST BE FIRST!! */
+ /* keep ipcp_data first for polymorphism */
struct ipcp_data ipcp_data;
uint32_t ip_addr;
@@ -83,7 +83,7 @@ struct ipcp_udp_data {
};
struct udp_flow {
- /* FLOW MUST BE FIRST !!!! */
+ /* keep flow first for polymorphism */
flow_t flow;
int fd;
};
@@ -120,7 +120,7 @@ struct ipcp_udp_data * ipcp_udp_data_create(char * ap_name,
}
instance_name = instance_name_init_with(
- instance_name, ap_name, (uint16_t)atoi(ap_id));
+ instance_name, ap_name, (uint16_t) atoi(ap_id));
if (instance_name == NULL) {
LOG_ERR("Failed to create instance name struct.");
@@ -169,7 +169,7 @@ static void * ipcp_udp_listener()
continue;
/* flow alloc request from other host */
- hostp = gethostbyaddr((const char *)&c_saddr.sin_addr.s_addr,
+ hostp = gethostbyaddr((const char *) &c_saddr.sin_addr.s_addr,
sizeof(c_saddr.sin_addr.s_addr), AF_INET);
if (hostp == NULL)
continue;
@@ -185,7 +185,7 @@ static void * ipcp_udp_listener()
continue;
}
- memset((char *)&f_saddr, 0, sizeof f_saddr);
+ memset((char *) &f_saddr, 0, sizeof f_saddr);
f_saddr.sin_family = AF_INET;
f_saddr.sin_addr.s_addr = local_ip;
@@ -203,7 +203,7 @@ static void * ipcp_udp_listener()
*/
if (connect(flow->fd,
- (struct sockaddr *)&c_saddr, sizeof c_saddr) < 0) {
+ (struct sockaddr *) &c_saddr, sizeof c_saddr) < 0) {
close(flow->fd);
free(flow);
continue;
@@ -283,7 +283,7 @@ static void * ipcp_udp_sdu_reader()
flow = shim_data(_ipcp)->fd_to_flow_ptr[fd];
if (flow->state == FLOW_PENDING) {
if (connect(fd,
- (struct sockaddr *)&r_saddr,
+ (struct sockaddr *) &r_saddr,
sizeof r_saddr)
< 0)
continue;
@@ -344,7 +344,7 @@ int ipcp_udp_bootstrap(struct dif_config * conf)
shim_data(_ipcp)->s_saddr.sin_port = LISTEN_PORT;
if (bind(shim_data(_ipcp)->s_fd,
- (struct sockaddr *)&shim_data(_ipcp)->s_saddr,
+ (struct sockaddr *) &shim_data(_ipcp)->s_saddr,
sizeof shim_data(_ipcp)->s_saddr ) < 0) {
LOG_ERR("Couldn't bind to %s.", ipstr);
return -1;
@@ -436,7 +436,7 @@ int ipcp_udp_flow_alloc(uint32_t port_id,
}
/* this socket is for the flow */
- memset((char *)&l_saddr, 0, sizeof l_saddr);
+ memset((char *) &l_saddr, 0, sizeof l_saddr);
l_saddr.sin_family = AF_INET;
l_saddr.sin_addr.s_addr = local_ip;
l_saddr.sin_port = 0;
@@ -458,7 +458,7 @@ int ipcp_udp_flow_alloc(uint32_t port_id,
LOG_MISSING;
- memset((char *)&r_saddr, 0, sizeof r_saddr);
+ memset((char *) &r_saddr, 0, sizeof r_saddr);
r_saddr.sin_family = AF_INET;
/* FIXME: pull in correct IP address */
r_saddr.sin_addr.s_addr = IP_ADDR; /* FIXME */
@@ -476,7 +476,7 @@ int ipcp_udp_flow_alloc(uint32_t port_id,
pthread_mutex_lock(&_ipcp->data->flow_lock);
- if(ipcp_data_add_flow(_ipcp->data, (flow_t *)flow)) {
+ if(ipcp_data_add_flow(_ipcp->data, (flow_t *) flow)) {
LOG_DBGF("Could not add flow.");
pthread_mutex_unlock(&_ipcp->data->flow_lock);
close(flow->fd);
@@ -609,7 +609,7 @@ int main (int argc, char * argv[])
irmd_pid = atoi(argv[1]);
/* init sig_act */
- memset (&sig_act, 0, sizeof sig_act);
+ memset(&sig_act, 0, sizeof sig_act);
/* install signal traps */
sig_act.sa_sigaction = &ipcp_sig_handler;
diff --git a/src/irmd/main.c b/src/irmd/main.c
index fcd93bd5..df3070f4 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -404,7 +404,7 @@ static int ap_unreg_id(uint32_t reg_ap_id,
struct reg_name_entry * rne = NULL;
struct list_head * pos = NULL;
- rne = find_reg_name_entry_by_id (reg_ap_id);
+ rne = find_reg_name_entry_by_id(reg_ap_id);
if (rne == NULL)
return 0; /* no such id */
@@ -522,7 +522,9 @@ static int ap_reg(char * ap_name,
return -1;
}
/* for now, we register single instances */
- reg_name_entry_add_name_instance(strdup(ap_name), instance_name_dup(api));
+ reg_name_entry_add_name_instance(strdup(ap_name),
+ instance_name_dup(api));
+ instance_name_destroy(api);
return reg_ap_id;
}
@@ -535,6 +537,8 @@ static int ap_unreg(char * ap_name,
struct reg_name_entry * tmp = NULL;
instance_name_t * api = instance_name_create();
+ if (api == NULL)
+ return -1;
if (instance_name_init_from(api, ap_name, ap_id) == NULL) {
instance_name_destroy(api);
return -1;
@@ -542,10 +546,12 @@ static int ap_unreg(char * ap_name,
/* check if ap_name is registered */
tmp = find_reg_name_entry_by_name(api->name);
- if (tmp == NULL)
+ if (tmp == NULL) {
+ instance_name_destroy(api);
return 0;
- else
+ } else {
return ap_unreg_id(tmp->reg_ap_id, api->id, difs, len);
+ }
}
@@ -629,7 +635,7 @@ int main()
struct sigaction sig_act;
/* init sig_act */
- memset (&sig_act, 0, sizeof sig_act);
+ memset(&sig_act, 0, sizeof sig_act);
/* install signal traps */
sig_act.sa_sigaction = &irmd_sig_handler;