From 18a994a6bd010c8cc2aaf4ab71cac668456478f3 Mon Sep 17 00:00:00 2001 From: kpfleming Date: Mon, 3 Nov 2008 13:01:18 +0000 Subject: somehow missed a bunch of gcc 4.3.x warnings in this branch on the first pass git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@153823 f38db490-d61c-443f-a65b-d21fe96a405b --- channels/chan_dahdi.c | 4 +++- channels/chan_oss.c | 13 +++++++---- funcs/func_odbc.c | 63 +++++++++++++++++++++++++++++++-------------------- main/file.c | 17 ++++++++++---- main/http.c | 31 +++++++++++++------------ main/utils.c | 7 ++++-- pbx/pbx_config.c | 20 ++++++++++++---- res/res_jabber.c | 9 +++----- 8 files changed, 103 insertions(+), 61 deletions(-) diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index 4a26f6d36..5449042ca 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -9728,7 +9728,9 @@ static char *complete_span_helper(const char *line, const char *word, int pos, i for (which = span = 0; span < NUM_SPANS; span++) { if (pris[span].pri && ++which > state) { - asprintf(&ret, "%d", span + 1); /* user indexes start from 1 */ + if (asprintf(&ret, "%d", span + 1) < 0) { /* user indexes start from 1 */ + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + } break; } } diff --git a/channels/chan_oss.c b/channels/chan_oss.c index 1a6cfd0b6..a4f373ad9 100644 --- a/channels/chan_oss.c +++ b/channels/chan_oss.c @@ -1792,12 +1792,15 @@ static struct chan_oss_pvt *store_config(struct ast_config *cfg, char *ctg) if (o->mixer_cmd) { char *cmd; - asprintf(&cmd, "mixer %s", o->mixer_cmd); - ast_log(LOG_WARNING, "running [%s]\n", cmd); - if (system(cmd) < 0) { - ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno)); + if (asprintf(&cmd, "mixer %s", o->mixer_cmd) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + } else { + ast_log(LOG_WARNING, "running [%s]\n", cmd); + if (system(cmd) < 0) { + ast_log(LOG_WARNING, "system() failed: %s\n", strerror(errno)); + } + free(cmd); } - free(cmd); } if (o == &oss_default) /* we are done with the default */ return NULL; diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index b0a13adef..49007d792 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -39,6 +39,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #include #include #include +#include #include "asterisk/module.h" #include "asterisk/file.h" @@ -405,6 +406,7 @@ static struct ast_custom_function escape_function = { static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_query **query) { const char *tmp; + int res; if (!cfg || !catg) { return -1; @@ -449,9 +451,13 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu } if ((tmp = ast_variable_retrieve(cfg, catg, "prefix")) && !ast_strlen_zero(tmp)) { - asprintf((char **)&((*query)->acf->name), "%s_%s", tmp, catg); + if (asprintf((char **)&((*query)->acf->name), "%s_%s", tmp, catg) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + } } else { - asprintf((char **)&((*query)->acf->name), "ODBC_%s", catg); + if (asprintf((char **)&((*query)->acf->name), "ODBC_%s", catg) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + } } if (!((*query)->acf->name)) { @@ -461,7 +467,10 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu return -1; } - asprintf((char **)&((*query)->acf->syntax), "%s([...[,]])", (*query)->acf->name); + if (asprintf((char **)&((*query)->acf->syntax), "%s([...[,]])", (*query)->acf->name) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + (*query)->acf->syntax = NULL; + } if (!((*query)->acf->syntax)) { free((char *)(*query)->acf->name); @@ -471,36 +480,42 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu return -1; } + res = 0; (*query)->acf->synopsis = "Runs the referenced query with the specified arguments"; if (!ast_strlen_zero((*query)->sql_read) && !ast_strlen_zero((*query)->sql_write)) { - asprintf((char **)&((*query)->acf->desc), - "Runs the following query, as defined in func_odbc.conf, performing\n" - "substitution of the arguments into the query as specified by ${ARG1},\n" - "${ARG2}, ... ${ARGn}. When setting the function, the values are provided\n" - "either in whole as ${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n" - "\nRead:\n%s\n\nWrite:\n%s\n", - (*query)->sql_read, - (*query)->sql_write); + res = asprintf((char **)&((*query)->acf->desc), + "Runs the following query, as defined in func_odbc.conf, performing\n" + "substitution of the arguments into the query as specified by ${ARG1},\n" + "${ARG2}, ... ${ARGn}. When setting the function, the values are provided\n" + "either in whole as ${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n" + "\nRead:\n%s\n\nWrite:\n%s\n", + (*query)->sql_read, + (*query)->sql_write); } else if (!ast_strlen_zero((*query)->sql_read)) { - asprintf((char **)&((*query)->acf->desc), - "Runs the following query, as defined in func_odbc.conf, performing\n" - "substitution of the arguments into the query as specified by ${ARG1},\n" - "${ARG2}, ... ${ARGn}. This function may only be read, not set.\n\nSQL:\n%s\n", - (*query)->sql_read); + res = asprintf((char **)&((*query)->acf->desc), + "Runs the following query, as defined in func_odbc.conf, performing\n" + "substitution of the arguments into the query as specified by ${ARG1},\n" + "${ARG2}, ... ${ARGn}. This function may only be read, not set.\n\nSQL:\n%s\n", + (*query)->sql_read); } else if (!ast_strlen_zero((*query)->sql_write)) { - asprintf((char **)&((*query)->acf->desc), - "Runs the following query, as defined in func_odbc.conf, performing\n" - "substitution of the arguments into the query as specified by ${ARG1},\n" - "${ARG2}, ... ${ARGn}. The values are provided either in whole as\n" - "${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n" - "This function may only be set.\nSQL:\n%s\n", - (*query)->sql_write); + res = asprintf((char **)&((*query)->acf->desc), + "Runs the following query, as defined in func_odbc.conf, performing\n" + "substitution of the arguments into the query as specified by ${ARG1},\n" + "${ARG2}, ... ${ARGn}. The values are provided either in whole as\n" + "${VALUE} or parsed as ${VAL1}, ${VAL2}, ... ${VALn}.\n" + "This function may only be set.\nSQL:\n%s\n", + (*query)->sql_write); } else { ast_log(LOG_ERROR, "No SQL was found for func_odbc class '%s'\n", catg); } + if (res < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + (*query)->acf->desc = NULL; + } + /* Could be out of memory, or could be we have neither sql_read nor sql_write */ - if (! ((*query)->acf->desc)) { + if (!((*query)->acf->desc)) { free((char *)(*query)->acf->syntax); free((char *)(*query)->acf->name); free((*query)->acf); diff --git a/main/file.c b/main/file.c index 45a033c55..d891000f7 100644 --- a/main/file.c +++ b/main/file.c @@ -265,11 +265,18 @@ static char *build_filename(const char *filename, const char *ext) if (!strcmp(ext, "wav49")) ext = "WAV"; - if (filename[0] == '/') - asprintf(&fn, "%s.%s", filename, ext); - else - asprintf(&fn, "%s/sounds/%s.%s", - ast_config_AST_DATA_DIR, filename, ext); + if (filename[0] == '/') { + if (asprintf(&fn, "%s.%s", filename, ext) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + fn = NULL; + } + } else { + if (asprintf(&fn, "%s/sounds/%s.%s", + ast_config_AST_DATA_DIR, filename, ext) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + fn = NULL; + } + } return fn; } diff --git a/main/http.c b/main/http.c index e164d554f..cee1d913c 100644 --- a/main/http.c +++ b/main/http.c @@ -231,20 +231,23 @@ static struct ast_http_uri staticuri = { char *ast_http_error(int status, const char *title, const char *extra_header, const char *text) { char *c = NULL; - asprintf(&c, - "Content-type: text/html\r\n" - "%s" - "\r\n" - "\r\n" - "\r\n" - "%d %s\r\n" - "\r\n" - "

