Skip to content

Commit 9da7c40

Browse files
committed
Fix build warnings
1 parent 9560fc2 commit 9da7c40

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

lib/socks_mosq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
6262
#define SOCKS_REPLY_ADDRESS_TYPE_NOT_SUPPORTED 0x08U
6363

6464

65+
#ifdef WITH_SOCKS
6566
static inline int socks5__network_error(struct mosquitto *mosq)
6667
{
6768
WINDOWS_SET_ERRNO_RW();
@@ -79,8 +80,10 @@ static inline int socks5__network_error(struct mosquitto *mosq)
7980
}
8081
}
8182
}
83+
#endif
8284

8385

86+
#ifdef WITH_SOCKS
8487
static inline int socks5__connection_error(struct mosquitto *mosq)
8588
{
8689
uint8_t v = mosq->in_packet.payload[1];
@@ -105,6 +108,7 @@ static inline int socks5__connection_error(struct mosquitto *mosq)
105108
}
106109
return MOSQ_ERR_PROXY;
107110
}
111+
#endif
108112

109113

110114
int mosquitto_socks5_set(struct mosquitto *mosq, const char *host, int port, const char *username, const char *password)

libcommon/password_common.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,25 +73,12 @@ struct mosquitto_pw {
7373
};
7474

7575

76-
static int pw__memcmp_const(const void *a, const void *b, size_t len)
77-
{
7876
#ifdef WITH_TLS
77+
static inline int pw__memcmp_const(const void *a, const void *b, size_t len)
78+
{
7979
return CRYPTO_memcmp(a, b, len);
80-
#else
81-
int rc = 0;
82-
const volatile char *ac = a;
83-
const volatile char *bc = b;
84-
85-
if(!a || !b){
86-
return 1;
87-
}
88-
89-
for(size_t i=0; i<len; i++){
90-
rc |= ((char *)ac)[i] ^ ((char *)bc)[i];
91-
}
92-
return rc;
93-
#endif
9480
}
81+
#endif
9582

9683

9784
/* ==================================================
@@ -221,6 +208,8 @@ static int pw__create_sha512_pbkdf2(struct mosquitto_pw *pw, const char *passwor
221208
pw->valid = (rc == MOSQ_ERR_SUCCESS);
222209
return rc;
223210
#else
211+
UNUSED(pw);
212+
UNUSED(password);
224213
return MOSQ_ERR_NOT_SUPPORTED;
225214
#endif
226215
}
@@ -246,6 +235,8 @@ static int pw__verify_sha512_pbkdf2(struct mosquitto_pw *pw, const char *passwor
246235
return MOSQ_ERR_AUTH;
247236
}
248237
#else
238+
UNUSED(pw);
239+
UNUSED(password);
249240
return MOSQ_ERR_NOT_SUPPORTED;
250241
#endif
251242
}
@@ -282,6 +273,7 @@ static int pw__encode_sha512_pbkdf2(struct mosquitto_pw *pw)
282273

283274
return MOSQ_ERR_SUCCESS;
284275
#else
276+
UNUSED(pw);
285277
return MOSQ_ERR_NOT_SUPPORTED;
286278
#endif
287279
}
@@ -348,6 +340,8 @@ static int pw__decode_sha512_pbkdf2(struct mosquitto_pw *pw, const char *salt_pa
348340
pw->valid = true;
349341
return MOSQ_ERR_SUCCESS;
350342
#else
343+
UNUSED(pw);
344+
UNUSED(salt_password);
351345
return MOSQ_ERR_NOT_SUPPORTED;
352346
#endif
353347
}
@@ -408,6 +402,8 @@ static int pw__create_sha512(struct mosquitto_pw *pw, const char *password)
408402
pw->valid = (rc == MOSQ_ERR_SUCCESS);
409403
return rc;
410404
#else
405+
UNUSED(pw);
406+
UNUSED(password);
411407
return MOSQ_ERR_NOT_SUPPORTED;
412408
#endif
413409
}
@@ -430,6 +426,8 @@ static int pw__verify_sha512(struct mosquitto_pw *pw, const char *password)
430426
return MOSQ_ERR_AUTH;
431427
}
432428
#else
429+
UNUSED(pw);
430+
UNUSED(password);
433431
return MOSQ_ERR_NOT_SUPPORTED;
434432
#endif
435433
}
@@ -465,6 +463,7 @@ static int pw__encode_sha512(struct mosquitto_pw *pw)
465463

466464
return MOSQ_ERR_SUCCESS;
467465
#else
466+
UNUSED(pw);
468467
return MOSQ_ERR_NOT_SUPPORTED;
469468
#endif
470469
}
@@ -519,6 +518,8 @@ static int pw__decode_sha512(struct mosquitto_pw *pw, const char *salt_password)
519518
pw->valid = true;
520519
return MOSQ_ERR_SUCCESS;
521520
#else
521+
UNUSED(pw);
522+
UNUSED(salt_password);
522523
return MOSQ_ERR_NOT_SUPPORTED;
523524
#endif
524525
}

src/handle_connect.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,13 +463,15 @@ inline static int send__connack_error_and_return(struct mosquitto *context, uint
463463
}
464464

465465

466+
#ifdef WITH_TLS
466467
inline static int send__connack_bad_username_or_password_error(struct mosquitto *context, int rc)
467468
{
468469
uint8_t err_code = context->protocol == mosq_p_mqtt5
469470
? (uint8_t)MQTT_RC_BAD_USERNAME_OR_PASSWORD
470471
: (uint8_t)CONNACK_REFUSED_BAD_USERNAME_PASSWORD;
471472
return send__connack_error_and_return(context, err_code, rc);
472473
}
474+
#endif
473475

474476

475477
static int read_protocol_name(struct mosquitto *context, char protocol_name[7])
@@ -973,9 +975,9 @@ static int set_username_from_cert_subject_name(struct mosquitto *context)
973975

974976
static int handle_username_from_cert_options(struct mosquitto *context, char **username, char **password, uint16_t password_len)
975977
{
978+
#ifdef WITH_TLS
976979
int rc;
977980

978-
#ifdef WITH_TLS
979981
if(context->listener->ssl_ctx && (context->listener->use_identity_as_username || context->listener->use_subject_as_username)){
980982
/* Don't need the username or password if provided */
981983
mosquitto_FREE(*username);

src/mux_epoll.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,10 @@ int mux_epoll__handle(void)
161161
int event_count;
162162

163163
memset(&ev, 0, sizeof(struct epoll_event));
164-
#if defined(WITH_WEBSOCKETS)
164+
#if defined(WITH_WEBSOCKETS) && WITH_WEBSOCKETS == WS_IS_LWS
165165
event_count = epoll_wait(db.epollfd, ep_events, MAX_EVENTS, 100);
166166
#else
167-
event_count = epoll_wait(db.epollfd, ep_events, MAX_EVENTS, db.next_event_ms);
167+
event_count = epoll_wait(db.epollfd, ep_events, MAX_EVENTS, (int)db.next_event_ms);
168168
#endif
169169

170170
db.now_s = mosquitto_time();

0 commit comments

Comments
 (0)