From 4089005074d16bff45b5cf86077889c29a285d48 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 11 Jul 2023 15:41:55 -0400 Subject: [PATCH] MT#56128 simplify sdp_manipulations_add case Operating on an empty queue is essentially a no-op, so there's no point in doing an extra check first to see if the queue is empty. Remove this extra check for the CMD_ADD case. Change-Id: I3c7524cd407fb350a46bdf8d3a91014158c6bf44 --- daemon/call_interfaces.c | 1 - daemon/sdp.c | 16 +++++----------- include/sdp.h | 3 +-- 3 files changed, 6 insertions(+), 14 deletions(-) diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 38a9eba63..ee6fc831e 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -630,7 +630,6 @@ INLINE void ng_sdp_attr_manipulations(struct sdp_ng_flags *flags, bencode_item_t switch (__csh_lookup(&command_type)) { - /* CMD_ADD / CMD_SUBST commands */ case CSH_LOOKUP("substitute"): ht = &sm->subst_commands; diff --git a/daemon/sdp.c b/daemon/sdp.c index 0398eb3f4..0ea5d4940 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -302,7 +302,6 @@ static int sdp_manipulate_check(enum command_type command_type, if (!sdp_manipulations) return 0; - GQueue * q_ptr = NULL; GHashTable * ht = NULL; switch (command_type) { @@ -317,12 +316,6 @@ static int sdp_manipulate_check(enum command_type command_type, return 1; break; - case CMD_ADD: - q_ptr = &sdp_manipulations->add_commands; - if (q_ptr->head) - return 1; - break; - case CMD_REM:; if (!attr_name || !attr_name->len) break; @@ -346,6 +339,9 @@ static int sdp_manipulate_check(enum command_type command_type, static void sdp_manipulations_add(struct sdp_chopper *chop, struct sdp_manipulations * sdp_manipulations) { + if (!sdp_manipulations) + return; + GQueue * q_ptr = &sdp_manipulations->add_commands; for (GList *l = q_ptr->head; l; l = l->next) @@ -3170,8 +3166,7 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu /* ADD arbitrary SDP manipulations for a session sessions */ struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, MT_UNKNOWN); - if (sdp_manipulate_check(CMD_ADD, sdp_manipulations, NULL)) - sdp_manipulations_add(chop, sdp_manipulations); + sdp_manipulations_add(chop, sdp_manipulations); for (k = session->media_streams.head; k; k = k->next) { sdp_media = k->data; @@ -3246,8 +3241,7 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu /* ADD arbitrary SDP manipulations for audio/video media sessions */ sdp_manipulations = sdp_manipulations_get_by_id(flags, sdp_media->media_type_id); - if (sdp_manipulate_check(CMD_ADD, sdp_manipulations, NULL)) - sdp_manipulations_add(chop, sdp_manipulations); + sdp_manipulations_add(chop, sdp_manipulations); media_index++; } diff --git a/include/sdp.h b/include/sdp.h index 49073200b..90ee3cbc6 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -8,8 +8,7 @@ #include "media_socket.h" enum command_type { - CMD_ADD = 0, - CMD_REM, + CMD_REM = 1, CMD_SUBST, };