Skip to content

Commit a4e772c

Browse files
committed
registrar: Code styling & documentation nitpicks
1 parent 6bfb11c commit a4e772c

File tree

5 files changed

+27
-31
lines changed

5 files changed

+27
-31
lines changed

lib/reg/ci.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,8 @@ ucontact_info_t *pack_ci(struct sip_msg* _m, contact_t* _c, unsigned int _e,
155155
ci.methods = allowed;
156156
}
157157

158-
if (_c->instance) {
158+
if (_c->instance)
159159
ci.instance = _c->instance->body;
160-
}
161160

162161
/* get received */
163162
if (ci.received.len==0) {

lib/reg/doc/lookup_retcodes.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
<para>
55
<emphasis role='bold'>1</emphasis> - contacts found and successfully
66
pushed as branches. Contacts which required awakening prior to being
7-
reachable have been notified via async Push Notifications.
7+
reachable are being notified via async Push Notifications.
88
</para>
99
</listitem>
1010
<listitem>
1111
<para>
12-
<emphasis role='bold'>2</emphasis> - successfully triggered at least one
12+
<emphasis role='bold'>2</emphasis> - successfully started at least one
1313
async Push Notification for the found contacts, however no extra branches
1414
were populated (i.e. there is no need to call t_relay()).
1515
</para>

lib/reg/save_flags.c

-1
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,4 @@ void reg_parse_save_flags(str *flags_s, struct save_ctx *sctx)
113113
LM_WARN("unsupported flag %c \n",flags_s->s[st]);
114114
}
115115
}
116-
117116
}

modules/mid_registrar/save.c

+18-21
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ static int trim_to_single_contact(struct sip_msg *msg, str *aor)
160160
return -1;
161161
}
162162

