mirror of
https://github.com/eclipse/mosquitto.git
synced 2025-05-09 01:01:11 +08:00
Fixes for lots of minor build warnings highlighted by Visual Studio.
This commit is contained in:
parent
e717b7f42c
commit
370cec5edd
@ -16,6 +16,7 @@ Broker:
|
||||
Build:
|
||||
- `install` Makefile target should depend on `all`, not `mosquitto`, to ensure
|
||||
that man pages are always built. Closes #1989.
|
||||
- Fixes for lots of minor build warnings highlighted by Visual Studio.
|
||||
|
||||
Apps:
|
||||
- Disallow control characters in mosquitto_passwd usernames.
|
||||
|
@ -36,6 +36,8 @@ static void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto
|
||||
{
|
||||
struct mosq_ctrl *ctrl = obj;
|
||||
|
||||
UNUSED(properties);
|
||||
|
||||
if(ctrl->payload_callback){
|
||||
ctrl->payload_callback(ctrl, msg->payloadlen, msg->payload);
|
||||
}
|
||||
@ -47,6 +49,10 @@ static void on_message(struct mosquitto *mosq, void *obj, const struct mosquitto
|
||||
|
||||
static void on_publish(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties)
|
||||
{
|
||||
UNUSED(obj);
|
||||
UNUSED(mid);
|
||||
UNUSED(properties);
|
||||
|
||||
if(reason_code > 127){
|
||||
fprintf(stderr, "Publish error: %s\n", mosquitto_reason_string(reason_code));
|
||||
run = 0;
|
||||
@ -59,6 +65,9 @@ static void on_subscribe(struct mosquitto *mosq, void *obj, int mid, int qos_cou
|
||||
{
|
||||
struct mosq_ctrl *ctrl = obj;
|
||||
|
||||
UNUSED(mid);
|
||||
UNUSED(properties);
|
||||
|
||||
if(qos_count == 1){
|
||||
if(granted_qos[0] < 128){
|
||||
/* Success */
|
||||
@ -87,6 +96,9 @@ static void on_connect(struct mosquitto *mosq, void *obj, int reason_code, int f
|
||||
{
|
||||
struct mosq_ctrl *ctrl = obj;
|
||||
|
||||
UNUSED(flags);
|
||||
UNUSED(properties);
|
||||
|
||||
if(reason_code == 0){
|
||||
if(ctrl->response_topic){
|
||||
mosquitto_subscribe(mosq, NULL, ctrl->response_topic, ctrl->cfg.qos);
|
||||
|
@ -124,7 +124,7 @@ static void print_list(cJSON *j_response, const char *arrayname, const char *key
|
||||
}
|
||||
|
||||
|
||||
static void print_roles(cJSON *j_roles, int slen)
|
||||
static void print_roles(cJSON *j_roles, size_t slen)
|
||||
{
|
||||
bool first;
|
||||
cJSON *j_elem, *jtmp;
|
||||
@ -136,9 +136,9 @@ static void print_roles(cJSON *j_roles, int slen)
|
||||
if(jtmp && cJSON_IsString(jtmp)){
|
||||
if(first){
|
||||
first = false;
|
||||
printf("%-*s %s", slen, "Roles:", jtmp->valuestring);
|
||||
printf("%-*s %s", (int)slen, "Roles:", jtmp->valuestring);
|
||||
}else{
|
||||
printf("%-*s %s", slen, "", jtmp->valuestring);
|
||||
printf("%-*s %s", (int)slen, "", jtmp->valuestring);
|
||||
}
|
||||
jtmp = cJSON_GetObjectItem(j_elem, "priority");
|
||||
if(jtmp && cJSON_IsNumber(jtmp)){
|
||||
@ -383,7 +383,13 @@ static void dynsec__payload_callback(struct mosq_ctrl *ctrl, long payloadlen, co
|
||||
{
|
||||
cJSON *tree, *j_responses, *j_response, *j_command, *j_error;
|
||||
|
||||
UNUSED(ctrl);
|
||||
|
||||
#if CJSON_VERSION_FULL < 1007013
|
||||
tree = cJSON_Parse(payload);
|
||||
#else
|
||||
tree = cJSON_ParseWithLength(payload, payloadlen);
|
||||
#endif
|
||||
if(tree == NULL){
|
||||
fprintf(stderr, "Error: Payload not JSON.\n");
|
||||
return;
|
||||
@ -492,6 +498,9 @@ static int dynsec__set_default_acl_access(int argc, char *argv[], cJSON *j_comma
|
||||
|
||||
static int dynsec__get_default_acl_access(int argc, char *argv[], cJSON *j_command)
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
if(cJSON_AddStringToObject(j_command, "command", "getDefaultACLAccess") == NULL
|
||||
){
|
||||
|
||||
|
@ -15,6 +15,8 @@ SPDX-License-Identifier: EPL-2.0 OR EDL-1.0
|
||||
Contributors:
|
||||
Roger Light - initial implementation and documentation.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <cjson/cJSON.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -66,6 +68,9 @@ int dynsec_group__delete(int argc, char *argv[], cJSON *j_command)
|
||||
|
||||
int dynsec_group__get_anonymous(int argc, char *argv[], cJSON *j_command)
|
||||
{
|
||||
UNUSED(argc);
|
||||
UNUSED(argv);
|
||||
|
||||
if(cJSON_AddStringToObject(j_command, "command", "getAnonymousGroup") == NULL
|
||||
){
|
||||
|
||||
|
@ -241,6 +241,10 @@ static int pwfile_iterate(FILE *fptr, FILE *ftmp,
|
||||
* ====================================================================== */
|
||||
static int delete_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const char *password, const char *line, struct cb_helper *helper)
|
||||
{
|
||||
UNUSED(fptr);
|
||||
UNUSED(password);
|
||||
UNUSED(line);
|
||||
|
||||
if(strcmp(username, helper->username)){
|
||||
/* If this isn't the username to delete, write it to the new file */
|
||||
fprintf(ftmp, "%s", line);
|
||||
@ -274,6 +278,9 @@ int delete_pwuser(FILE *fptr, FILE *ftmp, const char *username)
|
||||
* ====================================================================== */
|
||||
static int update_file_cb(FILE *fptr, FILE *ftmp, const char *username, const char *password, const char *line, struct cb_helper *helper)
|
||||
{
|
||||
UNUSED(fptr);
|
||||
UNUSED(line);
|
||||
|
||||
if(helper){
|
||||
return output_new_password(ftmp, username, password, helper->iterations);
|
||||
}else{
|
||||
@ -294,6 +301,9 @@ static int update_pwuser_cb(FILE *fptr, FILE *ftmp, const char *username, const
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
UNUSED(fptr);
|
||||
UNUSED(password);
|
||||
|
||||
if(strcmp(username, helper->username)){
|
||||
/* If this isn't the matching user, then writing out the exiting line */
|
||||
fprintf(ftmp, "%s", line);
|
||||
|
@ -54,7 +54,7 @@ extern struct mosq_config cfg;
|
||||
|
||||
bool process_messages = true;
|
||||
int msg_count = 0;
|
||||
struct mosquitto *mosq = NULL;
|
||||
struct mosquitto *g_mosq = NULL;
|
||||
static bool timed_out = false;
|
||||
static int connack_result = 0;
|
||||
|
||||
@ -63,7 +63,7 @@ void my_signal_handler(int signum)
|
||||
{
|
||||
if(signum == SIGALRM){
|
||||
process_messages = false;
|
||||
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||
mosquitto_disconnect_v5(g_mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||
timed_out = true;
|
||||
}
|
||||
}
|
||||
@ -82,6 +82,10 @@ 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)
|
||||
{
|
||||
UNUSED(mosq);
|
||||
UNUSED(obj);
|
||||
UNUSED(properties);
|
||||
|
||||
print_message(&cfg, message, properties);
|
||||
switch(cfg.pub_mode){
|
||||
case MSGMODE_CMD:
|
||||
@ -125,6 +129,10 @@ 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)
|
||||
{
|
||||
UNUSED(obj);
|
||||
UNUSED(flags);
|
||||
UNUSED(properties);
|
||||
|
||||
connack_result = result;
|
||||
if(!result){
|
||||
client_state = rr_s_connected;
|
||||
@ -145,6 +153,10 @@ 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)
|
||||
{
|
||||
UNUSED(obj);
|
||||
UNUSED(mid);
|
||||
UNUSED(qos_count);
|
||||
|
||||
if(granted_qos[0] < 128){
|
||||
client_state = rr_s_ready_to_publish;
|
||||
}else{
|
||||
@ -157,6 +169,12 @@ void my_subscribe_callback(struct mosquitto *mosq, void *obj, int mid, int qos_c
|
||||
|
||||
void my_publish_callback(struct mosquitto *mosq, void *obj, int mid, int reason_code, const mosquitto_property *properties)
|
||||
{
|
||||
UNUSED(mosq);
|
||||
UNUSED(obj);
|
||||
UNUSED(mid);
|
||||
UNUSED(reason_code);
|
||||
UNUSED(properties);
|
||||
|
||||
client_state = rr_s_wait_for_response;
|
||||
}
|
||||
|
||||
@ -328,8 +346,8 @@ int main(int argc, char *argv[])
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
||||
if(!mosq){
|
||||
g_mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
||||
if(!g_mosq){
|
||||
switch(errno){
|
||||
case ENOMEM:
|
||||
err_printf(&cfg, "Error: Out of memory.\n");
|
||||
@ -340,17 +358,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
if(client_opts_set(mosq, &cfg)){
|
||||
if(client_opts_set(g_mosq, &cfg)){
|
||||
goto cleanup;
|
||||
}
|
||||
if(cfg.debug){
|
||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
||||
mosquitto_log_callback_set(g_mosq, my_log_callback);
|
||||
}
|
||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
||||
mosquitto_message_v5_callback_set(mosq, my_message_callback);
|
||||
mosquitto_connect_v5_callback_set(g_mosq, my_connect_callback);
|
||||
mosquitto_subscribe_callback_set(g_mosq, my_subscribe_callback);
|
||||
mosquitto_message_v5_callback_set(g_mosq, my_message_callback);
|
||||
|
||||
rc = client_connect(mosq, &cfg);
|
||||
rc = client_connect(g_mosq, &cfg);
|
||||
if(rc){
|
||||
goto cleanup;
|
||||
}
|
||||
@ -371,17 +389,17 @@ int main(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
do{
|
||||
rc = mosquitto_loop(mosq, -1, 1);
|
||||
rc = mosquitto_loop(g_mosq, -1, 1);
|
||||
if(client_state == rr_s_ready_to_publish){
|
||||
client_state = rr_s_wait_for_response;
|
||||
switch(cfg.pub_mode){
|
||||
case MSGMODE_CMD:
|
||||
case MSGMODE_FILE:
|
||||
case MSGMODE_STDIN_FILE:
|
||||
rc = my_publish(mosq, &mid_sent, cfg.topic, cfg.msglen, cfg.message, cfg.qos, cfg.retain);
|
||||
rc = my_publish(g_mosq, &mid_sent, cfg.topic, cfg.msglen, cfg.message, cfg.qos, cfg.retain);
|
||||
break;
|
||||
case MSGMODE_NULL:
|
||||
rc = my_publish(mosq, &mid_sent, cfg.topic, 0, NULL, cfg.qos, cfg.retain);
|
||||
rc = my_publish(g_mosq, &mid_sent, cfg.topic, 0, NULL, cfg.qos, cfg.retain);
|
||||
break;
|
||||
case MSGMODE_STDIN_LINE:
|
||||
/* FIXME */
|
||||
@ -390,7 +408,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}while(rc == MOSQ_ERR_SUCCESS && client_state != rr_s_disconnect);
|
||||
|
||||
mosquitto_destroy(mosq);
|
||||
mosquitto_destroy(g_mosq);
|
||||
mosquitto_lib_cleanup();
|
||||
|
||||
if(cfg.msg_count>0 && rc == MOSQ_ERR_NO_CONN){
|
||||
|
@ -41,7 +41,7 @@ Contributors:
|
||||
struct mosq_config cfg;
|
||||
bool process_messages = true;
|
||||
int msg_count = 0;
|
||||
struct mosquitto *mosq = NULL;
|
||||
struct mosquitto *g_mosq = NULL;
|
||||
int last_mid = 0;
|
||||
static bool timed_out = false;
|
||||
static int connack_result = 0;
|
||||
@ -53,7 +53,7 @@ void my_signal_handler(int signum)
|
||||
if(signum == SIGALRM || signum == SIGTERM || signum == SIGINT){
|
||||
if(connack_received){
|
||||
process_messages = false;
|
||||
mosquitto_disconnect_v5(mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||
mosquitto_disconnect_v5(g_mosq, MQTT_RC_DISCONNECT_WITH_WILL_MSG, cfg.disconnect_props);
|
||||
}else{
|
||||
exit(-1);
|
||||
}
|
||||
@ -358,8 +358,8 @@ int main(int argc, char *argv[])
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
||||
if(!mosq){
|
||||
g_mosq = mosquitto_new(cfg.id, cfg.clean_session, &cfg);
|
||||
if(!g_mosq){
|
||||
switch(errno){
|
||||
case ENOMEM:
|
||||
err_printf(&cfg, "Error: Out of memory.\n");
|
||||
@ -370,17 +370,17 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
goto cleanup;
|
||||
}
|
||||
if(client_opts_set(mosq, &cfg)){
|
||||
if(client_opts_set(g_mosq, &cfg)){
|
||||
goto cleanup;
|
||||
}
|
||||
if(cfg.debug){
|
||||
mosquitto_log_callback_set(mosq, my_log_callback);
|
||||
mosquitto_log_callback_set(g_mosq, my_log_callback);
|
||||
}
|
||||
mosquitto_subscribe_callback_set(mosq, my_subscribe_callback);
|
||||
mosquitto_connect_v5_callback_set(mosq, my_connect_callback);
|
||||
mosquitto_message_v5_callback_set(mosq, my_message_callback);
|
||||
mosquitto_subscribe_callback_set(g_mosq, my_subscribe_callback);
|
||||
mosquitto_connect_v5_callback_set(g_mosq, my_connect_callback);
|
||||
mosquitto_message_v5_callback_set(g_mosq, my_message_callback);
|
||||
|
||||
rc = client_connect(mosq, &cfg);
|
||||
rc = client_connect(g_mosq, &cfg);
|
||||
if(rc){
|
||||
goto cleanup;
|
||||
}
|
||||
@ -410,9 +410,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = mosquitto_loop_forever(mosq, -1, 1);
|
||||
rc = mosquitto_loop_forever(g_mosq, -1, 1);
|
||||
|
||||
mosquitto_destroy(mosq);
|
||||
mosquitto_destroy(g_mosq);
|
||||
mosquitto_lib_cleanup();
|
||||
|
||||
if(cfg.msg_count>0 && rc == MOSQ_ERR_NO_CONN){
|
||||
@ -432,7 +432,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
cleanup:
|
||||
mosquitto_destroy(mosq);
|
||||
mosquitto_destroy(g_mosq);
|
||||
mosquitto_lib_cleanup();
|
||||
client_config_cleanup(&cfg);
|
||||
return 1;
|
||||
|
@ -443,7 +443,7 @@ static void formatted_print_percent(const struct mosq_config *lcfg, const struct
|
||||
uint8_t i8value;
|
||||
uint16_t i16value;
|
||||
uint32_t i32value;
|
||||
char *binvalue, *strname, *strvalue;
|
||||
char *binvalue = NULL, *strname, *strvalue;
|
||||
const mosquitto_property *prop;
|
||||
|
||||
|
||||
@ -627,8 +627,8 @@ static void formatted_print(const struct mosq_config *lcfg, const struct mosquit
|
||||
size_t len;
|
||||
int i;
|
||||
struct tm *ti = NULL;
|
||||
long ns;
|
||||
char strf[3];
|
||||
long ns = 0;
|
||||
char strf[3] = {0, 0 ,0};
|
||||
char buf[100];
|
||||
char align, pad;
|
||||
int field_width, precision;
|
||||
@ -769,7 +769,7 @@ void rand_init(void)
|
||||
}
|
||||
|
||||
|
||||
void print_message(struct mosq_config *cfg, const struct mosquitto_message *message, const mosquitto_property *properties)
|
||||
void print_message(struct mosq_config *lcfg, const struct mosquitto_message *message, const mosquitto_property *properties)
|
||||
{
|
||||
#ifdef WIN32
|
||||
unsigned int r = 0;
|
||||
@ -777,27 +777,27 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
|
||||
long r = 0;
|
||||
#endif
|
||||
|
||||
if(cfg->random_filter < 10000){
|
||||
if(lcfg->random_filter < 10000){
|
||||
#ifdef WIN32
|
||||
rand_s(&r);
|
||||
#else
|
||||
r = random();
|
||||
#endif
|
||||
if((r%10000) >= cfg->random_filter){
|
||||
if((long)(r%10000) >= lcfg->random_filter){
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(cfg->format){
|
||||
formatted_print(cfg, message, properties);
|
||||
}else if(cfg->verbose){
|
||||
if(lcfg->format){
|
||||
formatted_print(lcfg, message, properties);
|
||||
}else if(lcfg->verbose){
|
||||
if(message->payloadlen){
|
||||
printf("%s ", message->topic);
|
||||
write_payload(message->payload, message->payloadlen, false, 0, 0, 0, 0);
|
||||
if(cfg->eol){
|
||||
if(lcfg->eol){
|
||||
printf("\n");
|
||||
}
|
||||
}else{
|
||||
if(cfg->eol){
|
||||
if(lcfg->eol){
|
||||
printf("%s (null)\n", message->topic);
|
||||
}
|
||||
}
|
||||
@ -805,7 +805,7 @@ void print_message(struct mosq_config *cfg, const struct mosquitto_message *mess
|
||||
}else{
|
||||
if(message->payloadlen){
|
||||
write_payload(message->payload, message->payloadlen, false, 0, 0, 0, 0);
|
||||
if(cfg->eol){
|
||||
if(lcfg->eol){
|
||||
printf("\n");
|
||||
}
|
||||
fflush(stdout);
|
||||
|
@ -39,7 +39,7 @@ int handle__publish(struct mosquitto *mosq)
|
||||
uint8_t header;
|
||||
struct mosquitto_message_all *message;
|
||||
int rc = 0;
|
||||
uint16_t mid;
|
||||
uint16_t mid = 0;
|
||||
uint16_t slen;
|
||||
mosquitto_property *properties = NULL;
|
||||
|
||||
|
@ -393,9 +393,6 @@ static int net__try_connect_tcp(const char *host, uint16_t port, mosq_sock_t *so
|
||||
struct addrinfo *ainfo_bind, *rp_bind;
|
||||
int s;
|
||||
int rc = MOSQ_ERR_SUCCESS;
|
||||
#ifdef WIN32
|
||||
uint32_t val = 1;
|
||||
#endif
|
||||
|
||||
ainfo_bind = NULL;
|
||||
|
||||
|
@ -65,6 +65,8 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
|
||||
X509_STORE *st = NULL;
|
||||
STACK_OF(X509) *ch = NULL;
|
||||
|
||||
UNUSED(ssl);
|
||||
|
||||
long 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);
|
||||
|
||||
|
@ -55,6 +55,7 @@ int mosquitto_loop_start(struct mosquitto *mosq)
|
||||
return MOSQ_ERR_ERRNO;
|
||||
}
|
||||
#else
|
||||
UNUSED(mosq);
|
||||
return MOSQ_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
@ -91,6 +92,8 @@ int mosquitto_loop_stop(struct mosquitto *mosq, bool force)
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
#else
|
||||
UNUSED(mosq);
|
||||
UNUSED(force);
|
||||
return MOSQ_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
}
|
||||
|
@ -35,8 +35,8 @@ typedef int (*MOSQ_FUNC_acl_check)(struct mosquitto_evt_acl_check *, struct dyns
|
||||
|
||||
static int acl_check_publish_c_recv(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||
{
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
||||
struct dynsec__acl *acl, *acl_tmp;
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||
bool result;
|
||||
|
||||
HASH_ITER(hh, base_rolelist, rolelist, rolelist_tmp){
|
||||
@ -63,8 +63,8 @@ static int acl_check_publish_c_recv(struct mosquitto_evt_acl_check *ed, struct d
|
||||
|
||||
static int acl_check_publish_c_send(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||
{
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
||||
struct dynsec__acl *acl, *acl_tmp;
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||
bool result;
|
||||
|
||||
HASH_ITER(hh, base_rolelist, rolelist, rolelist_tmp){
|
||||
@ -91,8 +91,8 @@ static int acl_check_publish_c_send(struct mosquitto_evt_acl_check *ed, struct d
|
||||
|
||||
static int acl_check_subscribe(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||
{
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
||||
struct dynsec__acl *acl, *acl_tmp;
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||
size_t len;
|
||||
|
||||
len = strlen(ed->topic);
|
||||
@ -128,8 +128,8 @@ static int acl_check_subscribe(struct mosquitto_evt_acl_check *ed, struct dynsec
|
||||
|
||||
static int acl_check_unsubscribe(struct mosquitto_evt_acl_check *ed, struct dynsec__rolelist *base_rolelist)
|
||||
{
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
||||
struct dynsec__acl *acl, *acl_tmp;
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||
struct dynsec__acl *acl, *acl_tmp = NULL;
|
||||
size_t len;
|
||||
|
||||
len = strlen(ed->topic);
|
||||
@ -163,10 +163,10 @@ static int acl_check_unsubscribe(struct mosquitto_evt_acl_check *ed, struct dyns
|
||||
* #
|
||||
* ################################################################ */
|
||||
|
||||
static int acl_check(struct mosquitto_evt_acl_check *ed, MOSQ_FUNC_acl_check check, bool default_access)
|
||||
static int acl_check(struct mosquitto_evt_acl_check *ed, MOSQ_FUNC_acl_check check, bool acl_default_access)
|
||||
{
|
||||
struct dynsec__client *client;
|
||||
struct dynsec__grouplist *grouplist, *grouplist_tmp;
|
||||
struct dynsec__grouplist *grouplist, *grouplist_tmp = NULL;
|
||||
const char *username;
|
||||
int rc;
|
||||
|
||||
@ -196,7 +196,7 @@ static int acl_check(struct mosquitto_evt_acl_check *ed, MOSQ_FUNC_acl_check che
|
||||
}
|
||||
}
|
||||
|
||||
if(default_access == false){
|
||||
if(acl_default_access == false){
|
||||
return MOSQ_ERR_PLUGIN_DEFER;
|
||||
}else{
|
||||
if(!strncmp(ed->topic, "$CONTROL", strlen("$CONTROL"))){
|
||||
@ -220,6 +220,9 @@ int dynsec__acl_check_callback(int event, void *event_data, void *userdata)
|
||||
{
|
||||
struct mosquitto_evt_acl_check *ed = event_data;
|
||||
|
||||
UNUSED(event);
|
||||
UNUSED(userdata);
|
||||
|
||||
/* ACL checks are made in the order below until a match occurs, at which
|
||||
* point the decision is made.
|
||||
*
|
||||
|
@ -37,7 +37,7 @@ Contributors:
|
||||
int dynsec_auth__base64_encode(unsigned char *in, int in_len, char **encoded)
|
||||
{
|
||||
BIO *bmem, *b64;
|
||||
BUF_MEM *bptr;
|
||||
BUF_MEM *bptr = NULL;
|
||||
|
||||
if(in_len < 0) return 1;
|
||||
|
||||
@ -178,6 +178,9 @@ int dynsec_auth__basic_auth_callback(int event, void *event_data, void *userdata
|
||||
unsigned char password_hash[64]; /* For SHA512 */
|
||||
const char *clientid;
|
||||
|
||||
UNUSED(event);
|
||||
UNUSED(userdata);
|
||||
|
||||
if(ed->username == NULL || ed->password == NULL) return MOSQ_ERR_PLUGIN_DEFER;
|
||||
|
||||
client = dynsec_clients__find(ed->username);
|
||||
|
@ -170,7 +170,7 @@ int dynsec_groups__process_add_role(cJSON *j_responses, struct mosquitto *contex
|
||||
|
||||
void dynsec_groups__cleanup(void)
|
||||
{
|
||||
struct dynsec__group *group, *group_tmp;
|
||||
struct dynsec__group *group, *group_tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, local_groups, group, group_tmp){
|
||||
group__free_item(group);
|
||||
@ -300,7 +300,7 @@ int dynsec_groups__config_load(cJSON *tree)
|
||||
|
||||
static int dynsec__config_add_groups(cJSON *j_groups)
|
||||
{
|
||||
struct dynsec__group *group, *group_tmp;
|
||||
struct dynsec__group *group, *group_tmp = NULL;
|
||||
cJSON *j_group, *j_clients, *j_roles;
|
||||
|
||||
HASH_ITER(hh, local_groups, group, group_tmp){
|
||||
@ -572,7 +572,7 @@ int dynsec_groups__process_add_client(cJSON *j_responses, struct mosquitto *cont
|
||||
|
||||
static int dynsec__remove_all_clients_from_group(struct dynsec__group *group)
|
||||
{
|
||||
struct dynsec__clientlist *clientlist, *clientlist_tmp;
|
||||
struct dynsec__clientlist *clientlist, *clientlist_tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, group->clientlist, clientlist, clientlist_tmp){
|
||||
/* Remove client stored group reference */
|
||||
@ -587,7 +587,7 @@ static int dynsec__remove_all_clients_from_group(struct dynsec__group *group)
|
||||
|
||||
static int dynsec__remove_all_roles_from_group(struct dynsec__group *group)
|
||||
{
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp;
|
||||
struct dynsec__rolelist *rolelist, *rolelist_tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, group->rolelist, rolelist, rolelist_tmp){
|
||||
dynsec_rolelist__group_remove(group, rolelist->role);
|
||||
@ -670,7 +670,7 @@ int dynsec_groups__process_remove_client(cJSON *j_responses, struct mosquitto *c
|
||||
static cJSON *add_group_to_json(struct dynsec__group *group)
|
||||
{
|
||||
cJSON *j_group, *jtmp, *j_clientlist, *j_client, *j_rolelist;
|
||||
struct dynsec__clientlist *clientlist, *clientlist_tmp;
|
||||
struct dynsec__clientlist *clientlist, *clientlist_tmp = NULL;
|
||||
|
||||
j_group = cJSON_CreateObject();
|
||||
if(j_group == NULL){
|
||||
@ -718,7 +718,7 @@ int dynsec_groups__process_list(cJSON *j_responses, struct mosquitto *context, c
|
||||
{
|
||||
bool verbose;
|
||||
cJSON *tree, *j_groups, *j_group, *j_data;
|
||||
struct dynsec__group *group, *group_tmp;
|
||||
struct dynsec__group *group, *group_tmp = NULL;
|
||||
int i, count, offset;
|
||||
const char *admin_clientid, *admin_username;
|
||||
|
||||
@ -1042,6 +1042,8 @@ int dynsec_groups__process_get_anonymous_group(cJSON *j_responses, struct mosqui
|
||||
const char *groupname;
|
||||
const char *admin_clientid, *admin_username;
|
||||
|
||||
UNUSED(command);
|
||||
|
||||
tree = cJSON_CreateObject();
|
||||
if(tree == NULL){
|
||||
dynsec__command_reply(j_responses, context, "getAnonymousGroup", "Internal error", correlation_data);
|
||||
|
@ -41,6 +41,8 @@ void dynsec__command_reply(cJSON *j_responses, struct mosquitto *context, const
|
||||
{
|
||||
cJSON *j_response;
|
||||
|
||||
UNUSED(context);
|
||||
|
||||
j_response = cJSON_CreateObject();
|
||||
if(j_response == NULL) return;
|
||||
|
||||
@ -82,6 +84,9 @@ static int dynsec_control_callback(int event, void *event_data, void *userdata)
|
||||
cJSON *tree, *commands;
|
||||
cJSON *j_response_tree, *j_responses;
|
||||
|
||||
UNUSED(event);
|
||||
UNUSED(userdata);
|
||||
|
||||
/* Create object for responses */
|
||||
j_response_tree = cJSON_CreateObject();
|
||||
if(j_response_tree == NULL){
|
||||
@ -174,6 +179,8 @@ int dynsec__process_get_default_acl_access(cJSON *j_responses, struct mosquitto
|
||||
cJSON *tree, *jtmp, *j_data, *j_acls, *j_acl;
|
||||
const char *admin_clientid, *admin_username;
|
||||
|
||||
UNUSED(command);
|
||||
|
||||
tree = cJSON_CreateObject();
|
||||
if(tree == NULL){
|
||||
dynsec__command_reply(j_responses, context, "getDefaultACLAccess", "Internal error", correlation_data);
|
||||
@ -465,6 +472,8 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
|
||||
{
|
||||
int i;
|
||||
|
||||
UNUSED(user_data);
|
||||
|
||||
for(i=0; i<option_count; i++){
|
||||
if(!strcasecmp(options[i].key, "config_file")){
|
||||
config_file = mosquitto_strdup(options[i].value);
|
||||
@ -491,6 +500,10 @@ int mosquitto_plugin_init(mosquitto_plugin_id_t *identifier, void **user_data, s
|
||||
|
||||
int mosquitto_plugin_cleanup(void *user_data, struct mosquitto_opt *options, int option_count)
|
||||
{
|
||||
UNUSED(user_data);
|
||||
UNUSED(options);
|
||||
UNUSED(option_count);
|
||||
|
||||
if(plg_id){
|
||||
mosquitto_callback_unregister(plg_id, MOSQ_EVT_CONTROL, dynsec_control_callback, "$CONTROL/dynamic-security/v1");
|
||||
mosquitto_callback_unregister(plg_id, MOSQ_EVT_BASIC_AUTH, dynsec_auth__basic_auth_callback, NULL);
|
||||
|
@ -66,7 +66,7 @@ static void role__free_acl(struct dynsec__acl **acl, struct dynsec__acl *item)
|
||||
|
||||
static void role__free_all_acls(struct dynsec__acl **acl)
|
||||
{
|
||||
struct dynsec__acl *iter, *tmp;
|
||||
struct dynsec__acl *iter, *tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, *acl, iter, tmp){
|
||||
role__free_acl(acl, iter);
|
||||
@ -105,7 +105,7 @@ struct dynsec__role *dynsec_roles__find(const char *rolename)
|
||||
|
||||
void dynsec_roles__cleanup(void)
|
||||
{
|
||||
struct dynsec__role *role, *role_tmp;
|
||||
struct dynsec__role *role, *role_tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, local_roles, role, role_tmp){
|
||||
role__free_item(role, true);
|
||||
@ -115,7 +115,7 @@ void dynsec_roles__cleanup(void)
|
||||
|
||||
static void role__kick_all(struct dynsec__role *role)
|
||||
{
|
||||
struct dynsec__grouplist *grouplist, *grouplist_tmp;
|
||||
struct dynsec__grouplist *grouplist, *grouplist_tmp = NULL;
|
||||
|
||||
dynsec_clientlist__kick_all(role->clientlist);
|
||||
|
||||
@ -137,7 +137,7 @@ static void role__kick_all(struct dynsec__role *role)
|
||||
|
||||
static int add_single_acl_to_json(cJSON *j_array, const char *acl_type, struct dynsec__acl *acl)
|
||||
{
|
||||
struct dynsec__acl *iter, *tmp;
|
||||
struct dynsec__acl *iter, *tmp = NULL;
|
||||
cJSON *j_acl;
|
||||
|
||||
HASH_ITER(hh, acl, iter, tmp){
|
||||
@ -185,7 +185,7 @@ static int add_acls_to_json(cJSON *j_role, struct dynsec__role *role)
|
||||
int dynsec_roles__config_save(cJSON *tree)
|
||||
{
|
||||
cJSON *j_roles, *j_role;
|
||||
struct dynsec__role *role, *role_tmp;
|
||||
struct dynsec__role *role, *role_tmp = NULL;
|
||||
|
||||
if((j_roles = cJSON_AddArrayToObject(tree, "roles")) == NULL){
|
||||
return 1;
|
||||
@ -433,7 +433,7 @@ error:
|
||||
|
||||
static void role__remove_all_clients(struct dynsec__role *role)
|
||||
{
|
||||
struct dynsec__clientlist *clientlist, *clientlist_tmp;
|
||||
struct dynsec__clientlist *clientlist, *clientlist_tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, role->clientlist, clientlist, clientlist_tmp){
|
||||
mosquitto_kick_client_by_username(clientlist->client->username, false);
|
||||
@ -444,7 +444,7 @@ static void role__remove_all_clients(struct dynsec__role *role)
|
||||
|
||||
static void role__remove_all_groups(struct dynsec__role *role)
|
||||
{
|
||||
struct dynsec__grouplist *grouplist, *grouplist_tmp;
|
||||
struct dynsec__grouplist *grouplist, *grouplist_tmp = NULL;
|
||||
|
||||
HASH_ITER(hh, role->grouplist, grouplist, grouplist_tmp){
|
||||
if(grouplist->group == dynsec_anonymous_group){
|
||||
@ -526,7 +526,7 @@ static cJSON *add_role_to_json(struct dynsec__role *role, bool verbose)
|
||||
int dynsec_roles__process_list(cJSON *j_responses, struct mosquitto *context, cJSON *command, char *correlation_data)
|
||||
{
|
||||
bool verbose;
|
||||
struct dynsec__role *role, *role_tmp;
|
||||
struct dynsec__role *role, *role_tmp = NULL;
|
||||
cJSON *tree, *j_roles, *j_role, *j_data;
|
||||
int i, count, offset;
|
||||
const char *admin_clientid, *admin_username;
|
||||
|
@ -32,8 +32,6 @@ Contributors:
|
||||
*
|
||||
* Note that this only works on Mosquitto 2.0 or later.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@ -42,6 +40,8 @@ Contributors:
|
||||
#include "mosquitto.h"
|
||||
#include "mqtt_protocol.h"
|
||||
|
||||
#define UNUSED(A) (void)(A)
|
||||
|
||||
static mosquitto_plugin_id_t *mosq_pid = NULL;
|
||||
|
||||
static int callback_message(int event, void *event_data, void *userdata)
|
||||
@ -50,6 +50,9 @@ static int callback_message(int event, void *event_data, void *userdata)
|
||||
char *new_payload;
|
||||
uint32_t new_payloadlen;
|
||||
|
||||
UNUSED(event);
|
||||
UNUSED(userdata);
|
||||
|
||||
/* This simply adds "hello " to the front of every payload. You can of
|
||||
* course do much more complicated message processing if needed. */
|
||||
|
||||
@ -91,11 +94,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_MESSAGE, callback_message, 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_MESSAGE, callback_message, NULL);
|
||||
}
|
||||
|
@ -86,7 +86,7 @@ int bridge__new(struct mosquitto__bridge *bridge)
|
||||
mosquitto__free(local_id);
|
||||
}else{
|
||||
/* id wasn't found, so generate a new context */
|
||||
new_context = context__init(-1);
|
||||
new_context = context__init(INVALID_SOCKET);
|
||||
if(!new_context){
|
||||
mosquitto__free(local_id);
|
||||
return MOSQ_ERR_NOMEM;
|
||||
|
@ -2047,7 +2047,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
||||
token = strtok_r(NULL, " ", &saveptr);
|
||||
if(token){
|
||||
if (token[0] == '#'){
|
||||
strtok_r(NULL, "", &saveptr);
|
||||
(void)strtok_r(NULL, "", &saveptr);
|
||||
}
|
||||
qos = (uint8_t)atoi(token);
|
||||
if(qos > 2){
|
||||
@ -2060,7 +2060,7 @@ int config__read_file_core(struct mosquitto__config *config, bool reload, struct
|
||||
if(!strcmp(token, "\"\"") || token[0] == '#'){
|
||||
local_prefix = NULL;
|
||||
if (token[0] == '#'){
|
||||
strtok_r(NULL, "", &saveptr);
|
||||
(void)strtok_r(NULL, "", &saveptr);
|
||||
}
|
||||
}else{
|
||||
local_prefix = token;
|
||||
@ -2275,7 +2275,7 @@ static int config__check(struct mosquitto__config *config)
|
||||
if(!config->listeners[i].security_options.auto_id_prefix){
|
||||
return MOSQ_ERR_NOMEM;
|
||||
}
|
||||
config->listeners[i].security_options.auto_id_prefix_len = strlen("auto-");
|
||||
config->listeners[i].security_options.auto_id_prefix_len = (uint16_t)strlen("auto-");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
@ -2284,7 +2284,7 @@ static int config__check(struct mosquitto__config *config)
|
||||
if(!config->security_options.auto_id_prefix){
|
||||
return MOSQ_ERR_NOMEM;
|
||||
}
|
||||
config->security_options.auto_id_prefix_len = strlen("auto-");
|
||||
config->security_options.auto_id_prefix_len = (uint16_t)strlen("auto-");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ int scmp_p(const void *p1, const void *p2)
|
||||
#ifdef WIN32
|
||||
int config__get_dir_files(const char *include_dir, char ***files, int *file_count)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
int i;
|
||||
char **l_files = NULL;
|
||||
int l_file_count = 0;
|
||||
|
@ -124,7 +124,7 @@ int control__unregister_callback(struct mosquitto__security_options *opts, MOSQ_
|
||||
if(strncmp(topic, "$CONTROL/", strlen("$CONTROL/"))) return MOSQ_ERR_INVAL;
|
||||
|
||||
HASH_FIND(hh, opts->plugin_callbacks.control, topic, topic_len, cb_found);
|
||||
if(cb_found){
|
||||
if(cb_found && cb_found->cb == cb_func){
|
||||
HASH_DELETE(hh, opts->plugin_callbacks.control, cb_found);
|
||||
mosquitto__free(cb_found->data);
|
||||
mosquitto__free(cb_found);
|
||||
|
@ -90,8 +90,8 @@ bool db__ready_for_queue(struct mosquitto *context, int qos, struct mosquitto_ms
|
||||
{
|
||||
int source_count;
|
||||
int adjust_count;
|
||||
unsigned long source_bytes;
|
||||
unsigned long adjust_bytes = db.config->max_inflight_bytes;
|
||||
size_t source_bytes;
|
||||
size_t adjust_bytes = db.config->max_inflight_bytes;
|
||||
bool valid_bytes;
|
||||
bool valid_count;
|
||||
|
||||
@ -148,10 +148,10 @@ int db__open(struct mosquitto__config *config)
|
||||
|
||||
db.subs = NULL;
|
||||
|
||||
subhier = sub__add_hier_entry(NULL, &db.subs, "", strlen(""));
|
||||
subhier = sub__add_hier_entry(NULL, &db.subs, "", 0);
|
||||
if(!subhier) return MOSQ_ERR_NOMEM;
|
||||
|
||||
subhier = sub__add_hier_entry(NULL, &db.subs, "$SYS", strlen("$SYS"));
|
||||
subhier = sub__add_hier_entry(NULL, &db.subs, "$SYS", (uint16_t)strlen("$SYS"));
|
||||
if(!subhier) return MOSQ_ERR_NOMEM;
|
||||
|
||||
retain__init();
|
||||
@ -312,6 +312,8 @@ void db__message_dequeue_first(struct mosquitto *context, struct mosquitto_msg_d
|
||||
{
|
||||
struct mosquitto_client_msg *msg;
|
||||
|
||||
UNUSED(context);
|
||||
|
||||
msg = msg_data->queued;
|
||||
DL_DELETE(msg_data->queued, msg);
|
||||
DL_APPEND(msg_data->inflight, msg);
|
||||
|
@ -33,7 +33,7 @@ int handle__unsubscribe(struct mosquitto *context)
|
||||
char *sub;
|
||||
uint16_t slen;
|
||||
int rc;
|
||||
uint8_t reason;
|
||||
uint8_t reason = 0;
|
||||
int reason_code_count = 0;
|
||||
int reason_code_max;
|
||||
uint8_t *reason_codes = NULL, *reason_tmp;
|
||||
|
@ -27,6 +27,8 @@ static time_t last_keepalive_check = 0;
|
||||
|
||||
int keepalive__add(struct mosquitto *context)
|
||||
{
|
||||
UNUSED(context);
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
@ -58,6 +60,8 @@ void keepalive__check(void)
|
||||
|
||||
int keepalive__remove(struct mosquitto *context)
|
||||
{
|
||||
UNUSED(context);
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -140,6 +140,8 @@ int drop_privileges(struct mosquitto__config *config)
|
||||
log__printf(NULL, MOSQ_LOG_WARNING, "Warning: Mosquitto should not be run as root/administrator.");
|
||||
}
|
||||
}
|
||||
#else
|
||||
UNUSED(config);
|
||||
#endif
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
}
|
||||
@ -237,7 +239,7 @@ int listeners__start_single_mqtt(struct mosquitto__listener *listener)
|
||||
|
||||
|
||||
#ifdef WITH_WEBSOCKETS
|
||||
void listeners__add_websockets(struct lws_context *ws_context, int fd)
|
||||
void listeners__add_websockets(struct lws_context *ws_context, mosq_sock_t fd)
|
||||
{
|
||||
int i;
|
||||
struct mosquitto__listener *listener = NULL;
|
||||
@ -624,6 +626,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
|
||||
char *saveptr = NULL;
|
||||
int rc;
|
||||
|
||||
UNUSED(hInstance);
|
||||
UNUSED(hPrevInstance);
|
||||
UNUSED(nCmdShow);
|
||||
|
||||
argv = mosquitto__malloc(sizeof(char *)*1);
|
||||
argv[0] = "mosquitto";
|
||||
token = strtok_r(lpCmdLine, " ", &saveptr);
|
||||
|
@ -747,7 +747,7 @@ int mux__cleanup(void);
|
||||
void listener__set_defaults(struct mosquitto__listener *listener);
|
||||
void listeners__reload_all_certificates(void);
|
||||
#ifdef WITH_WEBSOCKETS
|
||||
void listeners__add_websockets(struct lws_context *ws_context, int fd);
|
||||
void listeners__add_websockets(struct lws_context *ws_context, mosq_sock_t fd);
|
||||
#endif
|
||||
|
||||
/* ============================================================
|
||||
|
@ -56,7 +56,7 @@ Contributors:
|
||||
#include "util_mosq.h"
|
||||
#include "mux.h"
|
||||
|
||||
static void loop_handle_reads_writes(struct pollfd *pollfds);
|
||||
static void loop_handle_reads_writes(void);
|
||||
|
||||
static struct pollfd *pollfds = NULL;
|
||||
static size_t pollfd_max, pollfd_current_max;
|
||||
@ -235,7 +235,7 @@ int mux_poll__handle(struct mosquitto__listener_sock *listensock, int listensock
|
||||
log__printf(NULL, MOSQ_LOG_ERR, "Error in poll: %s.", strerror(errno));
|
||||
}
|
||||
}else{
|
||||
loop_handle_reads_writes(pollfds);
|
||||
loop_handle_reads_writes();
|
||||
|
||||
for(i=0; i<listensock_count; i++){
|
||||
if(pollfds[i].revents & POLLIN){
|
||||
@ -267,7 +267,7 @@ int mux_poll__cleanup(void)
|
||||
}
|
||||
|
||||
|
||||
static void loop_handle_reads_writes(struct pollfd *pollfds)
|
||||
static void loop_handle_reads_writes(void)
|
||||
{
|
||||
struct mosquitto *context, *ctxt_tmp;
|
||||
int err;
|
||||
|
@ -54,7 +54,7 @@ static struct mosquitto *persist__find_or_add_context(const char *client_id, uin
|
||||
context = NULL;
|
||||
HASH_FIND(hh_id, db.contexts_by_id, client_id, strlen(client_id), context);
|
||||
if(!context){
|
||||
context = context__init(-1);
|
||||
context = context__init(INVALID_SOCKET);
|
||||
if(!context) return NULL;
|
||||
context->id = mosquitto__strdup(client_id);
|
||||
if(!context->id){
|
||||
|
@ -62,10 +62,10 @@ int retain__init(void)
|
||||
{
|
||||
struct mosquitto__retainhier *retainhier;
|
||||
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "", (int)strlen(""));
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "", 0);
|
||||
if(!retainhier) return MOSQ_ERR_NOMEM;
|
||||
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "$SYS", (int)strlen("$SYS"));
|
||||
retainhier = retain__add_hier_entry(NULL, &db.retains, "$SYS", (uint16_t)strlen("$SYS"));
|
||||
if(!retainhier) return MOSQ_ERR_NOMEM;
|
||||
|
||||
return MOSQ_ERR_SUCCESS;
|
||||
|
@ -47,7 +47,7 @@ int mosquitto_security_init_default(bool reload)
|
||||
int rc;
|
||||
int i;
|
||||
char *pwf;
|
||||
char *pskf;
|
||||
char *pskf = NULL;
|
||||
|
||||
UNUSED(reload);
|
||||
|
||||
@ -136,7 +136,7 @@ int mosquitto_security_init_default(bool reload)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
char *pskf = db.config->security_options.psk_file;
|
||||
pskf = db.config->security_options.psk_file;
|
||||
if(pskf){
|
||||
rc = psk__file_parse(&db.config->security_options.psk_id, pskf);
|
||||
if(rc){
|
||||
@ -372,6 +372,9 @@ static int mosquitto_acl_check_default(int event, void *event_data, void *userda
|
||||
char *s;
|
||||
struct mosquitto__security_options *security_opts = NULL;
|
||||
|
||||
UNUSED(event);
|
||||
UNUSED(userdata);
|
||||
|
||||
if(ed->client->bridge) return MOSQ_ERR_SUCCESS;
|
||||
if(ed->access == MOSQ_ACL_SUBSCRIBE || ed->access == MOSQ_ACL_UNSUBSCRIBE) return MOSQ_ERR_SUCCESS; /* FIXME - implement ACL subscription strings. */
|
||||
|
||||
@ -667,7 +670,7 @@ static void acl__cleanup_single(struct mosquitto__security_options *security_opt
|
||||
|
||||
static int acl__cleanup(bool reload)
|
||||
{
|
||||
struct mosquitto *context, *ctxt_tmp;
|
||||
struct mosquitto *context, *ctxt_tmp = NULL;
|
||||
int i;
|
||||
|
||||
UNUSED(reload);
|
||||
@ -833,7 +836,7 @@ void unpwd__free_item(struct mosquitto__unpwd **unpwd, struct mosquitto__unpwd *
|
||||
#ifdef WITH_TLS
|
||||
static int unpwd__decode_passwords(struct mosquitto__unpwd **unpwd)
|
||||
{
|
||||
struct mosquitto__unpwd *u, *tmp;
|
||||
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||
char *token;
|
||||
unsigned char *salt;
|
||||
unsigned int salt_len;
|
||||
@ -939,7 +942,7 @@ static int unpwd__file_parse(struct mosquitto__unpwd **unpwd, const char *passwo
|
||||
static int psk__file_parse(struct mosquitto__unpwd **psk_id, const char *psk_file)
|
||||
{
|
||||
int rc;
|
||||
struct mosquitto__unpwd *u, *tmp;
|
||||
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||
|
||||
if(!db.config || !psk_id) return MOSQ_ERR_INVAL;
|
||||
|
||||
@ -993,6 +996,9 @@ static int mosquitto_unpwd_check_default(int event, void *event_data, void *user
|
||||
int rc;
|
||||
#endif
|
||||
|
||||
UNUSED(event);
|
||||
UNUSED(userdata);
|
||||
|
||||
if(ed->client->username == NULL){
|
||||
return MOSQ_ERR_PLUGIN_DEFER;
|
||||
}
|
||||
@ -1038,7 +1044,7 @@ static int mosquitto_unpwd_check_default(int event, void *event_data, void *user
|
||||
|
||||
static int unpwd__cleanup(struct mosquitto__unpwd **root, bool reload)
|
||||
{
|
||||
struct mosquitto__unpwd *u, *tmp;
|
||||
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||
|
||||
UNUSED(reload);
|
||||
|
||||
@ -1079,7 +1085,7 @@ static void security__disconnect_auth(struct mosquitto *context)
|
||||
*/
|
||||
int mosquitto_security_apply_default(void)
|
||||
{
|
||||
struct mosquitto *context, *ctxt_tmp;
|
||||
struct mosquitto *context, *ctxt_tmp = NULL;
|
||||
struct mosquitto__acl_user *acl_user_tail;
|
||||
bool allow_anonymous;
|
||||
struct mosquitto__security_options *security_opts = NULL;
|
||||
@ -1289,7 +1295,7 @@ int mosquitto_security_apply_default(void)
|
||||
|
||||
int mosquitto_psk_key_get_default(struct mosquitto *context, const char *hint, const char *identity, char *key, int max_key_len)
|
||||
{
|
||||
struct mosquitto__unpwd *u, *tmp;
|
||||
struct mosquitto__unpwd *u, *tmp = NULL;
|
||||
struct mosquitto__unpwd *psk_id_ref = NULL;
|
||||
|
||||
if(!hint || !identity || !key) return MOSQ_ERR_INVAL;
|
||||
|
@ -31,7 +31,7 @@ int main(int argc, char *argv[]);
|
||||
|
||||
static void print_error(void)
|
||||
{
|
||||
char *buf;
|
||||
char *buf = NULL;
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, GetLastError(), LANG_NEUTRAL, (LPTSTR)&buf, 0, NULL);
|
||||
@ -70,6 +70,9 @@ void __stdcall service_main(DWORD dwArgc, LPTSTR *lpszArgv)
|
||||
char conf_path[MAX_PATH + 20];
|
||||
int rc;
|
||||
|
||||
UNUSED(dwArgc);
|
||||
UNUSED(lpszArgv);
|
||||
|
||||
service_handle = RegisterServiceCtrlHandler("mosquitto", service_handler);
|
||||
if(service_handle){
|
||||
memset(conf_path, 0, sizeof(conf_path));
|
||||
|
@ -92,6 +92,8 @@ DWORD WINAPI SigThreadProc(void* data)
|
||||
static HANDLE evt[3];
|
||||
int pid = GetCurrentProcessId();
|
||||
|
||||
UNUSED(data);
|
||||
|
||||
sprintf_s(evt_name, MAX_PATH, "mosq%d_shutdown", pid);
|
||||
evt[0] = CreateEvent(NULL, TRUE, FALSE, evt_name);
|
||||
sprintf_s(evt_name, MAX_PATH, "mosq%d_reload", pid);
|
||||
|
@ -253,7 +253,7 @@ static int sub__add_shared(struct mosquitto *context, uint8_t qos, uint32_t iden
|
||||
}
|
||||
}
|
||||
if(shared_ref){
|
||||
shared_subs = mosquitto__realloc(context->shared_subs, sizeof(struct mosquitto__subhier_ref *)*(size_t)(context->shared_sub_count + 1));
|
||||
shared_subs = mosquitto__realloc(context->shared_subs, sizeof(struct mosquitto__subshared_ref *)*(size_t)(context->shared_sub_count + 1));
|
||||
if(!shared_subs){
|
||||
mosquitto__free(shared_ref);
|
||||
context->shared_subs[context->shared_sub_count-1] = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user