[Asterisk-code-review] res pjsip header funcs: Various cleanups (asterisk[13])
Sean Bright
asteriskteam at digium.com
Thu Feb 15 14:20:00 CST 2018
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/8213
Change subject: res_pjsip_header_funcs: Various cleanups
......................................................................
res_pjsip_header_funcs: Various cleanups
* Prefer strcasecmp() over stricmp()
* Use a list with no lock since we never actually lock
* Minor cleanups to error messages
Change-Id: I8446f44795ee8f3072e1c1f9193c6912dfc0c42b
---
M res/res_pjsip_header_funcs.c
1 file changed, 10 insertions(+), 17 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/8213/1
diff --git a/res/res_pjsip_header_funcs.c b/res/res_pjsip_header_funcs.c
index 5cb4a5f..d35dd91 100644
--- a/res/res_pjsip_header_funcs.c
+++ b/res/res_pjsip_header_funcs.c
@@ -146,18 +146,11 @@
pjsip_hdr *hdr;
AST_LIST_ENTRY(hdr_list_entry) nextptr;
};
-AST_LIST_HEAD(hdr_list, hdr_list_entry);
-
-/*! \brief Destructor for hdr_list */
-static void hdr_list_destroy(void *obj)
-{
- AST_LIST_HEAD_DESTROY((struct hdr_list *) obj);
-}
+AST_LIST_HEAD_NOLOCK(hdr_list, hdr_list_entry);
/*! \brief Datastore for saving headers */
static const struct ast_datastore_info header_datastore = {
.type = "header_datastore",
- .destroy = hdr_list_destroy,
};
/*! \brief Data structure used for ast_sip_push_task_synchronous */
@@ -215,7 +208,7 @@
ast_log(AST_LOG_ERROR, "Unable to create datastore for header functions.\n");
return 0;
}
- AST_LIST_HEAD_INIT((struct hdr_list *) datastore->data);
+ AST_LIST_HEAD_INIT_NOLOCK((struct hdr_list *) datastore->data);
}
insert_headers(pool, (struct hdr_list *) datastore->data, rdata->msg_info.msg);
@@ -340,7 +333,7 @@
ast_log(AST_LOG_ERROR, "Unable to create datastore for header functions.\n");
return -1;
}
- AST_LIST_HEAD_INIT((struct hdr_list *) datastore->data);
+ AST_LIST_HEAD_INIT_NOLOCK((struct hdr_list *) datastore->data);
}
ast_debug(1, "Adding header %s with value %s\n", data->header_name,
@@ -486,15 +479,15 @@
header_data.buf = buf;
header_data.len = len;
- if (stricmp(args.action, "read") == 0) {
+ if (!strcasecmp(args.action, "read")) {
return ast_sip_push_task_synchronous(channel->session->serializer, read_header,
&header_data);
- } else if (stricmp(args.action, "remove") == 0) {
+ } else if (!strcasecmp(args.action, "remove")) {
return ast_sip_push_task_synchronous(channel->session->serializer, remove_header,
&header_data);
} else {
ast_log(AST_LOG_ERROR,
- "Unknown action \'%s\' is not valid, Must be \'read\' or \'remove\'.\n",
+ "Unknown action \'%s\' is not valid, must be \'read\' or \'remove\'.\n",
args.action);
return -1;
}
@@ -545,18 +538,18 @@
header_data.buf = NULL;
header_data.len = 0;
- if (stricmp(args.action, "add") == 0) {
+ if (!strcasecmp(args.action, "add")) {
return ast_sip_push_task_synchronous(channel->session->serializer, add_header,
&header_data);
- } else if (stricmp(args.action, "update") == 0) {
+ } else if (!strcasecmp(args.action, "update")) {
return ast_sip_push_task_synchronous(channel->session->serializer, update_header,
&header_data);
- } else if (stricmp(args.action, "remove") == 0) {
+ } else if (!strcasecmp(args.action, "remove")) {
return ast_sip_push_task_synchronous(channel->session->serializer, remove_header,
&header_data);
} else {
ast_log(AST_LOG_ERROR,
- "Unknown action \'%s\' is not valid, Must be \'add\', \'update\', or \'remove\'.\n",
+ "Unknown action \'%s\' is not valid, must be \'add\', \'update\', or \'remove\'.\n",
args.action);
return -1;
}
--
To view, visit https://gerrit.asterisk.org/8213
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: I8446f44795ee8f3072e1c1f9193c6912dfc0c42b
Gerrit-Change-Number: 8213
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180215/0d21de8f/attachment.html>
More information about the asterisk-code-review
mailing list