From 53dc68c8a5a3edb904ca937dada67380701f18b0 Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 14 Nov 2011 22:58:53 +1100 Subject: small cleanups --- lib/avp.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/avp.c b/lib/avp.c index 5af6129..6f30d4c 100644 --- a/lib/avp.c +++ b/lib/avp.c @@ -25,14 +25,19 @@ rs_avp_free (rs_avp **vps) size_t rs_avp_length (rs_const_avp *vp) { - assert (vp != NULL); + if (vp == NULL) + return 0; + return vp->length; } rs_attr_type_t rs_avp_typeof (rs_const_avp *vp) { - return vp ? vp->da->type : RS_TYPE_INVALID; + if (vp == NULL) + return RS_TYPE_INVALID; + + return vp->da->type; } void @@ -40,6 +45,8 @@ rs_avp_attrid (rs_const_avp *vp, unsigned int *attr, unsigned int *vendor) { + assert (vp != NULL); + *attr = vp->da->attr; *vendor = vp->da->vendor; } @@ -47,7 +54,7 @@ rs_avp_attrid (rs_const_avp *vp, const char * rs_avp_name (rs_const_avp *vp) { - return vp ? vp->da->name : NULL; + return (vp != NULL) ? vp->da->name : NULL; } void @@ -127,15 +134,15 @@ rs_avp_dup (rs_const_avp *vp) } rs_avp * -rs_avp_next (rs_avp *avp) +rs_avp_next (rs_avp *vp) { - return avp ? avp->next : NULL; + return (vp != NULL) ? vp->next : NULL; } rs_const_avp * -rs_avp_next_const (rs_const_avp *avp) +rs_avp_next_const (rs_const_avp *vp) { - return avp ? avp->next : NULL; + return (vp != NULL) ? vp->next : NULL; } int -- cgit v1.1