Remove -Wno-unused-parameter

Introduced UNUSED macro with cast to void in commoh.h for internal
use. Used cast to void directly in those files which do not
include common.h. Although this change doesn't fix semantic issues
with unused function parameters, it does explicitly mark all those
places, which might require attention in future.
This commit is contained in:
Oleg Synelnykov
2019-12-23 21:45:54 -06:00
committed by Dmitry Podgorny
parent 20c039fdb8
commit 198bdd77d0
33 changed files with 150 additions and 14 deletions

View File

@@ -109,6 +109,8 @@ static int _handle_error(xmpp_conn_t *const conn,
xmpp_stanza_t *child;
const char *name;
UNUSED(userdata);
/* free old stream error if it's still there */
if (conn->stream_error) {
xmpp_stanza_release(conn->stream_error->stanza);
@@ -200,6 +202,8 @@ static int _handle_error(xmpp_conn_t *const conn,
static int _handle_missing_features(xmpp_conn_t *const conn,
void *const userdata)
{
UNUSED(userdata);
xmpp_debug(conn->ctx, "xmpp", "didn't get stream features");
/* legacy auth will be attempted */
@@ -216,6 +220,8 @@ static int _handle_features(xmpp_conn_t *const conn,
const char *ns;
char *text;
UNUSED(userdata);
/* remove the handler that detects missing stream:features */
xmpp_timed_handler_delete(conn, _handle_missing_features);
@@ -293,6 +299,8 @@ static int _handle_proceedtls_default(xmpp_conn_t *const conn,
{
const char *name;
UNUSED(userdata);
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp", "handle proceedtls called for %s", name);
@@ -357,6 +365,8 @@ static int _handle_digestmd5_challenge(xmpp_conn_t *const conn,
xmpp_stanza_t *auth, *authdata;
const char *name;
UNUSED(userdata);
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp", "handle digest-md5 (challenge) called for %s",
name);
@@ -412,6 +422,8 @@ static int _handle_digestmd5_rspauth(xmpp_conn_t *const conn,
xmpp_stanza_t *auth;
const char *name;
UNUSED(userdata);
name = xmpp_stanza_get_name(stanza);
xmpp_debug(conn->ctx, "xmpp", "handle digest-md5 (rspauth) called for %s",
name);
@@ -825,6 +837,8 @@ static int _handle_features_sasl(xmpp_conn_t *const conn,
const char *ns;
char *resource;
UNUSED(userdata);
/* remove missing features handler */
xmpp_timed_handler_delete(conn, _handle_missing_features_sasl);
@@ -925,6 +939,8 @@ static int _handle_features_sasl(xmpp_conn_t *const conn,
static int _handle_missing_features_sasl(xmpp_conn_t *const conn,
void *const userdata)
{
UNUSED(userdata);
xmpp_error(conn->ctx, "xmpp",
"Did not receive stream features "
"after SASL authentication.");
@@ -939,6 +955,8 @@ static int _handle_bind(xmpp_conn_t *const conn,
const char *type;
xmpp_stanza_t *iq, *session;
UNUSED(userdata);
/* delete missing bind handler */
xmpp_timed_handler_delete(conn, _handle_missing_bind);
@@ -1006,6 +1024,8 @@ static int _handle_bind(xmpp_conn_t *const conn,
static int _handle_missing_bind(xmpp_conn_t *const conn, void *const userdata)
{
UNUSED(userdata);
xmpp_error(conn->ctx, "xmpp", "Server did not reply to bind request.");
xmpp_disconnect(conn);
return 0;
@@ -1017,6 +1037,8 @@ static int _handle_session(xmpp_conn_t *const conn,
{
const char *type;
UNUSED(userdata);
/* delete missing session handler */
xmpp_timed_handler_delete(conn, _handle_missing_session);
@@ -1043,6 +1065,8 @@ static int _handle_session(xmpp_conn_t *const conn,
static int _handle_missing_session(xmpp_conn_t *const conn,
void *const userdata)
{
UNUSED(userdata);
xmpp_error(conn->ctx, "xmpp", "Server did not reply to session request.");
xmpp_disconnect(conn);
return 0;
@@ -1050,6 +1074,8 @@ static int _handle_missing_session(xmpp_conn_t *const conn,
static int _handle_missing_legacy(xmpp_conn_t *const conn, void *const userdata)
{
UNUSED(userdata);
xmpp_error(conn->ctx, "xmpp",
"Server did not reply to legacy "
"authentication request.");
@@ -1064,6 +1090,8 @@ static int _handle_legacy(xmpp_conn_t *const conn,
const char *type;
const char *name;
UNUSED(userdata);
/* delete missing handler */
xmpp_timed_handler_delete(conn, _handle_missing_legacy);
@@ -1264,6 +1292,8 @@ int _handle_component_hs_response(xmpp_conn_t *const conn,
{
const char *name;
UNUSED(userdata);
xmpp_timed_handler_delete(conn, _handle_missing_handshake);
name = xmpp_stanza_get_name(stanza);
@@ -1290,6 +1320,8 @@ int _handle_component_hs_response(xmpp_conn_t *const conn,
int _handle_missing_handshake(xmpp_conn_t *const conn, void *const userdata)
{
UNUSED(userdata);
xmpp_error(conn->ctx, "xmpp", "Server did not reply to handshake request.");
xmpp_disconnect(conn);
return 0;

View File

@@ -130,6 +130,8 @@ struct _xmpp_handlist_t {
} u;
};
#define UNUSED(x) ((void)(x))
#define MAX_DOMAIN_LEN 256
#define SASL_MASK_PLAIN (1 << 0)

View File

@@ -1065,6 +1065,8 @@ int xmpp_conn_is_disconnected(xmpp_conn_t *const conn)
/* timed handler for cleanup if normal disconnect procedure takes too long */
static int _disconnect_cleanup(xmpp_conn_t *const conn, void *const userdata)
{
UNUSED(userdata);
xmpp_debug(conn->ctx, "xmpp", "disconnection forced by cleanup timeout");
conn_disconnect(conn);
@@ -1229,6 +1231,8 @@ static void _handle_stream_end(char *name, void *const userdata)
{
xmpp_conn_t *conn = (xmpp_conn_t *)userdata;
UNUSED(name);
/* stream is over */
xmpp_debug(conn->ctx, "xmpp", "RECV: </stream:stream>");
conn_disconnect_clean(conn);

View File

@@ -123,16 +123,19 @@ int xmpp_version_check(int major, int minor)
*/
static void *_malloc(const size_t size, void *const userdata)
{
UNUSED(userdata);
return malloc(size);
}
static void _free(void *p, void *const userdata)
{
UNUSED(userdata);
free(p);
}
static void *_realloc(void *p, const size_t size, void *const userdata)
{
UNUSED(userdata);
return realloc(p, size);
}

View File

@@ -123,6 +123,11 @@ static void _start_element(void *userdata,
xmpp_stanza_t *child;
char **cbattrs;
UNUSED(prefix);
UNUSED(nnamespaces);
UNUSED(namespaces);
UNUSED(ndefaulted);
if (parser->depth == 0) {
/* notify the owner */
if (parser->startcb) {
@@ -178,6 +183,9 @@ static void _end_element(void *userdata,
{
parser_t *parser = (parser_t *)userdata;
UNUSED(prefix);
UNUSED(uri);
parser->depth--;
if (parser->depth == 0) {

View File

@@ -500,6 +500,8 @@ static void ares_srv_lookup_callback(
{
struct resolver_ares_ctx *actx = arg;
(void)timeouts;
if (status != ARES_SUCCESS)
actx->result = XMPP_DOMAIN_NOT_FOUND;
else

View File

@@ -184,6 +184,8 @@ static char *_add_key(xmpp_ctx_t *ctx,
const char *value, *qvalue;
char *c;
UNUSED(len);
/* allocate a zero-length string if necessary */
if (buf == NULL) {
buf = xmpp_alloc(ctx, 1);
@@ -405,6 +407,8 @@ char *sasl_scram(xmpp_ctx_t *ctx,
size_t response_len;
size_t auth_len;
UNUSED(jid);
tmp = xmpp_strdup(ctx, challenge);
if (!tmp) {
return NULL;

View File

@@ -35,57 +35,73 @@ void tls_shutdown(void)
tls_t *tls_new(xmpp_conn_t *conn)
{
UNUSED(conn);
/* always fail */
return NULL;
}
void tls_free(tls_t *tls)
{
UNUSED(tls);
return;
}
int tls_set_credentials(tls_t *tls, const char *cafilename)
{
UNUSED(tls);
UNUSED(cafilename);
return -1;
}
int tls_start(tls_t *tls)
{
UNUSED(tls);
return -1;
}
int tls_stop(tls_t *tls)
{
UNUSED(tls);
return -1;
}
int tls_error(tls_t *tls)
{
UNUSED(tls);
/* todo: some kind of error polling/dump */
return 0;
}
int tls_pending(tls_t *tls)
{
UNUSED(tls);
return 0;
}
int tls_read(tls_t *tls, void *const buff, const size_t len)
{
UNUSED(tls);
UNUSED(buff);
UNUSED(len);
return -1;
}
int tls_write(tls_t *tls, const void *const buff, const size_t len)
{
UNUSED(tls);
UNUSED(buff);
UNUSED(len);
return -1;
}
int tls_clear_pending_write(tls_t *tls)
{
UNUSED(tls);
return -1;
}
int tls_is_recoverable(int error)
{
UNUSED(error);
return 0;
}

View File

@@ -142,5 +142,6 @@ int tls_write(tls_t *tls, const void *const buff, const size_t len)
int tls_clear_pending_write(tls_t *tls)
{
UNUSED(tls);
return 0;
}

View File

@@ -203,6 +203,8 @@ void tls_free(tls_t *tls)
int tls_set_credentials(tls_t *tls, const char *cafilename)
{
UNUSED(tls);
UNUSED(cafilename);
return -1;
}
@@ -305,6 +307,7 @@ int tls_write(tls_t *tls, const void *const buff, const size_t len)
int tls_clear_pending_write(tls_t *tls)
{
UNUSED(tls);
return 0;
}

View File

@@ -209,6 +209,8 @@ void tls_free(tls_t *tls)
int tls_set_credentials(tls_t *tls, const char *cafilename)
{
UNUSED(tls);
UNUSED(cafilename);
return -1;
}
@@ -377,6 +379,7 @@ int tls_start(tls_t *tls)
int tls_stop(tls_t *tls)
{
UNUSED(tls);
return -1;
}