diff --git a/client/pub_shared.c b/client/pub_shared.c index bf73c2a1..34424eec 100644 --- a/client/pub_shared.c +++ b/client/pub_shared.c @@ -109,7 +109,7 @@ int load_file(const char *filename) cfg.message = NULL; cfg.msglen = 0; return 0; - }else if(cfg.msglen < 0){ + }else if(flen < 0){ fclose(fptr); err_printf(&cfg, "Error: Unable to determine size of file \"%s\".\n", filename); return 1; diff --git a/src/bridge.c b/src/bridge.c index 936c2392..199a156d 100644 --- a/src/bridge.c +++ b/src/bridge.c @@ -399,8 +399,8 @@ int bridge__connect(struct mosquitto *context) if (!context->bridge->notifications_local_only) { notification_payload = '0'; rc = will__set(context, notification_topic, 1, ¬ification_payload, 1, true, NULL); - mosquitto__free(notification_topic); if(rc != MOSQ_ERR_SUCCESS){ + mosquitto__free(notification_topic); return rc; } } diff --git a/src/mosquitto.c b/src/mosquitto.c index 8a0eab35..246d2f1f 100644 --- a/src/mosquitto.c +++ b/src/mosquitto.c @@ -303,7 +303,7 @@ int listeners__start(struct mosquitto__listener_sock **listensock, int *listenso if(listeners__start_local_only(listensock, listensock_count)){ db__close(); if(db.config->pid_file){ - remove(db.config->pid_file); + (void)remove(db.config->pid_file); } return 1; } @@ -315,7 +315,7 @@ int listeners__start(struct mosquitto__listener_sock **listensock, int *listenso if(listeners__start_single_mqtt(listensock, listensock_count, &listensock_index, &db.config->listeners[i])){ db__close(); if(db.config->pid_file){ - remove(db.config->pid_file); + (void)remove(db.config->pid_file); } return 1; } diff --git a/src/net.c b/src/net.c index f399ea9c..cbfcb089 100644 --- a/src/net.c +++ b/src/net.c @@ -649,7 +649,11 @@ static int net__socket_listen_tcp(struct mosquitto__listener *listener) #endif #ifdef IPV6_V6ONLY ss_opt = 1; - setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &ss_opt, sizeof(ss_opt)); + if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, &ss_opt, sizeof(ss_opt)) < 0){ + log__printf(NULL, MOSQ_LOG_WARNING, + "Warning when setting listener IPv6 mode: %s.\n", + strerror(errno)); + } #endif if(net__socket_nonblock(&sock)){ diff --git a/src/subs.c b/src/subs.c index 59939c13..2c080c8d 100644 --- a/src/subs.c +++ b/src/subs.c @@ -246,10 +246,11 @@ static int sub__add_shared(struct mosquitto *context, uint8_t qos, uint32_t iden for(i=0; ishared_sub_count; i++){ if(!context->shared_subs[i]){ context->shared_subs[i] = shared_ref; + shared_ref = NULL; break; } } - if(i == context->shared_sub_count){ + if(shared_ref){ shared_subs = mosquitto__realloc(context->shared_subs, sizeof(struct mosquitto__subhier_ref *)*(size_t)(context->shared_sub_count + 1)); if(!shared_subs){ mosquitto__free(shared_ref);