Skip to content

Commit c7a09b1

Browse files
authored
fix(tmqtt/logging): fix retval checkings (#34530)
1 parent 9651eea commit c7a09b1

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

contrib/libmqtt/ttq/inc/ttqLogging.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ extern "C" {
1111
#define __attribute__(attrib)
1212
#endif
1313

14-
int ttq_log(struct tmqtt *ttq, unsigned int level, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
14+
void ttq_log(struct tmqtt *ttq, unsigned int level, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
1515

1616
#ifdef __cplusplus
1717
}

source/libs/tmqtt/mgmt/src/tmqttMgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void mqttMgmtStopMqttd() {
320320
}
321321
atomic_store_32(&pData->stopCalled, 1);
322322
pData->needCleanUp = false;
323-
uv_process_kill(&pData->process, SIGTERM);
323+
UNUSED(uv_process_kill(&pData->process, SIGTERM));
324324
uv_barrier_destroy(&pData->barrier);
325325

326326
if (uv_thread_join(&pData->thread) != 0) {

source/libs/tmqtt/mqtt/src/tmqttContext.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818
#include <time.h>
1919

20+
#include "tthash.h"
2021
#include "ttqAlias.h"
2122
#include "ttqMemory.h"
2223
#include "ttqPacket.h"
2324
#include "ttqProperty.h"
2425
#include "ttqTime.h"
25-
#include "tthash.h"
2626
#include "ttqUtil.h"
2727

2828
struct tmqtt *ttqCxtInit(ttq_sock_t sock) {
@@ -35,7 +35,7 @@ struct tmqtt *ttqCxtInit(ttq_sock_t sock) {
3535
#ifdef WITH_EPOLL
3636
context->ident = id_client;
3737
#endif
38-
tmqtt__set_state(context, ttq_cs_new);
38+
UNUSED(tmqtt__set_state(context, ttq_cs_new));
3939
context->sock = sock;
4040
context->last_msg_in = db.now_s;
4141
context->next_msg_out = db.now_s + 60;
@@ -127,12 +127,12 @@ void ttqCxtCleanup(struct tmqtt *context, bool force_free) {
127127
ttq_free(context->password);
128128
context->password = NULL;
129129

130-
net__socket_close(context);
130+
UNUSED(net__socket_close(context));
131131
if (force_free) {
132-
ttqSubCleanSession(context);
132+
UNUSED(ttqSubCleanSession(context));
133133
}
134134

135-
ttqDbMessageDelete(context, force_free);
135+
UNUSED(ttqDbMessageDelete(context, force_free));
136136

137137
ttq_free(context->address);
138138
context->address = NULL;
@@ -179,7 +179,7 @@ void ttqCxtDisconnect(struct tmqtt *context) {
179179
// plugin__handle_disconnect(context, -1);
180180

181181
// ttqCxtSendWill(context);
182-
net__socket_close(context);
182+
UNUSED(net__socket_close(context));
183183
{
184184
if (context->session_expiry_interval == 0) {
185185
/* Client session is due to be expired now */
@@ -188,17 +188,17 @@ void ttqCxtDisconnect(struct tmqtt *context) {
188188
ttqCxtAddToDisused(context);
189189
}
190190
} else {
191-
ttqSessionExpiryAdd(context);
191+
UNUSED(ttqSessionExpiryAdd(context));
192192
}
193193
}
194-
ttqKeepaliveRemove(context);
195-
tmqtt__set_state(context, ttq_cs_disconnected);
194+
UNUSED(ttqKeepaliveRemove(context));
195+
UNUSED(tmqtt__set_state(context, ttq_cs_disconnected));
196196
}
197197

198198
void ttqCxtAddToDisused(struct tmqtt *context) {
199199
if (context->state == ttq_cs_disused) return;
200200

201-
tmqtt__set_state(context, ttq_cs_disused);
201+
UNUSED(tmqtt__set_state(context, ttq_cs_disused));
202202

203203
if (context->id) {
204204
ttqCxtRemoveFromById(context);

source/libs/tmqtt/mqtt/src/tmqttLogging.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#include <sys/stat.h>
3030
#endif
3131

32+
#include "tmqttBrokerInt.h"
3233
#include "ttqLogging.h"
3334
#include "ttqMemory.h"
3435
#include "ttqMisc.h"
35-
#include "tmqttBrokerInt.h"
3636
#include "ttqUtil.h"
3737

3838
static char log_fptr_buffer[BUFSIZ];
@@ -105,15 +105,15 @@ int ttqLogInit(struct tmqtt__config *config) {
105105
if (log_destinations & MQTT3_LOG_FILE) {
106106
config->log_fptr = tmqtt__fopen(config->log_file, "at", true);
107107
if (config->log_fptr) {
108-
setvbuf(config->log_fptr, log_fptr_buffer, _IOLBF, sizeof(log_fptr_buffer));
108+
UNUSED(setvbuf(config->log_fptr, log_fptr_buffer, _IOLBF, sizeof(log_fptr_buffer)));
109109
} else {
110110
log_destinations = MQTT3_LOG_STDERR;
111111
log_priorities = TTQ_LOG_ERR;
112112
ttq_log(NULL, TTQ_LOG_ERR, "Error: Unable to open log file %s for writing.", config->log_file);
113113
}
114114
}
115115
if (log_destinations & MQTT3_LOG_STDOUT) {
116-
setvbuf(stdout, NULL, _IOLBF, 0);
116+
UNUSED(setvbuf(stdout, NULL, _IOLBF, 0));
117117
}
118118
#ifdef WITH_DLT
119119
if (log_destinations & MQTT3_LOG_DLT) {
@@ -133,7 +133,7 @@ int ttqLogClose(struct tmqtt__config *config) {
133133
}
134134
if (log_destinations & MQTT3_LOG_FILE) {
135135
if (config->log_fptr) {
136-
fclose(config->log_fptr);
136+
UNUSED(fclose(config->log_fptr));
137137
config->log_fptr = NULL;
138138
}
139139
}
@@ -251,7 +251,7 @@ static int log__vprintf(unsigned int priority, const char *fmt, va_list va) {
251251
if (log_timestamp) {
252252
if (log_timestamp_format) {
253253
struct tm *ti = NULL;
254-
get_time(&ti);
254+
UNUSED(get_time(&ti));
255255
log_line_pos = strftime(log_line, sizeof(log_line), log_timestamp_format, ti);
256256
if (log_line_pos == 0) {
257257
log_line_pos = (size_t)snprintf(log_line, sizeof(log_line), "Time error");
@@ -311,7 +311,7 @@ static int log__vprintf(unsigned int priority, const char *fmt, va_list va) {
311311
return TTQ_ERR_SUCCESS;
312312
}
313313

314-
int ttq_log(struct tmqtt *ttq, unsigned int priority, const char *fmt, ...) {
314+
void ttq_log(struct tmqtt *ttq, unsigned int priority, const char *fmt, ...) {
315315
va_list va;
316316
int rc;
317317

@@ -321,7 +321,7 @@ int ttq_log(struct tmqtt *ttq, unsigned int priority, const char *fmt, ...) {
321321
rc = log__vprintf(priority, fmt, va);
322322
va_end(va);
323323

324-
return rc;
324+
UNUSED(rc);
325325
}
326326

327327
void ttqLogInternal(const char *fmt, ...) {

source/libs/tmqtt/mqtt/src/tmqttSocket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void listeners__stop(void) {
138138

139139
for (i = 0; i < listensock_count; i++) {
140140
if (listensock[i].sock != INVALID_SOCKET) {
141-
COMPAT_CLOSE(listensock[i].sock);
141+
UNUSED(COMPAT_CLOSE(listensock[i].sock));
142142
}
143143
}
144144

@@ -152,7 +152,7 @@ static void listeners__stop(void) {
152152
static void ttq_rand_init(void) {
153153
struct timeval tv;
154154

155-
gettimeofday(&tv, NULL);
155+
UNUSED(gettimeofday(&tv, NULL));
156156
srand((unsigned int)(tv.tv_sec + tv.tv_usec));
157157
}
158158

@@ -322,7 +322,7 @@ static int ttq_init(int argc, char *argv[], struct tmqtt__config *config) {
322322
}
323323

324324
static void ttq_cleanup(void) {
325-
ttqMuxCleanup();
325+
UNUSED(ttqMuxCleanup());
326326

327327
ttq_log_stopping();
328328

@@ -333,7 +333,7 @@ static void ttq_cleanup(void) {
333333
ttqSessionExpiryRemoveAll();
334334
ttq_cxt_cleanup();
335335
listeners__stop();
336-
ttqDbClose();
336+
UNUSED(ttqDbClose());
337337
// tmqtt_security_module_cleanup();
338338
ttqLogClose(db.config);
339339
ttqConfigCleanup(db.config);

0 commit comments

Comments
 (0)