Fix more "set but unused" warnings.

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@317474 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant
2011-05-05 22:36:33 +00:00
parent 3bc585feaf
commit 1ccfa50ba8
14 changed files with 48 additions and 72 deletions

View File

@@ -151,7 +151,7 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
char coltitle[256];
char rowdata[2048];
char *op;
const char *newparam, *newval;
const char *newparam;
char *stringp;
char *chunk;
SQLSMALLINT collen;
@@ -193,7 +193,7 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
ast_string_field_free_memory(&cps);
return NULL;
}
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?%s", table, newparam, op,
strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
@@ -201,7 +201,7 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,
strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
}
va_end(aq);
@@ -317,7 +317,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
char rowdata[2048];
const char *initfield=NULL;
char *op;
const char *newparam, *newval;
const char *newparam;
char *stringp;
char *chunk;
SQLSMALLINT collen;
@@ -358,7 +358,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
initfield = ast_strdupa(newparam);
if ((op = strchr(initfield, ' ')))
*op = '\0';
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?%s", table, newparam, op,
strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
@@ -366,7 +366,7 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,
strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
}
if (initfield)
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s", initfield);
@@ -476,7 +476,7 @@ static int update_odbc(const char *database, const char *table, const char *keyf
SQLHSTMT stmt;
char sql[256];
SQLLEN rowcount=0;
const char *newparam, *newval;
const char *newparam;
int res, count = 1;
va_list aq;
struct custom_prepare_struct cps = { .sql = sql, .extra = lookup };
@@ -509,7 +509,7 @@ static int update_odbc(const char *database, const char *table, const char *keyf
ast_string_field_free_memory(&cps);
return -1;
}
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
if (tableptr && !(column = 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);
@@ -517,7 +517,7 @@ static int update_odbc(const char *database, const char *table, const char *keyf
snprintf(sql, sizeof(sql), "UPDATE %s SET %s=?", table, newparam);
while((newparam = va_arg(aq, const char *))) {
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
if ((tableptr && (column = ast_odbc_find_column(tableptr, newparam))) || count > 63) {
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=?", newparam);
} else { /* the column does not exist in the table */
@@ -716,7 +716,7 @@ static int store_odbc(const char *database, const char *table, va_list ap)
char keys[256];
char vals[256];
SQLLEN rowcount=0;
const char *newparam, *newval;
const char *newparam;
int res;
va_list aq;
struct custom_prepare_struct cps = { .sql = sql, .extra = NULL };
@@ -737,13 +737,13 @@ static int store_odbc(const char *database, const char *table, va_list ap)
ast_odbc_release_obj(obj);
return -1;
}
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
snprintf(keys, sizeof(keys), "%s", newparam);
ast_copy_string(vals, "?", sizeof(vals));
while ((newparam = va_arg(aq, const char *))) {
snprintf(keys + strlen(keys), sizeof(keys) - strlen(keys), ", %s", newparam);
snprintf(vals + strlen(vals), sizeof(vals) - strlen(vals), ", ?");
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
}
va_end(aq);
snprintf(sql, sizeof(sql), "INSERT INTO %s (%s) VALUES (%s)", table, keys, vals);
@@ -791,7 +791,7 @@ static int destroy_odbc(const char *database, const char *table, const char *key
SQLHSTMT stmt;
char sql[256];
SQLLEN rowcount=0;
const char *newparam, *newval;
const char *newparam;
int res;
va_list aq;
struct custom_prepare_struct cps = { .sql = sql, .extra = lookup };
@@ -810,7 +810,7 @@ static int destroy_odbc(const char *database, const char *table, const char *key
snprintf(sql, sizeof(sql), "DELETE FROM %s WHERE ", table);
while((newparam = va_arg(aq, const char *))) {
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%s=? AND ", newparam);
newval = va_arg(aq, const char *);
va_arg(aq, const char *);
}
va_end(aq);
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), "%s=?", keyfield);

View File

@@ -1618,7 +1618,7 @@ static int realtime_require_handler(const char *unused, const char *tablename, v
struct sqlite_cache_tables *tbl = find_table(tablename);
struct sqlite_cache_columns *col;
char *elm;
int type, size, res = 0;
int type, res = 0;
if (!tbl) {
return -1;
@@ -1626,7 +1626,7 @@ static int realtime_require_handler(const char *unused, const char *tablename, v
while ((elm = va_arg(ap, char *))) {
type = va_arg(ap, require_type);
size = va_arg(ap, int);
va_arg(ap, int);
/* Check if the field matches the criteria */
AST_RWLIST_TRAVERSE(&tbl->columns, col, list) {
if (strcmp(col->name, elm) == 0) {

View File

@@ -99,7 +99,8 @@ static int pw_cb(char *buf, int size, int rwflag, void *userdata)
{
struct ast_key *key = (struct ast_key *)userdata;
char prompt[256];
int res, tmp;
int tmp;
int res;
if (key->infd < 0) {
/* Note that we were at least called */
@@ -118,6 +119,9 @@ static int pw_cb(char *buf, int size, int rwflag, void *userdata)
tmp = ast_hide_password(key->infd);
memset(buf, 0, size);
res = read(key->infd, buf, size);
if (res == -1) {
ast_log(LOG_WARNING, "read() failed: %s\n", strerror(errno));
}
ast_restore_tty(key->infd, tmp);
if (buf[strlen(buf) -1] == '\n') {
buf[strlen(buf) - 1] = '\0';

View File

@@ -2873,7 +2873,6 @@ static int aji_register_transport2(void *data, ikspak *pak)
*/
static void aji_pruneregister(struct aji_client *client)
{
int res = 0;
iks *removeiq = iks_new("iq");
iks *removequery = iks_new("query");
iks *removeitem = iks_new("item");
@@ -2890,10 +2889,10 @@ static void aji_pruneregister(struct aji_client *client)
/* For an aji_buddy, both AUTOPRUNE and AUTOREGISTER will never
* be called at the same time */
if (ast_test_flag(&iterator->flags, AJI_AUTOPRUNE)) { /* If autoprune is set on jabber.conf */
res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name,
ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBE, iterator->name,
"GoodBye. Your status is no longer needed by Asterisk the Open Source PBX"
" so I am no longer subscribing to your presence.\n"));
res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name,
ast_aji_send(client, iks_make_s10n(IKS_TYPE_UNSUBSCRIBED, iterator->name,
"GoodBye. You are no longer in the Asterisk config file so I am removing"
" your access to my presence.\n"));
iks_insert_attrib(removeiq, "from", client->jid->full);
@@ -2901,9 +2900,9 @@ static void aji_pruneregister(struct aji_client *client)
iks_insert_attrib(removequery, "xmlns", "jabber:iq:roster");
iks_insert_attrib(removeitem, "jid", iterator->name);
iks_insert_attrib(removeitem, "subscription", "remove");
res = ast_aji_send(client, removeiq);
ast_aji_send(client, removeiq);
} else if (ast_test_flag(&iterator->flags, AJI_AUTOREGISTER)) {
res = ast_aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name,
ast_aji_send(client, iks_make_s10n(IKS_TYPE_SUBSCRIBE, iterator->name,
"Greetings! I am the Asterisk Open Source PBX and I want to subscribe to your presence\n"));
ast_clear_flag(&iterator->flags, AJI_AUTOREGISTER);
}
@@ -3287,7 +3286,6 @@ static int aji_handle_pubsub_event(void *data, ikspak *pak)
*/
static void aji_create_affiliations(struct aji_client *client, const char *node)
{
int res = 0;
iks *modify_affiliates = aji_pubsub_iq_create(client, "set");
iks *pubsub, *affiliations, *affiliate;
pubsub = iks_insert(modify_affiliates, "pubsub");
@@ -3301,7 +3299,7 @@ static void aji_create_affiliations(struct aji_client *client, const char *node)
iks_insert_attrib(affiliate, "affiliation", "owner");
ASTOBJ_UNLOCK(iterator);
});
res = ast_aji_send(client, modify_affiliates);
ast_aji_send(client, modify_affiliates);
iks_delete(modify_affiliates);
}
@@ -3503,13 +3501,12 @@ static int aji_handle_pubsub_error(void *data, ikspak *pak)
*/
static void aji_request_pubsub_nodes(struct aji_client *client, const char *collection)
{
int res = 0;
iks *request = aji_build_node_request(client, collection);
iks_filter_add_rule(client->f, aji_receive_node_list, client, IKS_RULE_TYPE,
IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid,
IKS_RULE_DONE);
res = ast_aji_send(client, request);
ast_aji_send(client, request);
iks_delete(request);
}
@@ -3646,13 +3643,12 @@ static char *aji_cli_purge_pubsub_nodes(struct ast_cli_entry *e, int cmd, struct
static void aji_pubsub_purge_nodes(struct aji_client *client, const char* collection_name)
{
int res = 0;
iks *request = aji_build_node_request(client, collection_name);
ast_aji_send(client, request);
iks_filter_add_rule(client->f, aji_delete_node_list, client, IKS_RULE_TYPE,
IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid,
IKS_RULE_DONE);
res = ast_aji_send(client, request);
ast_aji_send(client, request);
iks_delete(request);
}
@@ -3772,15 +3768,14 @@ const char *leaf_name)
static iks* aji_create_pubsub_node(struct aji_client *client, const char *node_type, const
char *name, const char *collection_name)
{
int res = 0;
iks *node = aji_pubsub_iq_create(client, "set");
iks *pubsub, *create, *configure;
iks *pubsub, *create;
pubsub = iks_insert(node, "pubsub");
iks_insert_attrib(pubsub, "xmlns", "http://jabber.org/protocol/pubsub");
create = iks_insert(pubsub, "create");
iks_insert_attrib(create, "node", name);
configure = aji_build_node_config(pubsub, node_type, collection_name);
res = ast_aji_send(client, node);
aji_build_node_config(pubsub, node_type, collection_name);
ast_aji_send(client, node);
aji_create_affiliations(client, name);
iks_delete(node);
return 0;
@@ -3924,7 +3919,6 @@ static char *aji_cli_create_leafnode(struct ast_cli_entry *e, int cmd, struct as
*/
static void aji_set_presence(struct aji_client *client, char *to, char *from, int level, char *desc)
{
int res = 0;
iks *presence = iks_make_pres(level, desc);
iks *cnode = iks_new("c");
iks *priority = iks_new("priority");
@@ -3945,7 +3939,7 @@ static void aji_set_presence(struct aji_client *client, char *to, char *from, in
iks_insert_attrib(cnode, "ext", "voice-v1");
iks_insert_attrib(cnode, "xmlns", "http://jabber.org/protocol/caps");
iks_insert_node(presence, cnode);
res = ast_aji_send(client, presence);
ast_aji_send(client, presence);
} else {
ast_log(LOG_ERROR, "Out of memory.\n");
}