[sr-dev] git:master:4917283a: core: dset - comment to document return code for getting branch data

Daniel-Constantin Mierla miconda at gmail.com
Mon Aug 19 11:38:01 CEST 2019


Module: kamailio
Branch: master
Commit: 4917283ae2ed27a852a63cde78e9f8739958ff92
URL: https://github.com/kamailio/kamailio/commit/4917283ae2ed27a852a63cde78e9f8739958ff92

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2019-08-19T11:37:40+02:00

core: dset - comment to document return code for getting branch data

- differentiate when returning data for valid or invalid branch index

---

Modified: src/core/dset.c

---

Diff:  https://github.com/kamailio/kamailio/commit/4917283ae2ed27a852a63cde78e9f8739958ff92.diff
Patch: https://github.com/kamailio/kamailio/commit/4917283ae2ed27a852a63cde78e9f8739958ff92.patch

---

diff --git a/src/core/dset.c b/src/core/dset.c
index f1b79ba037..faa61db72b 100644
--- a/src/core/dset.c
+++ b/src/core/dset.c
@@ -314,6 +314,10 @@ char* next_branch(int* len, qvalue_t* q, str* dst_uri, str* path,
 	return ret;
 }
 
+/**
+ * Link branch attributes in the data structure
+ * - return: -1 (<0) on error; 0 - on no valid branch; 1 - on a valid branch
+ */
 int get_branch_data(unsigned int i, branch_data_t *vbranch)
 {
 	if(vbranch==NULL) {
@@ -348,18 +352,23 @@ int get_branch_data(unsigned int i, branch_data_t *vbranch)
 			vbranch->location_ua.s = branches[i].location_ua;
 		}
 		vbranch->otcpid = branches[i].otcpid;
+		return 1;
 	} else {
 		vbranch->q = Q_UNSPECIFIED;
+		return 0;
 	}
-
-	return 0;
 }
 
+/**
+ * Link branch attributes in the data structure and advance the iterator on
+ * return of a valid branch
+ * - return: -1 (<0) on error; 0 - on no valid branch; 1 - on a valid branch
+ */
 int next_branch_data(branch_data_t *vbranch)
 {
 	int ret;
 	ret= get_branch_data(branch_iterator, vbranch);
-	if (ret < 0) {
+	if (ret <= 0) {
 		return ret;
 	}
 	branch_iterator++;




More information about the sr-dev mailing list