diff --git a/ChangeLog.txt b/ChangeLog.txt index 275594ec..1701c5e4 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -9,6 +9,10 @@ Clients: - Set `receive-maximum` to not exceed the `-C` message count in mosquitto_sub and mosquitto_rr, to avoid potentially lost messages. Closes #2134. +Build: +- A variety of minor build related fixes, like functions not having previous + declarations. + 2.0.9 - 2021-03-11 ================== diff --git a/apps/db_dump/db_dump.c b/apps/db_dump/db_dump.c index ad6d2f7b..5ae009f2 100644 --- a/apps/db_dump/db_dump.c +++ b/apps/db_dump/db_dump.c @@ -27,6 +27,7 @@ Contributors: #include #include +#include "db_dump.h" #include #include #include diff --git a/apps/db_dump/print.c b/apps/db_dump/print.c index 84ca2ef0..bc4eac3e 100644 --- a/apps/db_dump/print.c +++ b/apps/db_dump/print.c @@ -19,6 +19,7 @@ Contributors: #include #include +#include "db_dump.h" #include #include #include @@ -142,7 +143,7 @@ static void print__properties(mosquitto_property *properties) } -void print__client(struct P_client *chunk, int length) +void print__client(struct P_client *chunk, uint32_t length) { printf("DB_CHUNK_CLIENT:\n"); printf("\tLength: %d\n", length); @@ -159,7 +160,7 @@ void print__client(struct P_client *chunk, int length) } -void print__client_msg(struct P_client_msg *chunk, int length) +void print__client_msg(struct P_client_msg *chunk, uint32_t length) { printf("DB_CHUNK_CLIENT_MSG:\n"); printf("\tLength: %d\n", length); @@ -175,8 +176,10 @@ void print__client_msg(struct P_client_msg *chunk, int length) } -void print__msg_store(struct P_msg_store *chunk, int length) +void print__msg_store(struct P_msg_store *chunk, uint32_t length) { + uint8_t *payload; + printf("DB_CHUNK_MSG_STORE:\n"); printf("\tLength: %d\n", length); printf("\tStore ID: %" PRIu64 "\n", chunk->F.store_id); @@ -190,8 +193,6 @@ void print__msg_store(struct P_msg_store *chunk, int length) printf("\tPayload Length: %d\n", chunk->F.payloadlen); printf("\tExpiry Time: %" PRIu64 "\n", chunk->F.expiry_time); - uint8_t *payload; - payload = chunk->payload; if(chunk->F.payloadlen < 256){ /* Print payloads with UTF-8 data below an arbitrary limit of 256 bytes */ diff --git a/apps/db_dump/stubs.c b/apps/db_dump/stubs.c index af00f706..8e233871 100644 --- a/apps/db_dump/stubs.c +++ b/apps/db_dump/stubs.c @@ -1,8 +1,10 @@ #include #include +#include "misc_mosq.h" #include "mosquitto_broker_internal.h" #include "mosquitto_internal.h" +#include "util_mosq.h" struct mosquitto *context__init(mosq_sock_t sock) { diff --git a/apps/mosquitto_ctrl/Makefile b/apps/mosquitto_ctrl/Makefile index 286eb449..502f0dac 100644 --- a/apps/mosquitto_ctrl/Makefile +++ b/apps/mosquitto_ctrl/Makefile @@ -12,7 +12,7 @@ LIBMOSQ:=../../lib/libmosquitto.a endif endif -LOCAL_CPPFLAGS:=-I../mosquitto_passwd +LOCAL_CPPFLAGS:=-I../mosquitto_passwd -DWITH_CJSON OBJS= mosquitto_ctrl.o \ client.o \ diff --git a/apps/mosquitto_ctrl/dynsec.c b/apps/mosquitto_ctrl/dynsec.c index fae86f43..c906cb2c 100644 --- a/apps/mosquitto_ctrl/dynsec.c +++ b/apps/mosquitto_ctrl/dynsec.c @@ -689,7 +689,7 @@ static cJSON *init_create(const char *username, const char *password, const char } /* mosquitto_ctrl dynsec init [role-name] */ -int dynsec_init(int argc, char *argv[]) +static int dynsec_init(int argc, char *argv[]) { char *filename; char *admin_user; diff --git a/apps/mosquitto_ctrl/mosquitto_ctrl.c b/apps/mosquitto_ctrl/mosquitto_ctrl.c index bda95902..b4433988 100644 --- a/apps/mosquitto_ctrl/mosquitto_ctrl.c +++ b/apps/mosquitto_ctrl/mosquitto_ctrl.c @@ -28,7 +28,7 @@ Contributors: #include "mosquitto.h" #include "mosquitto_ctrl.h" -void print_version(void) +static void print_version(void) { int major, minor, revision; @@ -36,7 +36,7 @@ void print_version(void) printf("mosquitto_ctrl version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision); } -void print_usage(void) +static void print_usage(void) { printf("mosquitto_ctrl is a tool for administering certain Mosquitto features.\n"); print_version(); @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) { struct mosq_ctrl ctrl; int rc = MOSQ_ERR_SUCCESS; - FUNC_ctrl_main ctrl_main = NULL; + FUNC_ctrl_main l_ctrl_main = NULL; void *lib = NULL; char lib_name[200]; @@ -76,22 +76,22 @@ int main(int argc, char *argv[]) /* In built modules */ if(!strcasecmp(argv[0], "dynsec")){ - ctrl_main = dynsec__main; + l_ctrl_main = dynsec__main; }else{ /* Attempt external module */ snprintf(lib_name, sizeof(lib_name), "mosquitto_ctrl_%s.so", argv[0]); lib = LIB_LOAD(lib_name); if(lib){ - ctrl_main = (FUNC_ctrl_main)LIB_SYM(lib, "ctrl_main"); + l_ctrl_main = (FUNC_ctrl_main)LIB_SYM(lib, "ctrl_main"); } } - if(ctrl_main == NULL){ + if(l_ctrl_main == NULL){ fprintf(stderr, "Error: Module '%s' not supported.\n", argv[0]); rc = MOSQ_ERR_NOT_SUPPORTED; } - if(ctrl_main){ - rc = ctrl_main(argc-1, &argv[1], &ctrl); + if(l_ctrl_main){ + rc = l_ctrl_main(argc-1, &argv[1], &ctrl); if(rc < 0){ /* Usage print */ rc = 0; diff --git a/apps/mosquitto_passwd/get_password.c b/apps/mosquitto_passwd/get_password.c index a62a76cd..42842536 100644 --- a/apps/mosquitto_passwd/get_password.c +++ b/apps/mosquitto_passwd/get_password.c @@ -35,7 +35,9 @@ Contributors: # include #endif -#define MAX_BUFFER_LEN 65536 +#include "get_password.h" + +#define MAX_BUFFER_LEN 65500 #define SALT_LEN 12 void get_password__reset_term(void) diff --git a/apps/mosquitto_passwd/mosquitto_passwd.c b/apps/mosquitto_passwd/mosquitto_passwd.c index 628bcc71..5a5a04f4 100644 --- a/apps/mosquitto_passwd/mosquitto_passwd.c +++ b/apps/mosquitto_passwd/mosquitto_passwd.c @@ -52,7 +52,7 @@ Contributors: # include #endif -#define MAX_BUFFER_LEN 65536 +#define MAX_BUFFER_LEN 65500 #define SALT_LEN 12 #include "misc_mosq.h" @@ -107,7 +107,7 @@ static FILE *mpw_tmpfile(void) #endif -void print_usage(void) +static void print_usage(void) { printf("mosquitto_passwd is a tool for managing password files for mosquitto.\n\n"); printf("Usage: mosquitto_passwd [-H sha512 | -H sha512-pbkdf2] [-c | -D] passwordfile username\n"); @@ -122,7 +122,7 @@ void print_usage(void) printf("\nSee https://mosquitto.org/ for more information.\n\n"); } -int output_new_password(FILE *fptr, const char *username, const char *password, int iterations) +static int output_new_password(FILE *fptr, const char *username, const char *password, int iterations) { int rc; char *salt64 = NULL, *hash64 = NULL; @@ -255,7 +255,7 @@ static int delete_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const return 0; } -int delete_pwuser(FILE *fptr, FILE *ftmp, const char *username) +static int delete_pwuser(FILE *fptr, FILE *ftmp, const char *username) { struct cb_helper helper; int rc; @@ -288,7 +288,7 @@ static int update_file_cb(FILE *fptr, FILE *ftmp, const char *username, const ch } } -int update_file(FILE *fptr, FILE *ftmp) +static int update_file(FILE *fptr, FILE *ftmp) { return pwfile_iterate(fptr, ftmp, update_file_cb, NULL); } @@ -315,7 +315,7 @@ static int update_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const return rc; } -int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *password, int iterations) +static int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *password, int iterations) { struct cb_helper helper; int rc; @@ -334,7 +334,7 @@ int update_pwuser(FILE *fptr, FILE *ftmp, const char *username, const char *pass } -int copy_contents(FILE *src, FILE *dest) +static int copy_contents(FILE *src, FILE *dest) { char buf[MAX_BUFFER_LEN]; size_t len; @@ -361,7 +361,7 @@ int copy_contents(FILE *src, FILE *dest) return 0; } -int create_backup(const char *backup_file, FILE *fptr) +static int create_backup(const char *backup_file, FILE *fptr) { FILE *fbackup; @@ -380,7 +380,7 @@ int create_backup(const char *backup_file, FILE *fptr) return 0; } -void handle_sigint(int signal) +static void handle_sigint(int signal) { get_password__reset_term(); diff --git a/client/client_shared.c b/client/client_shared.c index 68a12b39..f60b98be 100644 --- a/client/client_shared.c +++ b/client/client_shared.c @@ -183,7 +183,7 @@ static int check_format(const char *str) } -void init_config(struct mosq_config *cfg, int pub_or_sub) +static void init_config(struct mosq_config *cfg, int pub_or_sub) { memset(cfg, 0, sizeof(*cfg)); cfg->port = PORT_UNDEFINED; @@ -485,7 +485,7 @@ int client_config_load(struct mosq_config *cfg, int pub_or_sub, int argc, char * return MOSQ_ERR_SUCCESS; } -int cfg_add_topic(struct mosq_config *cfg, int type, char *topic, const char *arg) +static int cfg_add_topic(struct mosq_config *cfg, int type, char *topic, const char *arg) { if(mosquitto_validate_utf8(topic, (int )strlen(topic))){ fprintf(stderr, "Error: Malformed UTF-8 in %s argument.\n\n", arg); diff --git a/client/pub_client.c b/client/pub_client.c index 8049de6e..e82d90e0 100644 --- a/client/pub_client.c +++ b/client/pub_client.c @@ -232,7 +232,7 @@ int pub_shared_init(void) } -int pub_stdin_line_loop(struct mosquitto *mosq) +static int pub_stdin_line_loop(struct mosquitto *mosq) { char *buf2; int buf_len_actual = 0; @@ -334,7 +334,7 @@ int pub_stdin_line_loop(struct mosquitto *mosq) } -int pub_other_loop(struct mosquitto *mosq) +static int pub_other_loop(struct mosquitto *mosq) { int rc; int loop_delay = 1000; @@ -387,7 +387,7 @@ void pub_shared_cleanup(void) } -void print_version(void) +static void print_version(void) { int major, minor, revision; @@ -395,7 +395,7 @@ void print_version(void) printf("mosquitto_pub version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision); } -void print_usage(void) +static void print_usage(void) { int major, minor, revision; diff --git a/client/rr_client.c b/client/rr_client.c index 2331a4ed..4b1edba4 100644 --- a/client/rr_client.c +++ b/client/rr_client.c @@ -50,8 +50,6 @@ enum rr__state { static enum rr__state client_state = rr_s_new; -extern struct mosq_config cfg; - bool process_messages = true; int msg_count = 0; struct mosquitto *g_mosq = NULL; @@ -59,7 +57,7 @@ static bool timed_out = false; static int connack_result = 0; #ifndef WIN32 -void my_signal_handler(int signum) +static void my_signal_handler(int signum) { if(signum == SIGALRM){ process_messages = false; @@ -80,7 +78,7 @@ int my_publish(struct mosquitto *mosq, int *mid, const char *topic, int payloadl } -void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties) +static void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties) { UNUSED(mosq); UNUSED(obj); @@ -151,7 +149,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag } -void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos) +static void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos) { UNUSED(obj); UNUSED(mid); @@ -179,7 +177,7 @@ void my_publish_callback(struct mosquitto *mosq, void *obj, int mid, int reason_ } -void print_version(void) +static void print_version(void) { int major, minor, revision; @@ -187,7 +185,7 @@ void print_version(void) printf("mosquitto_rr version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision); } -void print_usage(void) +static void print_usage(void) { int major, minor, revision; diff --git a/client/sub_client.c b/client/sub_client.c index e2cebcdc..72170ab2 100644 --- a/client/sub_client.c +++ b/client/sub_client.c @@ -48,7 +48,7 @@ static int connack_result = 0; bool connack_received = false; #ifndef WIN32 -void my_signal_handler(int signum) +static void my_signal_handler(int signum) { if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){ if(connack_received){ @@ -65,19 +65,7 @@ void my_signal_handler(int signum) #endif -void my_publish_callback(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties) -{ - UNUSED(obj); - UNUSED(reason_code); - UNUSED(properties); - - if(process_messages == false && (mid == last_mid || last_mid == 0)){ - mosquitto_disconnect_v5(mosq, 0, cfg.disconnect_props); - } -} - - -void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties) +static void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquitto_message *message, const mosquitto_property *properties) { int i; bool res; @@ -120,7 +108,7 @@ void my_message_callback(struct mosquitto *mosq, void *obj, const struct mosquit } } -void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties) +static void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flags, const mosquitto_property *properties) { int i; @@ -153,7 +141,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result, int flag } } -void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos) +static void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_count, const int *granted_qos) { int i; bool some_sub_allowed = (granted_qos[0] < 128); @@ -177,7 +165,7 @@ void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_c } } -void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *str) +static void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *str) { UNUSED(mosq); UNUSED(obj); @@ -186,7 +174,7 @@ void my_log_callback(struct mosquitto *mosq, void *obj, int level, const char *s printf("%s\n", str); } -void print_version(void) +static void print_version(void) { int major, minor, revision; @@ -194,7 +182,7 @@ void print_version(void) printf("mosquitto_sub version %s running on libmosquitto %d.%d.%d.\n", VERSION, major, minor, revision); } -void print_usage(void) +static void print_usage(void) { int major, minor, revision; diff --git a/config.mk b/config.mk index d31b1160..d7b14b75 100644 --- a/config.mk +++ b/config.mk @@ -148,7 +148,7 @@ ifeq ($(UNAME),SunOS) CFLAGS?=-Wall -ggdb -O2 endif else - CFLAGS?=-Wall -ggdb -O2 -Wconversion + CFLAGS?=-Wall -ggdb -O2 -Wconversion -Wextra endif STATIC_LIB_DEPS:= diff --git a/lib/handle_auth.c b/lib/handle_auth.c index e33d085d..61f3bb4f 100644 --- a/lib/handle_auth.c +++ b/lib/handle_auth.c @@ -26,6 +26,7 @@ Contributors: #include "mqtt_protocol.h" #include "packet_mosq.h" #include "property_mosq.h" +#include "read_handle.h" int handle__auth(struct mosquitto *mosq) diff --git a/lib/handle_disconnect.c b/lib/handle_disconnect.c index a0a638db..28c51845 100644 --- a/lib/handle_disconnect.c +++ b/lib/handle_disconnect.c @@ -27,6 +27,7 @@ Contributors: #include "net_mosq.h" #include "packet_mosq.h" #include "property_mosq.h" +#include "read_handle.h" #include "send_mosq.h" #include "util_mosq.h" diff --git a/lib/handle_publish.c b/lib/handle_publish.c index 40644ef3..3fec2d53 100644 --- a/lib/handle_publish.c +++ b/lib/handle_publish.c @@ -29,6 +29,7 @@ Contributors: #include "messages_mosq.h" #include "packet_mosq.h" #include "property_mosq.h" +#include "read_handle.h" #include "send_mosq.h" #include "time_mosq.h" #include "util_mosq.h" diff --git a/lib/handle_suback.c b/lib/handle_suback.c index 91a40e26..770558be 100644 --- a/lib/handle_suback.c +++ b/lib/handle_suback.c @@ -31,6 +31,7 @@ Contributors: #include "mqtt_protocol.h" #include "packet_mosq.h" #include "property_mosq.h" +#include "read_handle.h" #include "util_mosq.h" diff --git a/lib/misc_mosq.c b/lib/misc_mosq.c index e7bf0784..8f2f2d2a 100644 --- a/lib/misc_mosq.c +++ b/lib/misc_mosq.c @@ -36,6 +36,8 @@ Contributors: # include #endif +#include "misc_mosq.h" + FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read) { diff --git a/lib/misc_mosq.h b/lib/misc_mosq.h index 233071e6..f86f5d76 100644 --- a/lib/misc_mosq.h +++ b/lib/misc_mosq.h @@ -19,6 +19,7 @@ Contributors: #define MISC_MOSQ_H #include +#include FILE *mosquitto__fopen(const char *path, const char *mode, bool restrict_read); char *misc__trimblanks(char *str); diff --git a/lib/net_mosq_ocsp.c b/lib/net_mosq_ocsp.c index 84b818c8..8c762373 100644 --- a/lib/net_mosq_ocsp.c +++ b/lib/net_mosq_ocsp.c @@ -64,10 +64,11 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg) OCSP_BASICRESP *br = NULL; X509_STORE *st = NULL; STACK_OF(X509) *ch = NULL; + long len; UNUSED(ssl); - long len = SSL_get_tlsext_status_ocsp_resp(mosq->ssl, &p); + len = SSL_get_tlsext_status_ocsp_resp(mosq->ssl, &p); log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: SSL_get_tlsext_status_ocsp_resp returned %ld bytes", len); /* the following functions expect a const pointer */ diff --git a/lib/property_mosq.c b/lib/property_mosq.c index 8a77dbe6..0cfc9f9c 100644 --- a/lib/property_mosq.c +++ b/lib/property_mosq.c @@ -33,7 +33,7 @@ Contributors: #include "property_mosq.h" -int property__read(struct mosquitto__packet *packet, uint32_t *len, mosquitto_property *property) +static int property__read(struct mosquitto__packet *packet, uint32_t *len, mosquitto_property *property) { int rc; uint32_t property_identifier; @@ -355,7 +355,7 @@ unsigned int property__get_remaining_length(const mosquitto_property *props) } -int property__write(struct mosquitto__packet *packet, const mosquitto_property *property) +static int property__write(struct mosquitto__packet *packet, const mosquitto_property *property) { int rc; @@ -975,7 +975,7 @@ int mosquitto_property_check_all(int command, const mosquitto_property *properti return MOSQ_ERR_SUCCESS; } -const mosquitto_property *property__get_property(const mosquitto_property *proplist, int identifier, bool skip_first) +static const mosquitto_property *property__get_property(const mosquitto_property *proplist, int identifier, bool skip_first) { const mosquitto_property *p; bool is_first = true; diff --git a/lib/send_connect.c b/lib/send_connect.c index d35cd80e..d9a3257c 100644 --- a/lib/send_connect.c +++ b/lib/send_connect.c @@ -32,6 +32,7 @@ Contributors: #include "mqtt_protocol.h" #include "packet_mosq.h" #include "property_mosq.h" +#include "send_mosq.h" int send__connect(struct mosquitto *mosq, uint16_t keepalive, bool clean_session, const mosquitto_property *properties) { diff --git a/lib/send_subscribe.c b/lib/send_subscribe.c index a8e77545..9217dc5b 100644 --- a/lib/send_subscribe.c +++ b/lib/send_subscribe.c @@ -32,10 +32,11 @@ Contributors: #include "mqtt_protocol.h" #include "packet_mosq.h" #include "property_mosq.h" +#include "send_mosq.h" #include "util_mosq.h" -int send__subscribe(struct mosquitto *mosq, int *mid, int topic_count, const char **topic, int topic_qos, const mosquitto_property *properties) +int send__subscribe(struct mosquitto *mosq, int *mid, int topic_count, char *const *const topic, int topic_qos, const mosquitto_property *properties) { struct mosquitto__packet *packet = NULL; uint32_t packetlen; diff --git a/lib/socks_mosq.c b/lib/socks_mosq.c index a360d64b..ed8fe128 100644 --- a/lib/socks_mosq.c +++ b/lib/socks_mosq.c @@ -23,7 +23,7 @@ Contributors: #include #ifdef WIN32 # include -#elif __QNX__ +#elif defined(__QNX__) # include # include # include @@ -40,6 +40,7 @@ Contributors: #include "net_mosq.h" #include "packet_mosq.h" #include "send_mosq.h" +#include "socks_mosq.h" #include "util_mosq.h" #define SOCKS_AUTH_NONE 0x00U diff --git a/lib/tls_mosq.c b/lib/tls_mosq.c index bddf2ec0..13d9aa22 100644 --- a/lib/tls_mosq.c +++ b/lib/tls_mosq.c @@ -84,7 +84,7 @@ int mosquitto__server_certificate_verify(int preverify_ok, X509_STORE_CTX *ctx) } } -int mosquitto__cmp_hostname_wildcard(char *certname, const char *hostname) +static int mosquitto__cmp_hostname_wildcard(char *certname, const char *hostname) { size_t i; size_t len; diff --git a/plugins/auth-by-ip/mosquitto_auth_by_ip.c b/plugins/auth-by-ip/mosquitto_auth_by_ip.c index 6a6f6289..49cc0178 100644 --- a/plugins/auth-by-ip/mosquitto_auth_by_ip.c +++ b/plugins/auth-by-ip/mosquitto_auth_by_ip.c @@ -32,7 +32,7 @@ Contributors: * * Note that this only works on Mosquitto 2.0 or later. */ - +#include "config.h" #include #include @@ -49,6 +49,9 @@ static int basic_auth_callback(int event, void *event_data, void *userdata) struct mosquitto_evt_basic_auth *ed = event_data; const char *ip_address; + UNUSED(event); + UNUSED(userdata); + ip_address = mosquitto_client_address(ed->client); if(!strcmp(ip_address, "127.0.0.1")){ /* Only allow connections from localhost */ @@ -72,11 +75,19 @@ int mosquitto_plugin_version(int supported_version_count, const int *supported_v int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, struct mosquitto_opt *opts, int opt_count) { + UNUSED(user_data); + UNUSED(opts); + UNUSED(opt_count); + mosq_pid = identifier; return mosquitto_callback_register(mosq_pid, MOSQ_EVT_BASIC_AUTH, basic_auth_callback, NULL, NULL); } int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *opts, int opt_count) { + UNUSED(user_data); + UNUSED(opts); + UNUSED(opt_count); + return mosquitto_callback_unregister(mosq_pid, MOSQ_EVT_BASIC_AUTH, basic_auth_callback, NULL); } diff --git a/src/conf.c b/src/conf.c index 33326c0c..bc4158ae 100644 --- a/src/conf.c +++ b/src/conf.c @@ -527,7 +527,7 @@ int config__parse_args(struct mosquitto__config *config, int argc, char *argv[]) return config__check(config); } -void config__copy(struct mosquitto__config *src, struct mosquitto__config *dest) +static void config__copy(struct mosquitto__config *src, struct mosquitto__config *dest) { mosquitto__free(dest->security_options.acl_file); dest->security_options.acl_file = src->security_options.acl_file; @@ -721,7 +721,7 @@ int config__read(struct mosquitto__config *config, bool reload) } -int config__read_file_core(struct mosquitto__config *config, bool reload, struct config_recurse *cr, int level, int *lineno, FILE *fptr, char **buf, int *buflen) +static int config__read_file_core(struct mosquitto__config *config, bool reload, struct config_recurse *cr, int level, int *lineno, FILE *fptr, char **buf, int *buflen) { int rc; char *token; diff --git a/src/conf_includedir.c b/src/conf_includedir.c index 5dda0a1e..9673ca5f 100644 --- a/src/conf_includedir.c +++ b/src/conf_includedir.c @@ -50,7 +50,7 @@ Contributors: #include "mqtt_protocol.h" -int scmp_p(const void *p1, const void *p2) +static int scmp_p(const void *p1, const void *p2) { const char *s1 = *(const char **)p1; const char *s2 = *(const char **)p2; diff --git a/src/database.c b/src/database.c index 2ba131c5..88253c57 100644 --- a/src/database.c +++ b/src/database.c @@ -580,7 +580,7 @@ int db__message_update_outgoing(struct mosquitto *context, uint16_t mid, enum mo } -void db__messages_delete_list(struct mosquitto_client_msg **head) +static void db__messages_delete_list(struct mosquitto_client_msg **head) { struct mosquitto_client_msg *tail, *tmp; @@ -624,7 +624,7 @@ int db__messages_delete(struct mosquitto *context, bool force_free) int db__messages_easy_queue(struct mosquitto *context, const char *topic, uint8_t qos, uint32_t payloadlen, const void *payload, int retain, uint32_t message_expiry_interval, mosquitto_property **properties) { struct mosquitto_msg_store *stored; - char *source_id; + const char *source_id; enum mosquitto_msg_origin origin; if(!topic) return MOSQ_ERR_INVAL; @@ -752,7 +752,7 @@ int db__message_store_find(struct mosquitto *context, uint16_t mid, struct mosqu /* Called on reconnect to set outgoing messages to a sensible state and force a * retry, and to set incoming messages to expect an appropriate retry. */ -int db__message_reconnect_reset_outgoing(struct mosquitto *context) +static int db__message_reconnect_reset_outgoing(struct mosquitto *context) { struct mosquitto_client_msg *msg, *tmp; @@ -821,7 +821,7 @@ int db__message_reconnect_reset_outgoing(struct mosquitto *context) /* Called on reconnect to set incoming messages to expect an appropriate retry. */ -int db__message_reconnect_reset_incoming(struct mosquitto *context) +static int db__message_reconnect_reset_incoming(struct mosquitto *context) { struct mosquitto_client_msg *msg, *tmp; @@ -975,63 +975,6 @@ int db__message_release_incoming(struct mosquitto *context, uint16_t mid) } } -int db__message_write_inflight_in(struct mosquitto *context) -{ - struct mosquitto_client_msg *tail, *tmp; - int rc; - - if(context->state != mosq_cs_active){ - return MOSQ_ERR_SUCCESS; - } - - DL_FOREACH_SAFE(context->msgs_in.inflight, tail, tmp){ - if(tail->store->message_expiry_time){ - if(db.now_real_s > tail->store->message_expiry_time){ - /* Message is expired, must not send. */ - db__message_remove(&context->msgs_in, tail); - if(tail->qos > 0){ - util__increment_receive_quota(context); - } - continue; - } - } - - switch(tail->state){ - case mosq_ms_send_pubrec: - rc = send__pubrec(context, tail->mid, 0, NULL); - if(!rc){ - tail->state = mosq_ms_wait_for_pubrel; - }else{ - return rc; - } - break; - - case mosq_ms_resend_pubcomp: - rc = send__pubcomp(context, tail->mid, NULL); - if(!rc){ - tail->state = mosq_ms_wait_for_pubrel; - }else{ - return rc; - } - break; - - case mosq_ms_invalid: - case mosq_ms_publish_qos0: - case mosq_ms_publish_qos1: - case mosq_ms_publish_qos2: - case mosq_ms_resend_pubrel: - case mosq_ms_wait_for_puback: - case mosq_ms_wait_for_pubrec: - case mosq_ms_wait_for_pubrel: - case mosq_ms_wait_for_pubcomp: - case mosq_ms_queued: - break; - } - } - return MOSQ_ERR_SUCCESS; -} - - static int db__message_write_inflight_out_single(struct mosquitto *context, struct mosquitto_client_msg *msg) { mosquitto_property *cmsg_props = NULL, *store_props = NULL; diff --git a/src/handle_connect.c b/src/handle_connect.c index b4cefad5..b031d200 100644 --- a/src/handle_connect.c +++ b/src/handle_connect.c @@ -83,7 +83,7 @@ static char *client_id_gen(uint16_t *idlen, const char *auto_id_prefix, uint16_t /* Remove any queued messages that are no longer allowed through ACL, * assuming a possible change of username. */ -void connection_check_acl(struct mosquitto *context, struct mosquitto_client_msg **head) +static void connection_check_acl(struct mosquitto *context, struct mosquitto_client_msg **head) { struct mosquitto_client_msg *msg_tail, *tmp; diff --git a/src/logging.c b/src/logging.c index 915ede23..cfac6a20 100644 --- a/src/logging.c +++ b/src/logging.c @@ -187,7 +187,7 @@ DltLogLevelType get_dlt_level(unsigned int priority) } #endif -int log__vprintf(unsigned int priority, const char *fmt, va_list va) +static int log__vprintf(unsigned int priority, const char *fmt, va_list va) { const char *topic; int syslog_priority; diff --git a/src/loop.c b/src/loop.c index 5044e7c8..dbee55a0 100644 --- a/src/loop.c +++ b/src/loop.c @@ -133,7 +133,7 @@ static void read_message_expiry_interval(mosquitto_property **proplist, uint32_t } } -void queue_plugin_msgs(void) +static void queue_plugin_msgs(void) { struct mosquitto_message_v5 *msg, *tmp; struct mosquitto *context; @@ -279,7 +279,7 @@ int mosquitto_main_loop(struct mosquitto__listener_sock *listensock, int listens void do_disconnect(struct mosquitto *context, int reason) { - char *id; + const char *id; #ifdef WITH_WEBSOCKETS bool is_duplicate = false; #endif diff --git a/src/mosquitto.c b/src/mosquitto.c index d3905ebe..1e5baec4 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -74,13 +74,6 @@ int allow_severity = LOG_INFO; int deny_severity = LOG_INFO; #endif -void handle_sigint(int signal); -void handle_sigusr1(int signal); -void handle_sigusr2(int signal); -#ifdef SIGHUP -void handle_sighup(int signal); -#endif - /* mosquitto shouldn't run as root. * This function will attempt to change to an unprivileged user and group if * running as root. The user is given in config->user. @@ -146,7 +139,7 @@ int drop_privileges(struct mosquitto__config *config) return MOSQ_ERR_SUCCESS; } -void mosquitto__daemonise(void) +static void mosquitto__daemonise(void) { #ifndef WIN32 char *err; @@ -208,7 +201,7 @@ void listeners__reload_all_certificates(void) } -int listeners__start_single_mqtt(struct mosquitto__listener *listener) +static int listeners__start_single_mqtt(struct mosquitto__listener *listener) { int i; struct mosquitto__listener_sock *listensock_new; @@ -275,7 +268,7 @@ void listeners__add_websockets(struct lws_context *ws_context, mosq_sock_t fd) } #endif -int listeners__add_local(const char *host, uint16_t port) +static int listeners__add_local(const char *host, uint16_t port) { struct mosquitto__listener *listeners; listeners = db.config->listeners; @@ -296,7 +289,7 @@ int listeners__add_local(const char *host, uint16_t port) return MOSQ_ERR_SUCCESS; } -int listeners__start_local_only(void) +static int listeners__start_local_only(void) { /* Attempt to open listeners bound to 127.0.0.1 and ::1 only */ int i; @@ -336,7 +329,7 @@ int listeners__start_local_only(void) } -int listeners__start(void) +static int listeners__start(void) { int i; @@ -380,7 +373,7 @@ int listeners__start(void) } -void listeners__stop(void) +static void listeners__stop(void) { int i; @@ -407,7 +400,7 @@ void listeners__stop(void) } -void signal__setup(void) +static void signal__setup(void) { signal(SIGINT, handle_sigint); signal(SIGTERM, handle_sigint); @@ -425,7 +418,7 @@ void signal__setup(void) } -int pid__write(void) +static int pid__write(void) { FILE *pid; diff --git a/src/mosquitto_broker_internal.h b/src/mosquitto_broker_internal.h index 6f6d48d2..c66126c8 100644 --- a/src/mosquitto_broker_internal.h +++ b/src/mosquitto_broker_internal.h @@ -819,6 +819,16 @@ void session_expiry__remove_all(void); void session_expiry__check(void); void session_expiry__send_all(void); +/* ============================================================ + * Signals + * ============================================================ */ +void handle_sigint(int signal); +void handle_sigusr1(int signal); +void handle_sigusr2(int signal); +#ifdef SIGHUP +void handle_sighup(int signal); +#endif + /* ============================================================ * Window service and signal related functions * ============================================================ */ @@ -855,4 +865,3 @@ void xtreport(void); #endif #endif - diff --git a/src/mux_epoll.c b/src/mux_epoll.c index 6b1b2e89..dd81b7d9 100644 --- a/src/mux_epoll.c +++ b/src/mux_epoll.c @@ -106,12 +106,6 @@ int mux_epoll__init(struct mosquitto__listener_sock *listensock, int listensock_ return MOSQ_ERR_SUCCESS; } -int mux_epoll__loop_setup(void) -{ - return MOSQ_ERR_SUCCESS; -} - - int mux_epoll__add_out(struct mosquitto *context) { struct epoll_event ev; diff --git a/src/net.c b/src/net.c index bbdb2708..cbcfc677 100644 --- a/src/net.c +++ b/src/net.c @@ -427,7 +427,7 @@ int net__tls_server_ctx(struct mosquitto__listener *listener) #endif -int net__load_crl_file(struct mosquitto__listener *listener) +static int net__load_crl_file(struct mosquitto__listener *listener) { #ifdef WITH_TLS X509_STORE *store; diff --git a/src/persist.h b/src/persist.h index 21c0e679..35081770 100644 --- a/src/persist.h +++ b/src/persist.h @@ -19,6 +19,8 @@ Contributors: #ifndef PERSIST_H #define PERSIST_H +#include "mosquitto_broker_internal.h" + #define MOSQ_DB_VERSION 6 /* DB read/write */ diff --git a/src/security.c b/src/security.c index 839ec31e..98b4d962 100644 --- a/src/security.c +++ b/src/security.c @@ -47,7 +47,7 @@ void LIB_ERROR(void) } -int security__load_v2(struct mosquitto__auth_plugin *plugin, struct mosquitto_auth_opt *auth_options, int auth_option_count, void *lib) +static int security__load_v2(struct mosquitto__auth_plugin *plugin, struct mosquitto_auth_opt *auth_options, int auth_option_count, void *lib) { int rc; @@ -121,7 +121,7 @@ int security__load_v2(struct mosquitto__auth_plugin *plugin, struct mosquitto_au } -int security__load_v3(struct mosquitto__auth_plugin *plugin, struct mosquitto_opt *auth_options, int auth_option_count, void *lib) +static int security__load_v3(struct mosquitto__auth_plugin *plugin, struct mosquitto_opt *auth_options, int auth_option_count, void *lib) { int rc; @@ -194,7 +194,7 @@ int security__load_v3(struct mosquitto__auth_plugin *plugin, struct mosquitto_op } -int security__load_v4(struct mosquitto__auth_plugin *plugin, struct mosquitto_opt *auth_options, int auth_option_count, void *lib) +static int security__load_v4(struct mosquitto__auth_plugin *plugin, struct mosquitto_opt *auth_options, int auth_option_count, void *lib) { int rc; diff --git a/src/security_default.c b/src/security_default.c index ec96e319..e659e7bf 100644 --- a/src/security_default.c +++ b/src/security_default.c @@ -202,7 +202,7 @@ int mosquitto_security_cleanup_default(bool reload) } -int add__acl(struct mosquitto__security_options *security_opts, const char *user, const char *topic, int access) +static int add__acl(struct mosquitto__security_options *security_opts, const char *user, const char *topic, int access) { struct mosquitto__acl_user *acl_user=NULL, *user_tail; struct mosquitto__acl *acl, *acl_tail; @@ -298,7 +298,7 @@ int add__acl(struct mosquitto__security_options *security_opts, const char *user return MOSQ_ERR_SUCCESS; } -int add__acl_pattern(struct mosquitto__security_options *security_opts, const char *topic, int access) +static int add__acl_pattern(struct mosquitto__security_options *security_opts, const char *topic, int access) { struct mosquitto__acl *acl, *acl_tail; char *local_topic; diff --git a/src/signals.c b/src/signals.c index 9938996f..82d911be 100644 --- a/src/signals.c +++ b/src/signals.c @@ -29,6 +29,8 @@ Contributors: #include #include +#include "mosquitto_broker_internal.h" + #ifdef WITH_PERSISTENCE extern bool flag_db_backup; #endif