Skip to content

Commit

Permalink
Remove -Wno-unused-parameter
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dissabte authored and pasis committed Mar 31, 2020
1 parent 20c039f commit 198bdd7
Show file tree
Hide file tree
Showing 33 changed files with 150 additions and 14 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Expand Up @@ -22,7 +22,7 @@ WARNING_FLAGS="-Wall"

AS_CASE([$PLATFORM],
[haiku], [],
[WARNING_FLAGS="$WARNING_FLAGS -Wextra -Wno-unused-parameter"])
[WARNING_FLAGS="$WARNING_FLAGS -Wextra"])

AC_ARG_WITH([libxml2],
[AS_HELP_STRING([--with-libxml2], [use libxml2 for XML parsing, expat is the default])])
Expand Down
5 changes: 5 additions & 0 deletions examples/active.c
Expand Up @@ -26,6 +26,8 @@ int handle_reply(xmpp_conn_t *const conn,
xmpp_stanza_t *query, *item;
const char *type;

(void)userdata;

type = xmpp_stanza_get_type(stanza);
if (strcmp(type, "error") == 0)
fprintf(stderr, "ERROR: query failed\n");
Expand Down Expand Up @@ -53,6 +55,9 @@ void conn_handler(xmpp_conn_t *const conn,
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
xmpp_stanza_t *iq, *query;

(void)error;
(void)stream_error;

if (status == XMPP_CONN_CONNECT) {
fprintf(stderr, "DEBUG: connected\n");

Expand Down
3 changes: 3 additions & 0 deletions examples/basic.c
Expand Up @@ -28,6 +28,9 @@ void conn_handler(xmpp_conn_t *const conn,
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
int secured;

(void)error;
(void)stream_error;

if (status == XMPP_CONN_CONNECT) {
fprintf(stderr, "DEBUG: connected\n");
secured = xmpp_conn_is_secured(conn);
Expand Down
3 changes: 3 additions & 0 deletions examples/bot.c
Expand Up @@ -126,6 +126,9 @@ void conn_handler(xmpp_conn_t *const conn,
{
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;

(void)error;
(void)stream_error;

if (status == XMPP_CONN_CONNECT) {
xmpp_stanza_t *pres;
fprintf(stderr, "DEBUG: connected\n");
Expand Down
3 changes: 3 additions & 0 deletions examples/component.c
Expand Up @@ -28,6 +28,9 @@ void conn_handler(xmpp_conn_t *const conn,
{
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;

(void)error;
(void)stream_error;

if (status == XMPP_CONN_CONNECT) {
fprintf(stderr, "DEBUG: connected\n");
xmpp_disconnect(conn);
Expand Down
12 changes: 12 additions & 0 deletions examples/register.c
Expand Up @@ -106,6 +106,8 @@ static int iq_reg2_cb(xmpp_conn_t *const conn,
{
const char *type;

(void)userdata;

type = xmpp_stanza_get_type(stanza);
if (!type || strcmp(type, "error") == 0) {
fprintf(stderr, "DEBUG: error during registration\n");
Expand Down Expand Up @@ -166,6 +168,9 @@ static int _handle_error(xmpp_conn_t *const conn,
xmpp_stanza_t *const stanza,
void *const userdata)
{
(void)stanza;
(void)userdata;

fprintf(stderr, "DEBUG: received stream error\n");
xmpp_disconnect(conn);

Expand All @@ -178,6 +183,8 @@ static int _handle_proceedtls_default(xmpp_conn_t *const conn,
{
const char *name = xmpp_stanza_get_name(stanza);

(void)userdata;

if (strcmp(name, "proceed") == 0) {
fprintf(stderr, "DEBUG: proceeding with TLS\n");
if (xmpp_conn_tls_start(conn) == 0) {
Expand All @@ -195,6 +202,8 @@ static int _handle_proceedtls_default(xmpp_conn_t *const conn,
static int _handle_missing_features(xmpp_conn_t *const conn,
void *const userdata)
{
(void)userdata;

fprintf(stderr, "DEBUG: timeout\n");
xmpp_disconnect(conn);

Expand Down Expand Up @@ -263,6 +272,9 @@ static void conn_handler(xmpp_conn_t *const conn,
xmpp_reg_t *reg = (xmpp_reg_t *)userdata;
int secured;

(void)error;
(void)stream_error;

if (status == XMPP_CONN_RAW_CONNECT) {
fprintf(stderr, "DEBUG: raw connection established\n");
xmpp_conn_open_stream_default(conn);
Expand Down
5 changes: 5 additions & 0 deletions examples/roster.c
Expand Up @@ -25,6 +25,8 @@ int handle_reply(xmpp_conn_t *const conn,
xmpp_stanza_t *query, *item;
const char *type, *name;

(void)userdata;

type = xmpp_stanza_get_type(stanza);
if (strcmp(type, "error") == 0)
fprintf(stderr, "ERROR: query failed\n");
Expand Down Expand Up @@ -58,6 +60,9 @@ void conn_handler(xmpp_conn_t *const conn,
xmpp_ctx_t *ctx = (xmpp_ctx_t *)userdata;
xmpp_stanza_t *iq, *query;

(void)error;
(void)stream_error;

if (status == XMPP_CONN_CONNECT) {
fprintf(stderr, "DEBUG: connected\n");

Expand Down
2 changes: 1 addition & 1 deletion examples/uuid.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <strophe.h>

int main(int argc, char **argv)
int main()
{
xmpp_ctx_t *ctx;
char *uuid;
Expand Down
2 changes: 2 additions & 0 deletions examples/vcard.c
Expand Up @@ -162,6 +162,8 @@ static vcard_cb_t vcard_cb_get(xmpp_stanza_t *stanza)

static int timedout(xmpp_conn_t *const conn, void *const userdata)
{
(void)userdata;

fprintf(stderr, "Timeout reached.\n");
xmpp_disconnect(conn);

Expand Down
32 changes: 32 additions & 0 deletions src/auth.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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 */
Expand All @@ -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);

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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.");
Expand All @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand All @@ -1043,13 +1065,17 @@ 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;
}

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.");
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/common.h
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/conn.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/ctx.c
Expand Up @@ -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);
}

Expand Down
8 changes: 8 additions & 0 deletions src/parser_libxml2.c
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions src/resolver.c
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/sasl.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 198bdd7

Please sign in to comment.