From 376226c129aafddcb0fc5592cab73e3b009204a1 Mon Sep 17 00:00:00 2001 From: "Roger A. Light" Date: Thu, 26 Aug 2021 10:54:03 +0100 Subject: [PATCH] Build warning fixes. --- buildtest.py | 3 ++- lib/net_mosq.c | 5 +++++ lib/options.c | 21 ++++++++++++++++++++- lib/send_publish.c | 2 +- lib/socks_mosq.c | 6 ++++++ lib/srv_mosq.c | 5 +++++ src/net.c | 10 ++++++---- src/plugin_public.c | 2 ++ src/retain.c | 3 +++ src/xtreport.c | 13 +++++++------ 10 files changed, 57 insertions(+), 13 deletions(-) diff --git a/buildtest.py b/buildtest.py index b28c273f..e85c2120 100755 --- a/buildtest.py +++ b/buildtest.py @@ -31,13 +31,14 @@ special_variants = [ ] +import os import random import subprocess def run_test(msg, opts): subprocess.run(["make", "clean"], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) print("%s: %s" % (msg, str(opts))) - args = ["make", "-j"] + opts + args = ["make", "-j%d" % (os.cpu_count())] + opts proc = subprocess.run(args, stdout=subprocess.DEVNULL) if proc.returncode != 0: raise RuntimeError("BUILD FAILED: %s" % (' '.join(args))) diff --git a/lib/net_mosq.c b/lib/net_mosq.c index aea34ab3..ce1bda71 100644 --- a/lib/net_mosq.c +++ b/lib/net_mosq.c @@ -920,6 +920,9 @@ int net__socket_connect_step3(struct mosquitto *mosq, const char *host) } } +#else + UNUSED(mosq); + UNUSED(host); #endif return MOSQ_ERR_SUCCESS; } @@ -1213,6 +1216,8 @@ void *mosquitto_ssl_get(struct mosquitto *mosq) #ifdef WITH_TLS return mosq->ssl; #else + UNUSED(mosq); + return NULL; #endif } diff --git a/lib/options.c b/lib/options.c index b16efce4..710c0cd4 100644 --- a/lib/options.c +++ b/lib/options.c @@ -205,6 +205,13 @@ int mosquitto_tls_set(struct mosquitto *mosq, const char *cafile, const char *ca return MOSQ_ERR_SUCCESS; #else + UNUSED(mosq); + UNUSED(cafile); + UNUSED(capath); + UNUSED(certfile); + UNUSED(keyfile); + UNUSED(pw_callback); + return MOSQ_ERR_NOT_SUPPORTED; #endif @@ -241,8 +248,12 @@ int mosquitto_tls_opts_set(struct mosquitto *mosq, int cert_reqs, const char *tl return MOSQ_ERR_SUCCESS; #else - return MOSQ_ERR_NOT_SUPPORTED; + UNUSED(mosq); + UNUSED(cert_reqs); + UNUSED(tls_version); + UNUSED(ciphers); + return MOSQ_ERR_NOT_SUPPORTED; #endif } @@ -254,6 +265,9 @@ int mosquitto_tls_insecure_set(struct mosquitto *mosq, bool value) mosq->tls_insecure = value; return MOSQ_ERR_SUCCESS; #else + UNUSED(mosq); + UNUSED(value); + return MOSQ_ERR_NOT_SUPPORTED; #endif } @@ -373,6 +387,11 @@ int mosquitto_tls_psk_set(struct mosquitto *mosq, const char *psk, const char *i return MOSQ_ERR_SUCCESS; #else + UNUSED(mosq); + UNUSED(psk); + UNUSED(identity); + UNUSED(ciphers); + return MOSQ_ERR_NOT_SUPPORTED; #endif } diff --git a/lib/send_publish.c b/lib/send_publish.c index 8a434c02..148ee29c 100644 --- a/lib/send_publish.c +++ b/lib/send_publish.c @@ -42,8 +42,8 @@ Contributors: int send__publish(struct mosquitto *mosq, uint16_t mid, const char *topic, uint32_t payloadlen, const void *payload, uint8_t qos, bool retain, bool dup, const mosquitto_property *cmsg_props, const mosquitto_property *store_props, uint32_t expiry_interval) { #ifdef WITH_BROKER -#ifdef WITH_BRIDGE size_t len; +#ifdef WITH_BRIDGE int i; struct mosquitto__bridge_topic *cur_topic; bool match; diff --git a/lib/socks_mosq.c b/lib/socks_mosq.c index ed8fe128..a7a0e035 100644 --- a/lib/socks_mosq.c +++ b/lib/socks_mosq.c @@ -108,6 +108,12 @@ int mosquitto_socks5_set(struct mosquitto *mosq, const char *host, int port, con return MOSQ_ERR_SUCCESS; #else + UNUSED(mosq); + UNUSED(host); + UNUSED(port); + UNUSED(username); + UNUSED(password); + return MOSQ_ERR_NOT_SUPPORTED; #endif } diff --git a/lib/srv_mosq.c b/lib/srv_mosq.c index 412fc1eb..3ee74f16 100644 --- a/lib/srv_mosq.c +++ b/lib/srv_mosq.c @@ -37,6 +37,9 @@ static void srv_callback(void *arg, int status, int timeouts, unsigned char *abu { struct mosquitto *mosq = arg; struct ares_srv_reply *reply = NULL; + + UNUSED(timeouts); + if(status == ARES_SUCCESS){ status = ares_parse_srv_reply(abuf, alen, &reply); if(status == ARES_SUCCESS){ @@ -69,6 +72,8 @@ int mosquitto_connect_srv(struct mosquitto *mosq, const char *host, int keepaliv int rc; if(!mosq) return MOSQ_ERR_INVAL; + UNUSED(bind_address); + if(keepalive < 0 || keepalive > UINT16_MAX){ return MOSQ_ERR_INVAL; } diff --git a/src/net.c b/src/net.c index e6616e3e..9bc9f807 100644 --- a/src/net.c +++ b/src/net.c @@ -434,9 +434,9 @@ int net__tls_server_ctx(struct mosquitto__listener *listener) #endif +#ifdef WITH_TLS static int net__load_crl_file(struct mosquitto__listener *listener) { -#ifdef WITH_TLS X509_STORE *store; X509_LOOKUP *lookup; int rc; @@ -456,10 +456,10 @@ static int net__load_crl_file(struct mosquitto__listener *listener) return MOSQ_ERR_TLS; } X509_STORE_set_flags(store, X509_V_FLAG_CRL_CHECK); -#endif return MOSQ_ERR_SUCCESS; } +#endif int net__load_certificates(struct mosquitto__listener *listener) @@ -499,14 +499,16 @@ int net__load_certificates(struct mosquitto__listener *listener) return rc; } } +#else + UNUSED(listener); #endif return MOSQ_ERR_SUCCESS; } +#if defined(WITH_TLS) && !defined(OPENSSL_NO_ENGINE) static int net__load_engine(struct mosquitto__listener *listener) { -#if defined(WITH_TLS) && !defined(OPENSSL_NO_ENGINE) ENGINE *engine = NULL; UI_METHOD *ui_method; EVP_PKEY *pkey; @@ -556,10 +558,10 @@ static int net__load_engine(struct mosquitto__listener *listener) } } ENGINE_free(engine); /* release the structural reference from ENGINE_by_id() */ -#endif return MOSQ_ERR_SUCCESS; } +#endif int net__tls_load_verify(struct mosquitto__listener *listener) diff --git a/src/plugin_public.c b/src/plugin_public.c index 5df56fec..dde66b41 100644 --- a/src/plugin_public.c +++ b/src/plugin_public.c @@ -80,6 +80,8 @@ void *mosquitto_client_certificate(const struct mosquitto *client) return NULL; } #else + UNUSED(client); + return NULL; #endif } diff --git a/src/retain.c b/src/retain.c index ee8ad609..6e324afa 100644 --- a/src/retain.c +++ b/src/retain.c @@ -106,7 +106,10 @@ int retain__store(const char *topic, struct mosquitto_msg_store *stored, char ** * they aren't for $SYS. */ db.persistence_changes++; } +#else + UNUSED(topic); #endif + if(retainhier->retained){ db__msg_store_ref_dec(&retainhier->retained); #ifdef WITH_SYS_TREE diff --git a/src/xtreport.c b/src/xtreport.c index 08750052..d9d69c77 100644 --- a/src/xtreport.c +++ b/src/xtreport.c @@ -34,10 +34,11 @@ Contributors: static void client_cost(FILE *fptr, struct mosquitto *context, int fn_index) { - size_t pkt_count, pkt_bytes; - size_t cmsg_count, cmsg_bytes; + long pkt_count, pkt_bytes; + long cmsg_count; + long cmsg_bytes; struct mosquitto__packet *pkt_tmp; - size_t tBytes; + long tBytes; pkt_count = 1; pkt_bytes = context->in_packet.packet_length; @@ -52,14 +53,14 @@ static void client_cost(FILE *fptr, struct mosquitto *context, int fn_index) pkt_tmp = pkt_tmp->next; } - cmsg_count = (size_t)context->msgs_in.msg_count; + cmsg_count = context->msgs_in.msg_count; cmsg_bytes = context->msgs_in.msg_bytes; - cmsg_count += (size_t)context->msgs_out.msg_count; + cmsg_count += context->msgs_out.msg_count; cmsg_bytes += context->msgs_out.msg_bytes; tBytes = pkt_bytes + cmsg_bytes; if(context->id){ - tBytes += strlen(context->id); + tBytes += (long)strlen(context->id); } fprintf(fptr, "%d %ld %lu %lu %lu %lu %d\n", fn_index, tBytes,