diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-02 23:56:13 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2008-11-02 23:56:13 +0000 |
commit | ee246d0e0519c6aa7cb0aea17ea92c9a5c2dc16f (patch) | |
tree | 80dccc06626175232f48f4c2cde5b9f5ba602632 /funcs | |
parent | 11aedae560fa003f20ee8d7a02b7aa2fc17ae13a (diff) |
import gcc 4.3.2 warning fixes from trunk, with a few changes specific to this branch
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@153710 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_odbc.c | 64 |
1 files changed, 40 insertions, 24 deletions
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index efd42ce7f..6ae3eb3a1 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -628,6 +628,7 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu { const char *tmp; int i; + int res; if (!cfg || !catg) { return EINVAL; @@ -717,9 +718,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)) { @@ -729,7 +734,10 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu return ENOMEM; } - asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name); + if (asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name) < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + (*query)->acf->syntax = NULL; + } if (!((*query)->acf->syntax)) { ast_free((char *)(*query)->acf->name); @@ -740,29 +748,31 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu } (*query)->acf->synopsis = "Runs the referenced query with the specified arguments"; + + res = 0; 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_free((char *)(*query)->acf->syntax); ast_free((char *)(*query)->acf->name); @@ -772,7 +782,13 @@ static int init_acf_query(struct ast_config *cfg, char *catg, struct acf_odbc_qu return EINVAL; } - if (! ((*query)->acf->desc)) { + if (res < 0) { + ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); + (*query)->acf->desc = NULL; + } + + + if (!((*query)->acf->desc)) { ast_free((char *)(*query)->acf->syntax); ast_free((char *)(*query)->acf->name); ast_free((*query)->acf); |