diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/instance_name.c | 26 | ||||
-rw-r--r-- | src/lib/irm.c | 27 |
2 files changed, 16 insertions, 37 deletions
diff --git a/src/lib/instance_name.c b/src/lib/instance_name.c index 1e61f790..0f666211 100644 --- a/src/lib/instance_name.c +++ b/src/lib/instance_name.c @@ -86,7 +86,7 @@ instance_name_t * instance_name_init_from(instance_name_t * dst, } instance_name_t * instance_name_init_with(instance_name_t * dst, - char * name, + char * name, uint16_t id) { if (dst == NULL) @@ -103,13 +103,11 @@ instance_name_t * instance_name_init_with(instance_name_t * dst, void instance_name_fini(instance_name_t * n) { - if (n == NULL) + if (n == NULL || n->name == NULL) return; - if (n->name != NULL) { - free(n->name); - n->name = NULL; - } + free(n->name); + n->name = NULL; } void instance_name_destroy(instance_name_t * ptr) @@ -122,17 +120,15 @@ void instance_name_destroy(instance_name_t * ptr) free(ptr); } -int instance_name_cpy(const instance_name_t * src, - instance_name_t * dst) +int instance_name_cpy(instance_name_t * dst, + const instance_name_t * src) { instance_name_t * res; if (src == NULL || dst == NULL) return -1; - res = instance_name_init_from(dst, - src->name, - src->id); + res = instance_name_init_from(dst, src->name, src->id); if (res == NULL) return -1; @@ -150,7 +146,7 @@ instance_name_t * instance_name_dup(const instance_name_t * src) if (tmp == NULL) return NULL; - if (instance_name_cpy(src, tmp)) { + if (instance_name_cpy(tmp, src)) { instance_name_destroy(tmp); return NULL; } @@ -160,9 +156,7 @@ instance_name_t * instance_name_dup(const instance_name_t * src) bool instance_name_is_valid(const instance_name_t * n) { - return (n != NULL && - n->name != NULL && - strlen(n->name)); + return (n != NULL && n->name != NULL && strlen(n->name)); } int instance_name_cmp(const instance_name_t * a, @@ -205,7 +199,7 @@ char * instance_name_to_string(const instance_name_t * n) if (n == NULL) return NULL; - size = 0; + size = 0; size += (n->name != NULL ? strlen(n->name) : none_len); diff --git a/src/lib/irm.c b/src/lib/irm.c index af899d0a..644e1113 100644 --- a/src/lib/irm.c +++ b/src/lib/irm.c @@ -35,10 +35,7 @@ int irm_create_ipcp(instance_name_t * api, { irm_msg_t msg = IRM_MSG__INIT; - if (api == NULL) - return -EINVAL; - - if (ipcp_type == NULL || api == NULL) + if (api == NULL || ipcp_type == NULL || api->name == NULL) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_CREATE_IPCP; @@ -59,12 +56,8 @@ int irm_destroy_ipcp(instance_name_t * api) { irm_msg_t msg = IRM_MSG__INIT; - if (api == NULL) - return -EINVAL; - - if (api->name == NULL) { + if (api == NULL || api->name == NULL) return -EINVAL; - } msg.code = IRM_MSG_CODE__IRM_DESTROY_IPCP; msg.ap_name = api->name; @@ -84,10 +77,7 @@ int irm_bootstrap_ipcp(instance_name_t * api, { irm_msg_t msg = IRM_MSG__INIT; - if (api == NULL) - return -EINVAL; - - if (api->name == NULL || conf == NULL) + if (api == NULL || api->name == NULL || conf == NULL) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_BOOTSTRAP_IPCP; @@ -108,10 +98,7 @@ int irm_enroll_ipcp(instance_name_t * api, { irm_msg_t msg = IRM_MSG__INIT; - if (api == NULL) - return -EINVAL; - - if (api->name == NULL || dif_name == NULL) + if (api == NULL || api->name == NULL || dif_name == NULL) return -EINVAL; msg.code = IRM_MSG_CODE__IRM_ENROLL_IPCP; @@ -171,10 +158,8 @@ int irm_unreg_ipcp(const instance_name_t * api, { irm_msg_t msg = IRM_MSG__INIT; - if (api == NULL) - return -EINVAL; - - if (api->name == NULL || + if (api == NULL || + api->name == NULL || difs == NULL || difs_size == 0 || difs[0] == NULL) { |