163-
if (anchor == NULL) {
163+
if (!anchor) {
164164
anchor = anchor_lump(msg, msg->unparsed - msg->buf, 0);
165-
if (anchor == NULL) {
165+
if (!anchor) {
166166
LM_ERR("failed to add anchor lump\n");
167167
return -1;
168168
}
@@ -191,7 +191,7 @@ static int trim_to_single_contact(struct sip_msg *msg, str *aor)
191191
/* > ;expires=<integer> \0 */
192192

193193
buf = pkg_malloc(len);
194-
if (buf == NULL) {
194+
if (!buf) {
195195
LM_ERR("oom\n");
196196
return -1;
197197
}
@@ -985,7 +985,7 @@ int append_contacts(ucontact_t *contacts, struct sip_msg *msg)
985985
}
986986

987987
len = sprintf(buf, "%.*s", contact.data_len, contact.buf);
988-
if (insert_new_lump_after(anchor, buf, len, HDR_CONTACT_T) == NULL) {
988+
if (!insert_new_lump_after(anchor, buf, len, HDR_CONTACT_T)) {
989989
pkg_free(buf);
990990
return -1;
991991
}
@@ -1261,21 +1261,18 @@ static inline int save_restore_rpl_contacts(struct sip_msg *req,
12611261
else
12621262
mri->ul_flags = FL_NONE;
12631263

1264-
if (is_tcp_based_proto(req->rcv.proto) && (req->flags & tcp_persistent_flag)) {
1264+
if (is_tcp_based_proto(req->rcv.proto) && req->flags & tcp_persistent_flag)
12651265
tcp_check = 1;
1266-
}
12671266

12681267
LM_DBG("running\n");
12691268

12701269
/* remove all "Contact" headers from the reply */
12711270
for (hdr = rpl->contact; hdr; hdr = hdr->next) {
1272-
if (hdr->type == HDR_CONTACT_T) {
1273-
if (del_lump(rpl, hdr->name.s - rpl->buf,
1274-
hdr->len, HDR_CONTACT_T) == NULL) {
1275-
LM_ERR("failed to delete contact '%.*s'\n", hdr->name.len,
1276-
hdr->name.s);
1277-
goto error;
1278-
}
1271+
if (hdr->type == HDR_CONTACT_T &&
1272+
!del_lump(rpl, hdr->name.s - rpl->buf, hdr->len, HDR_CONTACT_T)) {
1273+
LM_ERR("failed to delete contact '%.*s'\n", hdr->name.len,
1274+
hdr->name.s);
1275+
goto error;
12791276
}
12801277
}
12811278

@@ -1339,7 +1336,7 @@ static inline int save_restore_rpl_contacts(struct sip_msg *req,
13391336

13401337
LM_DBG("INSERTING contact with expires %lu\n", ci->expires);
13411338

1342-
if (ul.insert_ucontact( r, &ctmap->req_ct_uri, ci, &c, 0) < 0) {
1339+
if (ul.insert_ucontact(r, &ctmap->req_ct_uri, ci, &c, 0) < 0) {
13431340
rerrno = R_UL_INS_C;
13441341
LM_ERR("failed to insert contact\n");
13451342
goto error;
@@ -1492,7 +1489,7 @@ static inline int save_restore_req_contacts(struct sip_msg *req,
14921489

14931490
/* in MID_REG_THROTTLE_AOR mode, any reply will only contain 1 contact */
14941491
_c = get_first_contact(rpl);
1495-
if (_c != NULL)
1492+
if (_c)
14961493
calc_contact_expires(rpl, _c->expires, &e_out, 0);
14971494

14981495
ul.lock_udomain(mri->dom, &mri->aor);
@@ -1503,7 +1500,7 @@ static inline int save_restore_req_contacts(struct sip_msg *req,
15031500
* AoR not yet stored here, and the main registrar is also clean!
15041501
* Just skip processing any contacts found in the request, we're good.
15051502
*/
1506-
if (_c == NULL)
1503+
if (!_c)
15071504
goto out;
15081505

15091506
if (ul.insert_urecord(mri->dom, _a, &r, 0) < 0) {
@@ -1527,7 +1524,7 @@ static inline int save_restore_req_contacts(struct sip_msg *req,
15271524
}
15281525
}
15291526

1530-
if (_c != NULL) {
1527+
if (_c) {
15311528
/**
15321529
* we now replace the single reply Contact hf with all Contact hfs
15331530
* present in the initial request
@@ -1554,7 +1551,7 @@ static inline int save_restore_req_contacts(struct sip_msg *req,
15541551
list_for_each(_, &mri->ct_mappings) {
15551552
ctmap = list_entry(_, struct ct_mapping, list);
15561553

1557-
if (_c == NULL) {
1554+
if (!_c) {
15581555
if (ctmap->expires != 0)
15591556
LM_ERR("200 OK from main registrar is missing Contact '%.*s'\n",
15601557
ctmap->req_ct_uri.len, ctmap->req_ct_uri.s);
@@ -1569,13 +1566,13 @@ static inline int save_restore_req_contacts(struct sip_msg *req,
15691566
c = NULL;
15701567
/* pack the contact_info */
15711568
ci = mid_reg_pack_ci(req, rpl, mri, ctmap);
1572-
if (ci == NULL) {
1569+
if (!ci) {
15731570
LM_ERR("failed to extract contact info\n");
15741571
goto out_clear_err;
15751572
}
15761573
ci->expires_out = e_out;
15771574

1578-
if ((r->contacts == NULL ||
1575+
if ((!r->contacts ||
15791576
ul.get_ucontact(r, &ctmap->req_ct_uri, ci->callid, ci->cseq+1,
15801577
&mri->cmatch, &c) != 0) && ctmap->expires > 0) {
15811578
/* contact not found and not present on main reg either */
@@ -2241,7 +2238,7 @@ static int process_contacts_by_aor(struct sip_msg *req, urecord_t *urec,
22412238
unsigned int last_reg_ts;
22422239
int_str_t *value;
22432240

2244-
if (urec->contacts == NULL)
2241+
if (!urec->contacts)
22452242
return 1;
22462243

22472244
value = ul.get_urecord_key(urec, &ul_key_last_reg_ts);

str_list.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,24 @@ static inline void _free_str_list(str_list *list,
5656
}
5757

5858
#define free_pkg_str_list(list) \
59-
_free_str_list(list, osips_pkg_free, osips_pkg_free)
59+
_free_str_list(list, osips_pkg_free, NULL)
6060

6161
#define free_shm_str_list(list) \
62-
_free_str_list(list, osips_shm_free, osips_shm_free)
62+
_free_str_list(list, osips_shm_free, NULL)
6363

6464
static inline str_list *dup_shm_str_list(const str_list *list)
6565
{
6666
str_list *item, *ret = NULL;
6767
const str_list *it;
6868

6969
for (it = list; it; it = it->next) {
70-
item = shm_malloc(sizeof *item);
70+
item = shm_malloc(sizeof *item + it->s.len + 1);
7171
if (!item)
7272
goto oom;
7373

74-
if (shm_str_dup(&item->s, &it->s) != 0)
75-
goto oom;
74+
item->s.s = (char *)(item + 1);
75+
str_cpy(&item->s, &it->s);
76+
item->s.s[item->s.len] = '\0';
7677

7778
item->next = NULL;
7879
add_last(item, ret);

0 commit comments

Comments
 (0)