diff --git a/apps/db_dump/db_dump.c b/apps/db_dump/db_dump.c index 499660ab..af5fe2b0 100644 --- a/apps/db_dump/db_dump.c +++ b/apps/db_dump/db_dump.c @@ -42,8 +42,7 @@ Contributors: #include #endif -struct client_data -{ +struct client_data { UT_hash_handle hh_id; char *id; uint32_t subscriptions; @@ -52,8 +51,7 @@ struct client_data long message_size; }; -struct base_msg_chunk -{ +struct base_msg_chunk { UT_hash_handle hh; dbid_t store_id; uint32_t length; diff --git a/apps/db_dump/stubs.c b/apps/db_dump/stubs.c index 342b9c95..7c761bb1 100644 --- a/apps/db_dump/stubs.c +++ b/apps/db_dump/stubs.c @@ -9,22 +9,61 @@ # define UNUSED(A) (void)(A) #endif -struct mosquitto *context__init(void) { return NULL; } +struct mosquitto *context__init(void) +{ + return NULL; +} -void context__add_to_by_id(struct mosquitto *context) { UNUSED(context); } -int db__message_store(const struct mosquitto *source, struct mosquitto__base_msg *base_msg, uint32_t *message_expiry_interval, enum mosquitto_msg_origin origin) { UNUSED(source); UNUSED(base_msg); UNUSED(message_expiry_interval); UNUSED(origin); return 0; } +void context__add_to_by_id(struct mosquitto *context) +{ + UNUSED(context); +} -void db__msg_store_ref_inc(struct mosquitto__base_msg *base_msg) { UNUSED(base_msg); } -int log__printf(struct mosquitto *mosq, unsigned int level, const char *fmt, ...) { UNUSED(mosq); UNUSED(level); UNUSED(fmt); return 0; } +int db__message_store(const struct mosquitto *source, struct mosquitto__base_msg *base_msg, uint32_t *message_expiry_interval, enum mosquitto_msg_origin origin) +{ + UNUSED(source); UNUSED(base_msg); UNUSED(message_expiry_interval); UNUSED(origin); return 0; +} -int retain__store(const char *topic, struct mosquitto__base_msg *base_msg, char **split_topics, bool persist) { UNUSED(topic); UNUSED(base_msg); UNUSED(split_topics); UNUSED(persist); return 0; } -int sub__add(struct mosquitto *context, const struct mosquitto_subscription *sub) { UNUSED(context); UNUSED(sub); return 0; } +void db__msg_store_ref_inc(struct mosquitto__base_msg *base_msg) +{ + UNUSED(base_msg); +} -void db__msg_add_to_inflight_stats(struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg *msg) { UNUSED(msg_data); UNUSED(msg); } -void db__msg_add_to_queued_stats(struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg *msg) { UNUSED(msg_data); UNUSED(msg); } +int log__printf(struct mosquitto *mosq, unsigned int level, const char *fmt, ...) +{ + UNUSED(mosq); UNUSED(level); UNUSED(fmt); return 0; +} -int session_expiry__add_from_persistence(struct mosquitto *context, time_t expiry_time) { UNUSED(context); UNUSED(expiry_time); return 0; } + +int retain__store(const char *topic, struct mosquitto__base_msg *base_msg, char **split_topics, bool persist) +{ + UNUSED(topic); UNUSED(base_msg); UNUSED(split_topics); UNUSED(persist); return 0; +} + + +int sub__add(struct mosquitto *context, const struct mosquitto_subscription *sub) +{ + UNUSED(context); UNUSED(sub); return 0; +} + + +void db__msg_add_to_inflight_stats(struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg *msg) +{ + UNUSED(msg_data); UNUSED(msg); +} + + +void db__msg_add_to_queued_stats(struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg *msg) +{ + UNUSED(msg_data); UNUSED(msg); +} + + +int session_expiry__add_from_persistence(struct mosquitto *context, time_t expiry_time) +{ + UNUSED(context); UNUSED(expiry_time); return 0; +} diff --git a/apps/mosquitto_ctrl/ctrl_shell_dynsec.c b/apps/mosquitto_ctrl/ctrl_shell_dynsec.c index e6ed702a..adcec5cd 100644 --- a/apps/mosquitto_ctrl/ctrl_shell_dynsec.c +++ b/apps/mosquitto_ctrl/ctrl_shell_dynsec.c @@ -360,20 +360,22 @@ static int send_set_default_acl_access(char **saveptr) const char *acltype, *allow_s; acltype = strtok_r(NULL, " ", saveptr); - if(!acltype || ( - strcasecmp(acltype, "publishClientReceive") - && strcasecmp(acltype, "publishClientSend") - && strcasecmp(acltype, "subscribe") - && strcasecmp(acltype, "unsubscribe") + if(!acltype || + ( + strcasecmp(acltype, "publishClientReceive") + && strcasecmp(acltype, "publishClientSend") + && strcasecmp(acltype, "subscribe") + && strcasecmp(acltype, "unsubscribe") )){ ctrl_shell_printf("setDefaultACLAccess acltype allow|deny\n"); return MOSQ_ERR_INVAL; } allow_s = strtok_r(NULL, " ", saveptr); - if(!allow_s || ( - strcasecmp(allow_s, "allow") - && strcasecmp(allow_s, "deny") + if(!allow_s || + ( + strcasecmp(allow_s, "allow") + && strcasecmp(allow_s, "deny") )){ ctrl_shell_printf("setDefaultACLAccess acltype allow|deny\n"); return MOSQ_ERR_INVAL; diff --git a/apps/mosquitto_ctrl/ctrl_shell_post_connect.c b/apps/mosquitto_ctrl/ctrl_shell_post_connect.c index 78125c6f..518bca86 100644 --- a/apps/mosquitto_ctrl/ctrl_shell_post_connect.c +++ b/apps/mosquitto_ctrl/ctrl_shell_post_connect.c @@ -78,7 +78,7 @@ static void print_help(char **saveptr) } } -struct module_data{ +struct module_data { const char *name; void (*mod_init)(struct ctrl_shell__module *mod); }; diff --git a/client/client_props.c b/client/client_props.c index dcd725d8..9260602c 100644 --- a/client/client_props.c +++ b/client/client_props.c @@ -36,8 +36,7 @@ Contributors: #include "mosquitto.h" #include "client_shared.h" -enum prop_type -{ +enum prop_type { PROP_TYPE_BYTE, PROP_TYPE_INT16, PROP_TYPE_INT32, diff --git a/client/sub_client_output.c b/client/sub_client_output.c index 5c5885e7..ec61b839 100644 --- a/client/sub_client_output.c +++ b/client/sub_client_output.c @@ -19,7 +19,7 @@ Contributors: #include "config.h" #ifdef WIN32 - /* For rand_s on Windows */ +/* For rand_s on Windows */ # define _CRT_RAND_S # include # include @@ -55,7 +55,7 @@ Contributors: extern struct mosq_config cfg; -struct fieldoptions{ +struct fieldoptions { int field_width; int precision; char hexsepchar; @@ -63,7 +63,7 @@ struct fieldoptions{ char pad; }; -struct watch_topic{ +struct watch_topic { UT_hash_handle hh; char *topic; int line; diff --git a/lib/loop.c b/lib/loop.c index 15ae20e2..75905c13 100644 --- a/lib/loop.c +++ b/lib/loop.c @@ -194,9 +194,11 @@ static int interruptible_sleep(struct mosquitto *mosq, time_t reconnect_delay) int maxfd = 0; #ifndef WIN32 - while(mosq->sockpairR != INVALID_SOCKET && read(mosq->sockpairR, &pairbuf, 1) > 0); + while(mosq->sockpairR != INVALID_SOCKET && read(mosq->sockpairR, &pairbuf, 1) > 0){ + } #else - while(mosq->sockpairR != INVALID_SOCKET && recv(mosq->sockpairR, &pairbuf, 1, 0) > 0); + while(mosq->sockpairR != INVALID_SOCKET && recv(mosq->sockpairR, &pairbuf, 1, 0) > 0){ + } #endif local_timeout.tv_sec = reconnect_delay; diff --git a/lib/send_disconnect.c b/lib/send_disconnect.c index bccefb1e..0eb5079b 100644 --- a/lib/send_disconnect.c +++ b/lib/send_disconnect.c @@ -54,7 +54,6 @@ int send__disconnect(struct mosquitto *mosq, uint8_t reason_code, const mosquitt #else log__printf(mosq, MOSQ_LOG_DEBUG, "Client %s sending DISCONNECT", SAFE_PRINT(mosq->id)); #endif - assert(mosq); if(mosq->protocol == mosq_p_mqtt5 && (reason_code != 0 || properties)){ remaining_length = 1; diff --git a/libcommon/memory_common.c b/libcommon/memory_common.c index 2cf08ac9..785961be 100644 --- a/libcommon/memory_common.c +++ b/libcommon/memory_common.c @@ -138,7 +138,11 @@ void free(void *ptr) #define ALLOC_MARKER_SIZE 0 -static void set_alloc_marker(char* mem, size_t size) { UNUSED(mem); UNUSED(size); } + +static void set_alloc_marker(char *mem, size_t size) +{ + UNUSED(mem); UNUSED(size); +} #endif /* defined(ALLOC_MISMATCH_INVALID_READ) */ diff --git a/libcommon/password_common.c b/libcommon/password_common.c index 6e77fcf8..c709be82 100644 --- a/libcommon/password_common.c +++ b/libcommon/password_common.c @@ -33,7 +33,7 @@ Contributors: #ifdef WITH_TLS # define HASH_LEN EVP_MAX_MD_SIZE #else - /* 64 bytes big enough for SHA512 */ +/* 64 bytes big enough for SHA512 */ # define HASH_LEN 64 #endif @@ -47,7 +47,7 @@ Contributors: #define PW_DEFAULT_ITERATIONS 1000 static int pw__encode(struct mosquitto_pw *pw); -struct mosquitto_pw{ +struct mosquitto_pw { union { struct { unsigned char password_hash[HASH_LEN]; /* For SHA512 */ diff --git a/libcommon/topic_common.c b/libcommon/topic_common.c index 8f1583fa..20fa4be8 100644 --- a/libcommon/topic_common.c +++ b/libcommon/topic_common.c @@ -263,8 +263,7 @@ static int topic_matches_sub(const char *sub, const char *topic, const char *cli && spos > 0 && sub[-1] == '+' && sub[0] == '/' - && sub[1] == '#') - { + && sub[1] == '#'){ *result = true; return MOSQ_ERR_SUCCESS; } @@ -361,10 +360,11 @@ static int sub_matches_acl(const char *acl, const char *sub, const char *clienti /* no match */ return MOSQ_ERR_SUCCESS; } - if(pattern_check[1] == '\0' && ( - pattern_check[0] == '+' || - pattern_check[0] == '#' || - pattern_check[0] == '/') + if(pattern_check[1] == '\0' && + ( + pattern_check[0] == '+' || + pattern_check[0] == '#' || + pattern_check[0] == '/') ){ /* username/client id of just + / # not allowed */ @@ -435,8 +435,7 @@ static int sub_matches_acl(const char *acl, const char *sub, const char *clienti && apos > 0 && acl[-1] == '+' && acl[0] == '/' - && acl[1] == '#') - { + && acl[1] == '#'){ *result = true; return MOSQ_ERR_SUCCESS; } @@ -593,8 +592,7 @@ BROKER_EXPORT int mosquitto_topic_matches_sub2(const char *sub, size_t sublen, c && sub[spos-1] == '+' && sub[spos] == '/' && spos+1 < sublen - && sub[spos+1] == '#') - { + && sub[spos+1] == '#'){ *result = true; return MOSQ_ERR_SUCCESS; } diff --git a/plugins/dynamic-security/clients.c b/plugins/dynamic-security/clients.c index 36aa4d56..9d97600e 100644 --- a/plugins/dynamic-security/clients.c +++ b/plugins/dynamic-security/clients.c @@ -25,7 +25,7 @@ Contributors: #include "dynamic_security.h" #include "json_help.h" -struct connection_array_context{ +struct connection_array_context { const char *username; cJSON *j_connections; }; diff --git a/plugins/dynamic-security/control.c b/plugins/dynamic-security/control.c index d42edc7d..93276c49 100644 --- a/plugins/dynamic-security/control.c +++ b/plugins/dynamic-security/control.c @@ -44,7 +44,7 @@ static int dynsec__handle_command(struct mosquitto_control_cmd *cmd, void *userd }else if(!strcasecmp(cmd->command_name, "getDetails")){ rc = dynsec_details__process_get(data, cmd); - /* Clients */ + /* Clients */ }else if(!strcasecmp(cmd->command_name, "createClient")){ rc = dynsec_clients__process_create(data, cmd); }else if(!strcasecmp(cmd->command_name, "deleteClient")){ @@ -68,7 +68,7 @@ static int dynsec__handle_command(struct mosquitto_control_cmd *cmd, void *userd }else if(!strcasecmp(cmd->command_name, "disableClient")){ rc = dynsec_clients__process_disable(data, cmd); - /* Groups */ + /* Groups */ }else if(!strcasecmp(cmd->command_name, "addGroupClient")){ rc = dynsec_groups__process_add_client(data, cmd); }else if(!strcasecmp(cmd->command_name, "createGroup")){ @@ -92,7 +92,7 @@ static int dynsec__handle_command(struct mosquitto_control_cmd *cmd, void *userd }else if(!strcasecmp(cmd->command_name, "getAnonymousGroup")){ rc = dynsec_groups__process_get_anonymous_group(data, cmd); - /* Roles */ + /* Roles */ }else if(!strcasecmp(cmd->command_name, "createRole")){ rc = dynsec_roles__process_create(data, cmd); }else if(!strcasecmp(cmd->command_name, "getRole")){ @@ -108,7 +108,7 @@ static int dynsec__handle_command(struct mosquitto_control_cmd *cmd, void *userd }else if(!strcasecmp(cmd->command_name, "removeRoleACL")){ rc = dynsec_roles__process_remove_acl(data, cmd); - /* Unknown */ + /* Unknown */ }else{ mosquitto_control_command_reply(cmd, "Unknown command"); rc = MOSQ_ERR_INVAL; diff --git a/plugins/examples/client-lifetime-stats/mosquitto_client_lifetime_stats.c b/plugins/examples/client-lifetime-stats/mosquitto_client_lifetime_stats.c index 6b2664c4..f9b1602c 100644 --- a/plugins/examples/client-lifetime-stats/mosquitto_client_lifetime_stats.c +++ b/plugins/examples/client-lifetime-stats/mosquitto_client_lifetime_stats.c @@ -42,7 +42,7 @@ MOSQUITTO_PLUGIN_DECLARE_VERSION(5); static mosquitto_plugin_id_t *mosq_pid = NULL; -struct lifetime_s{ +struct lifetime_s { UT_hash_handle hh; char *id; time_t connect; diff --git a/plugins/examples/delayed-auth/mosquitto_delayed_auth.c b/plugins/examples/delayed-auth/mosquitto_delayed_auth.c index e34d2345..42ea53fb 100644 --- a/plugins/examples/delayed-auth/mosquitto_delayed_auth.c +++ b/plugins/examples/delayed-auth/mosquitto_delayed_auth.c @@ -50,7 +50,7 @@ Contributors: MOSQUITTO_PLUGIN_DECLARE_VERSION(5); -struct client_list{ +struct client_list { UT_hash_handle hh; char *id; time_t request_time; diff --git a/plugins/examples/payload-ban/mosquitto_payload_ban.c b/plugins/examples/payload-ban/mosquitto_payload_ban.c index 25ba49ee..a8b84b58 100644 --- a/plugins/examples/payload-ban/mosquitto_payload_ban.c +++ b/plugins/examples/payload-ban/mosquitto_payload_ban.c @@ -46,7 +46,7 @@ Contributors: #define PLUGIN_NAME "payload-ban" #define PLUGIN_VERSION "1.0" -struct banlist{ +struct banlist { UT_hash_handle hh_by_address; UT_hash_handle hh_by_id; char ip_address[50]; diff --git a/plugins/examples/tick-interval/mosquitto_tick_interval.c b/plugins/examples/tick-interval/mosquitto_tick_interval.c index 0e25d3ff..71b2fbd2 100644 --- a/plugins/examples/tick-interval/mosquitto_tick_interval.c +++ b/plugins/examples/tick-interval/mosquitto_tick_interval.c @@ -55,7 +55,7 @@ Contributors: MOSQUITTO_PLUGIN_DECLARE_VERSION(5); -struct plugin_data{ +struct plugin_data { mosquitto_plugin_id_t *pid; int interval; }; diff --git a/plugins/examples/wildcard-temp/mosquitto_wildcard_temp.c b/plugins/examples/wildcard-temp/mosquitto_wildcard_temp.c index 64fc503b..e3a19299 100644 --- a/plugins/examples/wildcard-temp/mosquitto_wildcard_temp.c +++ b/plugins/examples/wildcard-temp/mosquitto_wildcard_temp.c @@ -64,7 +64,7 @@ Contributors: MOSQUITTO_PLUGIN_DECLARE_VERSION(5); -struct client_list{ +struct client_list { UT_hash_handle hh; struct client_list *next, *prev; time_t sub_end; diff --git a/src/broker_control.c b/src/broker_control.c index d1fcb128..ec62f2ba 100644 --- a/src/broker_control.c +++ b/src/broker_control.c @@ -259,7 +259,7 @@ static int broker__handle_control(struct mosquitto_control_cmd *cmd, void *userd }else if(!strcasecmp(cmd->command_name, "listListeners")){ rc = broker__process_list_listeners(cmd); - /* Unknown */ + /* Unknown */ }else{ mosquitto_control_command_reply(cmd, "Unknown command"); rc = MOSQ_ERR_INVAL; diff --git a/src/conf.c b/src/conf.c index 4eaf6f4f..a3b59061 100644 --- a/src/conf.c +++ b/src/conf.c @@ -63,91 +63,91 @@ extern SERVICE_STATUS_HANDLE service_handle; #define REQUIRE_LISTENER(A) \ - do{ \ - if(cur_listener == NULL){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a listener to be defined first.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(cur_listener == NULL){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a listener to be defined first.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #define REQUIRE_LISTENER_OR_DEFAULT_LISTENER(A) \ - do{ \ - if(cur_listener == NULL){ \ - if(config__create_default_listener(config, (A))){ \ - return MOSQ_ERR_NOMEM; \ + do{ \ + if(cur_listener == NULL){ \ + if(config__create_default_listener(config, (A))){ \ + return MOSQ_ERR_NOMEM; \ + } \ + cur_listener = config->default_listener; \ } \ - cur_listener = config->default_listener; \ - } \ - }while(0) + }while(0) #define REQUIRE_LISTENER_IF_PER_LISTENER(A) \ - do{ \ - if(config->per_listener_settings == true && cur_listener == NULL){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a listener to be defined first.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(config->per_listener_settings == true && cur_listener == NULL){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a listener to be defined first.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #define REQUIRE_NON_DEFAULT_LISTENER(A) \ - do{ \ - if(cur_listener == config->default_listener || cur_listener == NULL){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a listener to be defined first.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(cur_listener == config->default_listener || cur_listener == NULL){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a listener to be defined first.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #define REQUIRE_BRIDGE(A) \ - do{ \ - if(cur_bridge == NULL){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a bridge to be defined first.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(cur_bridge == NULL){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires a bridge to be defined first.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #define REQUIRE_PLUGIN(A) \ - do{ \ - if(cur_plugin == NULL){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires plugin/global_plugin/plugin_load to be defined first.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(cur_plugin == NULL){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: The '%s' option requires plugin/global_plugin/plugin_load to be defined first.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #define OPTION_DEPRECATED(A, B) \ - log__printf(NULL, MOSQ_LOG_NOTICE, "The '%s' option is now deprecated and will be removed in version 3.0. %s", (A), (B)) + log__printf(NULL, MOSQ_LOG_NOTICE, "The '%s' option is now deprecated and will be removed in version 3.0. %s", (A), (B)) #define OPTION_UNAVAILABLE(A) \ - log__printf(NULL, MOSQ_LOG_WARNING, "Warning: The '%s' option is no longer available.", (A)); + log__printf(NULL, MOSQ_LOG_WARNING, "Warning: The '%s' option is no longer available.", (A)); #define REQUIRE_NON_EMPTY_OPTION(A, B) \ - do{ \ - if(!(A)){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty '%s' value in configuration.", (B)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(!(A)){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty '%s' value in configuration.", (B)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #define PER_LISTENER_ALTERNATIVE(A, B) \ - if(config->per_listener_settings){ \ - log__printf(NULL, MOSQ_LOG_NOTICE, "You are using the '%s' option with 'per_listener_settings true'. Please replace this with '%s'.", A, B); \ - } \ + if(config->per_listener_settings){ \ + log__printf(NULL, MOSQ_LOG_NOTICE, "You are using the '%s' option with 'per_listener_settings true'. Please replace this with '%s'.", A, B); \ + } \ #ifdef FINAL_WITH_TLS_PSK # define REQUIRE_BRIDGE_NO_TLS_PSK(A) \ - do{ \ - if(cur_bridge->tls_psk_identity || cur_bridge->tls_psk){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: '%s': Cannot use both certificate and psk encryption in a single bridge.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(cur_bridge->tls_psk_identity || cur_bridge->tls_psk){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: '%s': Cannot use both certificate and psk encryption in a single bridge.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) # define REQUIRE_BRIDGE_NO_X509(A) \ - do{ \ - if(cur_bridge->tls_cafile || cur_bridge->tls_capath || cur_bridge->tls_certfile || cur_bridge->tls_keyfile){ \ - log__printf(NULL, MOSQ_LOG_ERR, "Error: '%s': Cannot use both certificate and identity encryption in a single bridge.", (A)); \ - return MOSQ_ERR_INVAL; \ - } \ - }while(0) + do{ \ + if(cur_bridge->tls_cafile || cur_bridge->tls_capath || cur_bridge->tls_certfile || cur_bridge->tls_keyfile){ \ + log__printf(NULL, MOSQ_LOG_ERR, "Error: '%s': Cannot use both certificate and identity encryption in a single bridge.", (A)); \ + return MOSQ_ERR_INVAL; \ + } \ + }while(0) #else # define REQUIRE_BRIDGE_NO_TLS_PSK(A) @@ -2183,10 +2183,10 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload, if(!strcmp(token, "mqtt")){ cur_listener->protocol = mp_mqtt; - /* - }else if(!strcmp(token, "mqttsn")){ - cur_listener->protocol = mp_mqttsn; - */ + /* + }else if(!strcmp(token, "mqttsn")){ + cur_listener->protocol = mp_mqttsn; + */ }else if(!strcmp(token, "websockets")){ #ifdef WITH_WEBSOCKETS cur_listener->protocol = mp_websockets; diff --git a/src/database.c b/src/database.c index ceab9879..015fc94c 100644 --- a/src/database.c +++ b/src/database.c @@ -716,7 +716,7 @@ int db__message_insert_outgoing(struct mosquitto *context, uint64_t cmsg_id, uin static inline int db__message_update_outgoing_state(struct mosquitto *context, struct mosquitto__client_msg *head, - uint16_t mid, enum mosquitto_msg_state state, int qos, bool persist) + uint16_t mid, enum mosquitto_msg_state state, int qos, bool persist) { struct mosquitto__client_msg *client_msg; @@ -1260,7 +1260,7 @@ void db__expire_all_messages(struct mosquitto *context) static void db__client_messages_check_acl(struct mosquitto *context, struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg **head, - void (*decrement_stats_fn)(struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg *client_msg)) + void (*decrement_stats_fn)(struct mosquitto_msg_data *msg_data, struct mosquitto__client_msg *client_msg)) { struct mosquitto__client_msg *client_msg, *tmp; struct mosquitto__base_msg *base_msg; diff --git a/src/http_api.c b/src/http_api.c index f4b2a033..02f26808 100644 --- a/src/http_api.c +++ b/src/http_api.c @@ -38,7 +38,7 @@ Contributors: # define HTTP_API_DIR "" #endif -struct metric{ +struct metric { int64_t current; int64_t next; const char *topic, *topic_alias; diff --git a/src/mux_epoll.c b/src/mux_epoll.c index 8d2b9bcb..d1df87cc 100644 --- a/src/mux_epoll.c +++ b/src/mux_epoll.c @@ -171,32 +171,32 @@ int mux_epoll__handle(void) db.now_real_s = time(NULL); switch(event_count){ - case -1: - if(errno != EINTR){ - log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll waiting: %s.", strerror(errno)); - } - break; - case 0: - break; - default: - for(int i=0; iident == id_client){ - loop_handle_reads_writes(context, ep_events[i].events); - }else if(context->ident == id_listener){ - listensock = ep_events[i].data.ptr; - - if (ep_events[i].events & (EPOLLIN | EPOLLPRI)){ - while((context = net__socket_accept(listensock)) != NULL){ - } - } -#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS - }else if(context->ident == id_listener_ws){ - /* Nothing needs to happen here, because we always call lws_service in the loop. - * The important point is we've been woken up for this listener. */ -#endif + case -1: + if(errno != EINTR){ + log__printf(NULL, MOSQ_LOG_ERR, "Error in epoll waiting: %s.", strerror(errno)); + } + break; + case 0: + break; + default: + for(int i=0; iident == id_client){ + loop_handle_reads_writes(context, ep_events[i].events); + }else if(context->ident == id_listener){ + listensock = ep_events[i].data.ptr; + + if(ep_events[i].events & (EPOLLIN | EPOLLPRI)){ + while((context = net__socket_accept(listensock)) != NULL){ + } + } +#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS + }else if(context->ident == id_listener_ws){ + /* Nothing needs to happen here, because we always call lws_service in the loop. + * The important point is we've been woken up for this listener. */ +#endif + } } - } } return MOSQ_ERR_SUCCESS; } diff --git a/src/mux_kqueue.c b/src/mux_kqueue.c index 6cc7db79..8d98693c 100644 --- a/src/mux_kqueue.c +++ b/src/mux_kqueue.c @@ -174,32 +174,32 @@ int mux_kqueue__handle(void) db.now_real_s = time(NULL); switch(event_count){ - case -1: - if(errno != EINTR){ - log__printf(NULL, MOSQ_LOG_ERR, "Error in kqueue waiting: %s.", strerror(errno)); - } - break; - case 0: - break; - default: - for(int i=0; iident == id_client){ - loop_handle_reads_writes(context, event_list[i].filter); - }else if(context->ident == id_listener){ - listensock = event_list[i].udata; - - if(event_list[i].filter == EVFILT_READ){ - while((context = net__socket_accept(listensock)) != NULL){ - } - } -#ifdef WITH_WEBSOCKETS - }else if(context->ident == id_listener_ws){ - /* Nothing needs to happen here, because we always call lws_service in the loop. - * The important point is we've been woken up for this listener. */ -#endif + case -1: + if(errno != EINTR){ + log__printf(NULL, MOSQ_LOG_ERR, "Error in kqueue waiting: %s.", strerror(errno)); + } + break; + case 0: + break; + default: + for(int i=0; iident == id_client){ + loop_handle_reads_writes(context, event_list[i].filter); + }else if(context->ident == id_listener){ + listensock = event_list[i].udata; + + if(event_list[i].filter == EVFILT_READ){ + while((context = net__socket_accept(listensock)) != NULL){ + } + } +#ifdef WITH_WEBSOCKETS + }else if(context->ident == id_listener_ws){ + /* Nothing needs to happen here, because we always call lws_service in the loop. + * The important point is we've been woken up for this listener. */ +#endif + } } - } } return MOSQ_ERR_SUCCESS; } diff --git a/src/plugin_callbacks.c b/src/plugin_callbacks.c index bf333e02..f888353e 100644 --- a/src/plugin_callbacks.c +++ b/src/plugin_callbacks.c @@ -38,7 +38,7 @@ static const char *get_event_name(enum mosquitto_plugin_event event) return "auth-start"; case MOSQ_EVT_EXT_AUTH_CONTINUE: return "auth-continue"; - case MOSQ_EVT_CONTROL: + case MOSQ_EVT_CONTROL: return "control"; case MOSQ_EVT_MESSAGE_IN: return "message-in"; @@ -82,9 +82,9 @@ static const char *get_event_name(enum mosquitto_plugin_event event) return "persist-client-msg-delete"; case MOSQ_EVT_PERSIST_CLIENT_MSG_UPDATE: return "persist-client-msg-update"; - case MOSQ_EVT_PERSIST_WILL_ADD: + case MOSQ_EVT_PERSIST_WILL_ADD: return "persist-will-add"; - case MOSQ_EVT_PERSIST_WILL_DELETE: + case MOSQ_EVT_PERSIST_WILL_DELETE: return "persist-will-delete"; } return ""; @@ -162,9 +162,9 @@ static struct mosquitto__callback **plugin__get_callback_base(struct mosquitto__ return &security_options->plugin_callbacks.persist_retain_msg_delete; case MOSQ_EVT_MESSAGE_OUT: return &security_options->plugin_callbacks.message_out; - case MOSQ_EVT_PERSIST_WILL_ADD: + case MOSQ_EVT_PERSIST_WILL_ADD: return &security_options->plugin_callbacks.persist_will_add; - case MOSQ_EVT_PERSIST_WILL_DELETE: + case MOSQ_EVT_PERSIST_WILL_DELETE: return &security_options->plugin_callbacks.persist_will_delete; } return NULL; diff --git a/src/proxy_v2.c b/src/proxy_v2.c index 3c69b63d..9db386b3 100644 --- a/src/proxy_v2.c +++ b/src/proxy_v2.c @@ -44,32 +44,32 @@ struct proxy_hdr_v2 { uint16_t len; /* number of following bytes part of the header */ }; -union proxy_addr{ - struct{ /* for TCP/UDP over IPv4, len = 12 */ +union proxy_addr { + struct { /* for TCP/UDP over IPv4, len = 12 */ uint32_t src_addr; uint32_t dst_addr; uint16_t src_port; uint16_t dst_port; } ipv4_addr; - struct{ /* for TCP/UDP over IPv6, len = 36 */ + struct { /* for TCP/UDP over IPv6, len = 36 */ uint8_t src_addr[16]; uint8_t dst_addr[16]; uint16_t src_port; uint16_t dst_port; } ipv6_addr; - struct{ /* for AF_UNIX sockets, len = 216 */ + struct { /* for AF_UNIX sockets, len = 216 */ uint8_t src_addr[108]; uint8_t dst_addr[108]; } unix_addr; }; -struct pp2_tlv{ +struct pp2_tlv { uint8_t type; uint8_t length_h; uint8_t length_l; }; -struct pp2_tlv_ssl{ +struct pp2_tlv_ssl { uint8_t client; uint32_t verify; }; diff --git a/src/service.c b/src/service.c index 149ef26a..5055a357 100644 --- a/src/service.c +++ b/src/service.c @@ -68,7 +68,7 @@ void __stdcall service_handler(DWORD fdwControl) /* Pause service. */ break; case SERVICE_CONTROL_SHUTDOWN: - /* System is shutting down. */ + /* System is shutting down. */ case SERVICE_CONTROL_STOP: /* Service should stop. */ service_status.dwCurrentState = SERVICE_STOP_PENDING; diff --git a/src/sys_tree.c b/src/sys_tree.c index 32a3482b..4bcab89d 100644 --- a/src/sys_tree.c +++ b/src/sys_tree.c @@ -37,14 +37,14 @@ Contributors: #define METRIC_LOAD_5MIN 2 #define METRIC_LOAD_15MIN 3 -struct metric{ +struct metric { int64_t current; int64_t next; const char *topic, *topic_alias; bool is_max; }; -struct metric_load{ +struct metric_load { double current; const char *topic; int load_ref; diff --git a/src/websockets.c b/src/websockets.c index a3ff19c6..a41d634e 100644 --- a/src/websockets.c +++ b/src/websockets.c @@ -72,40 +72,40 @@ struct libws_http_data { static struct lws_protocols protocols[] = { /* first protocol must always be HTTP handler */ { - "http-only", /* name */ - callback_http, /* lws_callback_function */ - sizeof (struct libws_http_data), /* per_session_data_size */ - 0, /* rx_buffer_size */ - 0, /* id */ - NULL, /* user v1.4 on */ - WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */ + "http-only", /* name */ + callback_http, /* lws_callback_function */ + sizeof (struct libws_http_data), /* per_session_data_size */ + 0, /* rx_buffer_size */ + 0, /* id */ + NULL, /* user v1.4 on */ + WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */ }, { "mqtt", callback_mqtt, sizeof(struct libws_mqtt_data), - 0, /* rx_buffer_size */ - 1, /* id */ - NULL, /* user v1.4 on */ - WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */ + 0, /* rx_buffer_size */ + 1, /* id */ + NULL, /* user v1.4 on */ + WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */ }, { "mqttv3.1", callback_mqtt, sizeof(struct libws_mqtt_data), - 0, /* rx_buffer_size */ - 2, /* id */ - NULL, /* user v1.4 on */ - WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */ + 0, /* rx_buffer_size */ + 2, /* id */ + NULL, /* user v1.4 on */ + WS_TX_BUF_SIZE /* tx_packet_size v2.3.0 */ }, { NULL, NULL, 0, - 0, /* rx_buffer_size */ - 0, /* id */ - NULL, /* user v1.4 on */ - 0 /* tx_packet_size v2.3.0 */ + 0, /* rx_buffer_size */ + 0, /* id */ + NULL, /* user v1.4 on */ + 0 /* tx_packet_size v2.3.0 */ } }; diff --git a/test/unit/broker/stubs.c b/test/unit/broker/stubs.c index 10d6aa49..3eae0f5f 100644 --- a/test/unit/broker/stubs.c +++ b/test/unit/broker/stubs.c @@ -7,11 +7,11 @@ #include "read_handle.h" #include "send_mosq.h" -struct mosquitto_db{ +struct mosquitto_db { }; -struct mosquitto__base_msg{ +struct mosquitto__base_msg { }; diff --git a/test/unit/lib/stubs.c b/test/unit/lib/stubs.c index 02277944..302ede24 100644 --- a/test/unit/lib/stubs.c +++ b/test/unit/lib/stubs.c @@ -7,11 +7,11 @@ #include "read_handle.h" #include "send_mosq.h" -struct mosquitto_db{ +struct mosquitto_db { }; -struct mosquitto__base_msg{ +struct mosquitto__base_msg { }; diff --git a/test/unit/libcommon/strings_test.c b/test/unit/libcommon/strings_test.c index b94b36f0..841648d7 100644 --- a/test/unit/libcommon/strings_test.c +++ b/test/unit/libcommon/strings_test.c @@ -5,7 +5,7 @@ #include "mosquitto.h" -struct prop_id{ +struct prop_id { const char *name; int proptype; }; diff --git a/test/unit/libcommon/topic_test.c b/test/unit/libcommon/topic_test.c index 4b41f91c..2ef46749 100644 --- a/test/unit/libcommon/topic_test.c +++ b/test/unit/libcommon/topic_test.c @@ -3,7 +3,7 @@ #include -struct topic_test{ +struct topic_test { const char *topic_filter; const char *topic; const char *clientid; diff --git a/test/unit/tls_stubs.c b/test/unit/tls_stubs.c index 6c54f9cc..d741dc22 100644 --- a/test/unit/tls_stubs.c +++ b/test/unit/tls_stubs.c @@ -5,7 +5,7 @@ int tls_ex_index_mosq; -struct mosquitto_db{ +struct mosquitto_db { };