%s

\r\n" - "

%s

\r\n" - "
\r\n" - "
Asterisk Server
\r\n" - "\r\n", - (extra_header ? extra_header : ""), status, title, title, text); + if (asprintf(&c, + "Content-type: text/html\r\n" + "%s" + "\r\n" + "\r\n" + "\r\n" + "%d %s\r\n" + "\r\n" + "

%s

\r\n" + "

%s

\r\n" + "
\r\n" + "
Asterisk Server
\r\n" + "\r\n", + (extra_header ? extra_header : ""), status, title, title, text) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + c = NULL; + } return c; } diff --git a/main/utils.c b/main/utils.c index 9749949e1..a802fd324 100644 --- a/main/utils.c +++ b/main/utils.c @@ -954,8 +954,11 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st a->start_routine = start_routine; a->data = data; start_routine = dummy_start; - asprintf(&a->name, "%-20s started at [%5d] %s %s()", - start_fn, line, file, caller); + if (asprintf(&a->name, "%-20s started at [%5d] %s %s()", + start_fn, line, file, caller) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + a->name = NULL; + } data = a; } #endif /* !LOW_MEMORY */ diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 3314ac031..aa1d17d5c 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -723,10 +723,16 @@ static char *complete_context_remove_extension_deprecated(const char *line, cons if (++which > state) { /* If there is an extension then return exten@context. */ if (ast_get_extension_matchcid(e) && (!strchr(word, '@') || strchr(word, '/'))) { - asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)); + if (asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + ret = NULL; + } break; } else if (!ast_get_extension_matchcid(e) && !strchr(word, '/')) { - asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)); + if (asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + ret = NULL; + } break; } } @@ -863,10 +869,16 @@ static char *complete_context_remove_extension(const char *line, const char *wor if (++which > state) { /* If there is an extension then return exten@context. */ if (ast_get_extension_matchcid(e) && (!strchr(word, '@') || strchr(word, '/'))) { - asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)); + if (asprintf(&ret, "%s/%s@%s", ast_get_extension_name(e), ast_get_extension_cidmatch(e), ast_get_context_name(c)) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + ret = NULL; + } break; } else if (!ast_get_extension_matchcid(e) && !strchr(word, '/')) { - asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)); + if (asprintf(&ret, "%s@%s", ast_get_extension_name(e), ast_get_context_name(c)) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + ret = NULL; + } break; } } diff --git a/res/res_jabber.c b/res/res_jabber.c index 0c3bf6505..0079ee9ff 100644 --- a/res/res_jabber.c +++ b/res/res_jabber.c @@ -629,8 +629,7 @@ static int aji_act_hook(void *data, int type, iks *node) sprintf(secret, "%s%s", pak->id, client->password); ast_sha1_hash(shasum, secret); handshake = NULL; - asprintf(&handshake, "%s", shasum); - if (handshake) { + if (asprintf(&handshake, "%s", shasum) > 0) { iks_send_raw(client->p, handshake); free(handshake); handshake = NULL; @@ -2205,8 +2204,7 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug) } if (!strchr(client->user, '/') && !client->component) { /*client */ resource = NULL; - asprintf(&resource, "%s/asterisk", client->user); - if (resource) { + if (asprintf(&resource, "%s/asterisk", client->user) > 0) { client->jid = iks_id_new(client->stack, resource); free(resource); } @@ -2222,8 +2220,7 @@ static int aji_create_client(char *label, struct ast_variable *var, int debug) } if (!strchr(client->user, '/') && !client->component) { /*client */ resource = NULL; - asprintf(&resource, "%s/asterisk", client->user); - if (resource) { + if (asprintf(&resource, "%s/asterisk", client->user) > 0) { client->jid = iks_id_new(client->stack, resource); free(resource); } -- cgit v1.2.3