From c6142cf2cc7312122abcf74d6ab1daf0ad1d72bf Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Mon, 11 Jun 2012 15:23:30 +0000 Subject: [PATCH] Fix coverity UNUSED_VALUE findings in core support level files Most of these were just saving returned values without using them and in some cases the variable being saved to could be removed as well. (issue ASTERISK-19672) ........ Merged revisions 368738 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 368739 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@368751 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- apps/app_directory.c | 3 ++- apps/app_queue.c | 2 +- apps/app_voicemail.c | 2 +- channels/chan_dahdi.c | 3 +-- channels/chan_sip.c | 2 +- channels/sip/dialplan_functions.c | 4 ++-- channels/sip/reqresp_parser.c | 2 +- channels/sip/sdp_crypto.c | 4 +--- main/loader.c | 4 ++-- main/say.c | 2 +- pbx/pbx_config.c | 4 ++-- res/res_config_odbc.c | 7 +++---- res/res_fax.c | 2 +- res/res_odbc.c | 2 +- res/res_speech.c | 3 +-- 15 files changed, 21 insertions(+), 25 deletions(-) diff --git a/apps/app_directory.c b/apps/app_directory.c index bbca1bf..ce01bc8 100644 --- a/apps/app_directory.c +++ b/apps/app_directory.c @@ -475,7 +475,8 @@ static struct ast_config *realtime_directory(char *context) const char *ctx = ast_variable_retrieve(rtdata, mailbox, "context"); fullname = ast_variable_retrieve(rtdata, mailbox, "fullname"); - if (ast_true((hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir")))) { + hidefromdir = ast_variable_retrieve(rtdata, mailbox, "hidefromdir"); + if (ast_true(hidefromdir)) { /* Skip hidden */ continue; } diff --git a/apps/app_queue.c b/apps/app_queue.c index 1696798..245b451 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -2502,7 +2502,7 @@ static struct call_queue *find_queue_by_name_rt(const char *queuename, struct as memset(tmpbuf, 0, sizeof(tmpbuf)); for (v = queue_vars; v; v = v->next) { /* Convert to dashes `-' from underscores `_' as the latter are more SQL friendly. */ - if ((tmp = strchr(v->name, '_'))) { + if (strchr(v->name, '_')) { ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf)); tmp_name = tmpbuf; tmp = tmpbuf; diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 39d2847..8ee8367 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -1740,7 +1740,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword) for (category = ast_category_browse(cfg, NULL); category; category = ast_category_browse(cfg, category)) { ast_debug(4, "users.conf: %s\n", category); if (!strcasecmp(category, vmu->mailbox)) { - if (!(tmp = ast_variable_retrieve(cfg, category, "vmsecret"))) { + if (!ast_variable_retrieve(cfg, category, "vmsecret")) { ast_debug(3, "looks like we need to make vmsecret!\n"); var = ast_variable_new("vmsecret", newpassword, ""); } else { diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 46c4589..e6c39d2 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -14489,14 +14489,13 @@ static char *handle_pri_service_generic(struct ast_cli_entry *e, int cmd, struct int trunkgroup; int x, y, fd = a->fd; int interfaceid = 0; - char *c; char db_chan_name[20], db_answer[5]; struct dahdi_pvt *tmp; struct dahdi_pri *pri; if (a->argc < 5 || a->argc > 6) return CLI_SHOWUSAGE; - if ((c = strchr(a->argv[4], ':'))) { + if (strchr(a->argv[4], ':')) { if (sscanf(a->argv[4], "%30d:%30d", &trunkgroup, &channel) != 2) return CLI_SHOWUSAGE; if ((trunkgroup < 1) || (channel < 1)) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 051a538..d8c9f39 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -14178,7 +14178,7 @@ static int transmit_refer(struct sip_pvt *p, const char *dest) ast_log(LOG_NOTICE, "From address missing 'sip(s):', assuming sip:\n"); } /* Get just the username part */ - if ((c = strchr(dest, '@'))) { + if (strchr(dest, '@')) { c = NULL; } else if ((c = strchr(of, '@'))) { *c++ = '\0'; diff --git a/channels/sip/dialplan_functions.c b/channels/sip/dialplan_functions.c index fd8b04f..75fe82d 100644 --- a/channels/sip/dialplan_functions.c +++ b/channels/sip/dialplan_functions.c @@ -153,9 +153,9 @@ int sip_acf_channel_read(struct ast_channel *chan, const char *funcname, char *p } if (ast_strlen_zero(args.field) || !strcasecmp(args.field, "all")) { - char quality_buf[AST_MAX_USER_FIELD], *quality; + char quality_buf[AST_MAX_USER_FIELD]; - if (!(quality = ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf)))) { + if (!ast_rtp_instance_get_quality(rtp, AST_RTP_INSTANCE_STAT_FIELD_QUALITY, quality_buf, sizeof(quality_buf))) { return -1; } diff --git a/channels/sip/reqresp_parser.c b/channels/sip/reqresp_parser.c index e37d75b..d87acda 100644 --- a/channels/sip/reqresp_parser.c +++ b/channels/sip/reqresp_parser.c @@ -1079,7 +1079,7 @@ AST_TEST_DEFINE(get_in_brackets_test) } /* Test 6, NULL input */ - if ((uri = get_in_brackets(NULL))) { + if (get_in_brackets(NULL)) { ast_test_status_update(test, "Test 6, NULL input failed.\n"); res = AST_TEST_FAIL; } diff --git a/channels/sip/sdp_crypto.c b/channels/sip/sdp_crypto.c index 85adf83..7f88355 100644 --- a/channels/sip/sdp_crypto.c +++ b/channels/sip/sdp_crypto.c @@ -52,9 +52,7 @@ static int set_crypto_policy(struct ast_srtp_policy *policy, int suite_val, cons static struct sdp_crypto *sdp_crypto_alloc(void) { - struct sdp_crypto *crypto; - - return crypto = ast_calloc(1, sizeof(*crypto)); + return ast_calloc(1, sizeof(struct sdp_crypto)); } void sdp_crypto_destroy(struct sdp_crypto *crypto) diff --git a/main/loader.c b/main/loader.c index eacdff7..1415fa9 100644 --- a/main/loader.c +++ b/main/loader.c @@ -1075,13 +1075,13 @@ int load_modules(unsigned int preload_only) if (mod->flags.running) continue; - order = add_to_load_order(mod->resource, &load_order, 0); + add_to_load_order(mod->resource, &load_order, 0); } #ifdef LOADABLE_MODULES /* if we are allowed to load dynamic modules, scan the directory for for all available modules and add them as well */ - if ((dir = opendir(ast_config_AST_MODULE_DIR))) { + if ((dir = opendir(ast_config_AST_MODULE_DIR))) { while ((dirent = readdir(dir))) { int ld = strlen(dirent->d_name); diff --git a/main/say.c b/main/say.c index 9d6d4b1..f8379c5 100644 --- a/main/say.c +++ b/main/say.c @@ -1915,7 +1915,7 @@ static void powiedz(struct ast_channel *chan, const char *language, int audiofd, char *b = buf; b = pl_append(b, odm->dziesiatki[m100 / 10]); b = pl_append(b, odm->separator_dziesiatek); - b = pl_append(b, odm->cyfry2[m100 % 10]); + pl_append(b, odm->cyfry2[m100 % 10]); pl_odtworz_plik(chan, language, audiofd, ctrlfd, ints, buf); } } diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index cf9b26f..488241a 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1481,7 +1481,7 @@ static int pbx_load_config(const char *config_file) } } else if (!strcasecmp(v->name, "exten")) { int ipri; - char *plus, *firstp; + char *plus; char *pri, *appl, *data, *cidmatch; if (!(stringp = tc = ast_strdup(v->value))) { @@ -1551,7 +1551,7 @@ process_extension: } appl = S_OR(stringp, ""); /* Find the first occurrence of '(' */ - if (!(firstp = strchr(appl, '('))) { + if (!strchr(appl, '(')) { /* No arguments */ data = ""; } else { diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c index 4692283..66e15a0 100644 --- a/res/res_config_odbc.c +++ b/res/res_config_odbc.c @@ -518,7 +518,7 @@ static int update_odbc(const char *database, const char *table, const char *keyf } va_arg(aq, const char *); - if (tableptr && !(column = ast_odbc_find_column(tableptr, newparam))) { + if (tableptr && !ast_odbc_find_column(tableptr, newparam)) { ast_log(LOG_WARNING, "Key field '%s' does not exist in table '%s@%s'. Update will fail\n", newparam, table, database); } @@ -587,7 +587,6 @@ static SQLHSTMT update2_prepare(struct odbc_obj *obj, void *data) SQLHSTMT stmt; va_list ap; struct odbc_cache_tables *tableptr = ast_odbc_find_table(ups->database, ups->table); - struct odbc_cache_columns *column; if (!sql) { if (tableptr) { @@ -619,7 +618,7 @@ static SQLHSTMT update2_prepare(struct odbc_obj *obj, void *data) while ((newparam = va_arg(ap, const char *))) { newval = va_arg(ap, const char *); - if ((column = ast_odbc_find_column(tableptr, newparam))) { + if (ast_odbc_find_column(tableptr, newparam)) { ast_str_append(&sql, 0, "%s%s=? ", first ? "" : ", ", newparam); SQLBindParameter(stmt, x++, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, strlen(newval), 0, (void *)newval, 0, NULL); first = 0; @@ -637,7 +636,7 @@ static SQLHSTMT update2_prepare(struct odbc_obj *obj, void *data) while ((newparam = va_arg(ap, const char *))) { newval = va_arg(ap, const char *); - if (!(column = ast_odbc_find_column(tableptr, newparam))) { + if (!ast_odbc_find_column(tableptr, newparam)) { va_end(ap); ast_log(LOG_ERROR, "One or more of the criteria columns '%s' on '%s@%s' for this update does not exist!\n", newparam, ups->table, ups->database); ast_odbc_release_table(tableptr); diff --git a/res/res_fax.c b/res/res_fax.c index 7b628d3..50c1c36 100644 --- a/res/res_fax.c +++ b/res/res_fax.c @@ -583,7 +583,7 @@ static int update_modem_bits(enum ast_fax_modems *bits, const char *value) char *m[5], *tok, *v = (char *)value; int i = 0, j; - if (!(tok = strchr(v, ','))) { + if (!strchr(v, ',')) { m[i++] = v; m[i] = NULL; } else { diff --git a/res/res_odbc.c b/res/res_odbc.c index 39475e9..3afa088 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -1628,7 +1628,7 @@ static int acf_transaction_write(struct ast_channel *chan, const char *cmd, char pbx_builtin_setvar_helper(chan, "ODBC_RESULT", "INVALID_DB"); return -1; } - if (!(tx = find_transaction(chan, obj, value, 0))) { + if (!find_transaction(chan, obj, value, 0)) { pbx_builtin_setvar_helper(chan, "ODBC_RESULT", "FAILED_TO_CREATE"); return -1; } diff --git a/res/res_speech.c b/res/res_speech.c index de0c41e..e6fdab9 100644 --- a/res/res_speech.c +++ b/res/res_speech.c @@ -276,7 +276,6 @@ int ast_speech_change_results_type(struct ast_speech *speech, enum ast_speech_re /*! \brief Register a speech recognition engine */ int ast_speech_register(struct ast_speech_engine *engine) { - struct ast_speech_engine *existing_engine = NULL; int res = 0; /* Confirm the engine meets the minimum API requirements */ @@ -286,7 +285,7 @@ int ast_speech_register(struct ast_speech_engine *engine) } /* If an engine is already loaded with this name, error out */ - if ((existing_engine = find_engine(engine->name))) { + if (find_engine(engine->name)) { ast_log(LOG_WARNING, "Speech recognition engine '%s' already exists.\n", engine->name); return -1; } -- 1.7.9.5