From: Seungbae Shin Date: Tue, 11 Feb 2020 05:31:18 +0000 (+0900) Subject: fixup! stream-manager: Fix svace defects (CHECK_AFTER_OVERFLOW / UNREACHABLE_CODE) X-Git-Tag: submit/tizen/20200224.103343^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d0c82ca21d5fdf793089c7cfe35e724ad55753a;p=platform%2Fcore%2Fmultimedia%2Fpulseaudio-modules-tizen.git fixup! stream-manager: Fix svace defects (CHECK_AFTER_OVERFLOW / UNREACHABLE_CODE) + remove minor warning Change-Id: Icca68a8fc1e1369208c3e6a91a74e1b099e05a84 --- diff --git a/src/stream-manager.c b/src/stream-manager.c index 0debcf1..597c173 100644 --- a/src/stream-manager.c +++ b/src/stream-manager.c @@ -43,6 +43,8 @@ #include #include #include +#include + #include #include "stream-manager.h" @@ -125,14 +127,12 @@ static const char* notify_command_type_str[] = { #define STREAM_MAP_STREAM_AVAIL_OUT_DEVICES "avail-out-devices" #define STREAM_MAP_STREAM_AVAIL_FRAMEWORKS "avail-frameworks" -static bool is_valid_command(const char *func, notify_command_type_t command) { - if (command >= sizeof(notify_command_type_str) / sizeof(char *)) { - pa_log_error("[%s] invalid command: %d", func, command); - return false; - } +static bool is_valid_notify_command(notify_command_type_t command) { + return (command < sizeof(notify_command_type_str) / sizeof(char *)); +} - pa_log_debug("[%s] command: %s", func, notify_command_type_str[command]); - return true; +static bool is_valid_process_command(process_command_type_t command) { + return (command < sizeof(process_command_type_str) / sizeof(char *)); } bool stream_is_call_family(pa_object *stream) { @@ -1246,7 +1246,7 @@ static bool update_stream_parent_info(pa_stream_manager *m, process_command_type pa_idxset_remove_by_data(type == STREAM_SINK_INPUT ? (sp->idx_sink_inputs) : (sp->idx_source_outputs), stream, NULL); return true; } else { - pa_log_error("invalid command(%d)", command); + pa_log_error("invalid process command(%d)", command); return false; } } else { @@ -1284,7 +1284,7 @@ static bool update_the_highest_priority_stream(pa_stream_manager *m, process_com pa_assert(m); pa_assert(mine); if (!role) { - pa_log_error("invalid input, role(%s)", role); + pa_log_error("invalid input, role(%s)", pa_strnull(role)); return false; } @@ -1575,8 +1575,11 @@ static void fill_device_info_to_hook_data(pa_stream_manager *m, void *hook_data, pa_assert(m); pa_assert(hook_data); - if (!is_valid_command(__func__, command)) + if (!is_valid_notify_command(command)) { + pa_log_error("invalid notify command: %d", command); return; + } + pa_log_info("command: %s", notify_command_type_str[command]); switch (command) { case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: { @@ -1816,8 +1819,11 @@ ret_msg_t do_notify(pa_stream_manager *m, notify_command_type_t command, stream_ pa_assert(m); - if (!is_valid_command(__func__, command)) + if (!is_valid_notify_command(command)) { + pa_log_error("invalid notify command: %d", command); return RET_MSG_ERROR_INVALID_ARGUMENT; + } + pa_log_info("command: %s", notify_command_type_str[command]); switch (command) { case NOTIFY_COMMAND_SELECT_PROPER_SINK_OR_SOURCE_FOR_INIT: @@ -2330,12 +2336,16 @@ static process_stream_result_t handle_command_add_remove_parent_id(pa_stream_man process_stream_result_t process_stream(pa_stream_manager *m, void *stream, stream_type_t type, process_command_type_t command, bool is_new_data) { process_stream_result_t result = PROCESS_STREAM_RESULT_OK; - pa_log_info(">>> [%s]: stream(%p), stream_type(%d), is_new_data(%d)", - process_command_type_str[command], stream, type, is_new_data); - pa_assert(m); pa_assert(stream); + if (!is_valid_process_command(command)) { + pa_log_error("invalid process command: %d", command); + return PROCESS_STREAM_RESULT_SKIP; + } + pa_log_info(">>> [%s]: stream(%p), stream_type(%d), is_new_data(%d)", + process_command_type_str[command], stream, type, is_new_data); + if (check_name_to_skip(m, command, stream, type, is_new_data)) { result = PROCESS_STREAM_RESULT_SKIP; /* set it to null sink/source */