summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--channels/chan_sip.c2
-rw-r--r--include/asterisk/vector.h10
-rw-r--r--main/strings.c2
-rw-r--r--res/res_ari.c2
-rw-r--r--res/res_pjsip/pjsip_distributor.c2
-rw-r--r--res/res_pjsip_caller_id.c8
-rw-r--r--tests/test_vector.c2
7 files changed, 16 insertions, 12 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 8a30e0c00..62ff505fc 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -18127,7 +18127,7 @@ static int get_pai(struct sip_pvt *p, struct sip_request *req)
}
ast_copy_string(privacy, sip_get_header(req, "Privacy"), sizeof(privacy));
- if (!ast_strlen_zero(privacy) && !strncmp(privacy, "id", 2)) {
+ if (!ast_strlen_zero(privacy) && strcasecmp(privacy, "none")) {
callingpres = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
}
if (!cid_name) {
diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h
index 2de84d295..1e6fe038c 100644
--- a/include/asterisk/vector.h
+++ b/include/asterisk/vector.h
@@ -304,27 +304,31 @@ AST_VECTOR(ast_vector_int, int);
* \brief Add an element into a sorted vector
*
* \param vec Sorted vector to add to.
- * \param elem Element to insert.
+ * \param elem Element to insert. Must not be an array type.
* \param cmp A strcmp compatible compare function.
*
* \return 0 on success.
* \return Non-zero on failure.
*
* \warning Use of this macro on an unsorted vector will produce unpredictable results
+ * \warning 'elem' must not be an array type so passing 'x' where 'x' is defined as
+ * 'char x[4]' will fail to compile. However casting 'x' as 'char *' does
+ * result in a value that CAN be used.
*/
#define AST_VECTOR_ADD_SORTED(vec, elem, cmp) ({ \
int res = 0; \
size_t __idx = (vec)->current; \
+ typeof(elem) __elem = (elem); \
do { \
if (__make_room((vec)->current, vec) != 0) { \
res = -1; \
break; \
} \
- while (__idx > 0 && (cmp((vec)->elems[__idx - 1], elem) > 0)) { \
+ while (__idx > 0 && (cmp((vec)->elems[__idx - 1], __elem) > 0)) { \
(vec)->elems[__idx] = (vec)->elems[__idx - 1]; \
__idx--; \
} \
- (vec)->elems[__idx] = elem; \
+ (vec)->elems[__idx] = __elem; \
(vec)->current++; \
} while (0); \
res; \
diff --git a/main/strings.c b/main/strings.c
index 3207fa15e..82e315aea 100644
--- a/main/strings.c
+++ b/main/strings.c
@@ -312,7 +312,7 @@ regex:
}
equals:
- scan_numeric = (sscanf(left, "%lf", &left_num) && sscanf(internal_right, "%lf", &right_num));
+ scan_numeric = (sscanf(left, "%lf", &left_num) > 0 && sscanf(internal_right, "%lf", &right_num) > 0);
if (internal_op[0] == '=') {
if (ast_strlen_zero(left) && ast_strlen_zero(internal_right)) {
diff --git a/res/res_ari.c b/res/res_ari.c
index 054d3bf3c..5145499be 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -884,7 +884,7 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
RAII_VAR(struct ast_variable *, post_vars, NULL, ast_variables_destroy);
struct ast_variable *var;
const char *app_name = NULL;
- RAII_VAR(struct ast_json *, body, ast_json_null(), ast_json_free);
+ RAII_VAR(struct ast_json *, body, ast_json_null(), ast_json_unref);
int debug_app = 0;
if (!response_body) {
diff --git a/res/res_pjsip/pjsip_distributor.c b/res/res_pjsip/pjsip_distributor.c
index cf1b04a8b..b4828d89f 100644
--- a/res/res_pjsip/pjsip_distributor.c
+++ b/res/res_pjsip/pjsip_distributor.c
@@ -1142,9 +1142,9 @@ static void global_loaded(const char *object_type)
fake_auth = alloc_artificial_auth(default_realm);
if (fake_auth) {
ao2_global_obj_replace_unref(artificial_auth, fake_auth);
- ao2_ref(fake_auth, -1);
}
}
+ ao2_cleanup(fake_auth);
ast_sip_get_unidentified_request_thresholds(&unidentified_count, &unidentified_period, &unidentified_prune_interval);
diff --git a/res/res_pjsip_caller_id.c b/res/res_pjsip_caller_id.c
index 470d90f43..64191a750 100644
--- a/res/res_pjsip_caller_id.c
+++ b/res/res_pjsip_caller_id.c
@@ -149,12 +149,12 @@ static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
}
privacy = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &privacy_str, NULL);
- if (privacy && !pj_stricmp2(&privacy->hvalue, "id")) {
- id->number.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
- id->name.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
- } else {
+ if (!privacy || !pj_stricmp2(&privacy->hvalue, "none")) {
id->number.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
id->name.presentation = AST_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED;
+ } else {
+ id->number.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
+ id->name.presentation = AST_PRES_PROHIB_USER_NUMBER_NOT_SCREENED;
}
return 0;
diff --git a/tests/test_vector.c b/tests/test_vector.c
index 8e0d121dd..2dfcc60a8 100644
--- a/tests/test_vector.c
+++ b/tests/test_vector.c
@@ -210,7 +210,7 @@ AST_TEST_DEFINE(basic_ops)
ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, ZZZ, strcmp) == 0, rc, cleanup);
ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, CCC, strcmp) == 0, rc, cleanup);
ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, AAA, strcmp) == 0, rc, cleanup);
- ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, CCC2, strcmp) == 0, rc, cleanup);
+ ast_test_validate_cleanup(test, AST_VECTOR_ADD_SORTED(&sv1, (char*)CCC2, strcmp) == 0, rc, cleanup);
ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 0) == AAA, rc, cleanup);
ast_test_validate_cleanup(test, AST_VECTOR_GET(&sv1, 1) == BBB, rc, cleanup);