Skip to content

Commit 8a0d45f

Browse files
davidtrihy-genesysbenceszigeti
authored andcommitted
Inline return of Contact header status
1 parent 1714b3d commit 8a0d45f

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

modules/sipmsgops/sipmsgops.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,13 +1622,11 @@ static enum sip_validation_failures validate_contact_header(struct sip_msg *msg,
16221622
contact_t * contacts = NULL;
16231623
exp_body_t *expires_body = NULL;
16241624
struct sip_uri test_contacts;
1625-
enum sip_validation_failures ret = SV_NO_ERROR;
16261625

16271626
if (method & METHOD_WITH_CONTACT_HDR) {
16281627
if (!msg->contact) {
16291628
strcpy(reason, "SIP message doesn't have 'Contact' header");
1630-
ret = SV_NO_CONTACT;
1631-
goto failed;
1629+
return SV_NO_CONTACT;
16321630
}
16331631

16341632
/* iterate through Contact headers */
@@ -1637,8 +1635,7 @@ static enum sip_validation_failures validate_contact_header(struct sip_msg *msg,
16371635
if (!ptr->parsed && (parse_contact(ptr) < 0
16381636
|| !ptr->parsed)) {
16391637
strcpy(reason, "failed to parse 'Contact' header");
1640-
ret = SV_CONTACT_PARSE_ERROR;
1641-
goto failed;
1638+
return SV_CONTACT_PARSE_ERROR;
16421639
}
16431640
contacts = ((contact_body_t*)ptr->parsed)->contacts;
16441641

@@ -1649,43 +1646,37 @@ static enum sip_validation_failures validate_contact_header(struct sip_msg *msg,
16491646
&test_contacts) < 0
16501647
|| test_contacts.host.len < 0) {
16511648
strcpy(reason, "failed to parse 'Contact' header");
1652-
ret = SV_CONTACT_PARSE_ERROR;
1653-
goto failed;
1649+
return SV_CONTACT_PARSE_ERROR;
16541650
}
16551651
}
16561652
} else {
16571653
/* This is a star Contact header, valid only for REGISTER requests */
16581654
if (method == METHOD_REGISTER) {
16591655
if (msg->first_line.type == SIP_REPLY) {
16601656
strcpy(reason, "'Contact' header for REGISTER reply contains '*' only valid for REGISTER request");
1661-
ret = SV_BAD_STAR_CONTACT;
1662-
goto failed;
1657+
return SV_BAD_STAR_CONTACT;
16631658
}
16641659

16651660
if (!msg->expires || (parse_expires(msg->expires) < 0 || !msg->expires->parsed)) {
16661661
strcpy(reason, "failed to parse 'Expires' header");
1667-
ret = SV_BAD_STAR_CONTACT;
1668-
goto failed;
1662+
return SV_BAD_STAR_CONTACT;
16691663
}
16701664

16711665
expires_body = (exp_body_t*) msg->expires->parsed;
16721666

16731667
if (!expires_body || expires_body->val != 0) {
16741668
strcpy(reason, "'Expires' header greater than 0 for REGISTER 'Contact' header with '*' value");
1675-
ret = SV_BAD_STAR_CONTACT;
1676-
goto failed;
1669+
return SV_BAD_STAR_CONTACT;
16771670
}
16781671
} else {
16791672
strcpy(reason, "'Contact' header for SIP message contains '*' only valid for REGISTER request");
1680-
ret = SV_BAD_STAR_CONTACT;
1681-
goto failed;
1673+
return SV_BAD_STAR_CONTACT;
16821674
}
16831675
}
16841676
}
16851677
}
16861678

1687-
failed:
1688-
return ret;
1679+
return SV_NO_ERROR;
16891680
}
16901681

16911682
static int w_sip_validate(struct sip_msg *msg, void *_flags, pv_spec_t* err_txt)

0 commit comments

Comments
 (0)