1
0
mirror of https://github.com/eclipse/mosquitto.git synced 2025-04-19 10:22:16 +03:00

Whitespace tidy

This commit is contained in:
Roger A. Light 2025-04-06 22:25:02 +01:00
parent f522dcaeed
commit c6c6850d5c
28 changed files with 175 additions and 175 deletions

View File

@ -29,7 +29,7 @@ int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store
UNUSED(message_expiry_interval);
UNUSED(store_id);
UNUSED(origin);
return 0;
return 0;
}
void db__msg_store_ref_inc(struct mosquitto_msg_store *store)

View File

@ -127,7 +127,7 @@ int client_request_response(struct mosq_ctrl *ctrl)
int rc;
time_t start;
if(ctrl->cfg.cafile == NULL && ctrl->cfg.capath == NULL && !ctrl->cfg.tls_use_os_certs && ctrl->cfg.port != 8883
if(ctrl->cfg.cafile == NULL && ctrl->cfg.capath == NULL && !ctrl->cfg.tls_use_os_certs && ctrl->cfg.port != 8883
# ifdef FINAL_WITH_TLS_PSK
&& !ctrl->cfg.psk
# endif

View File

@ -389,8 +389,8 @@ static int client_config_line_proc(struct mosq_config *cfg, int *argc, char **ar
}
argv++;
(*argc)--;
}else if(!strcmp(argv[0], "--tls-use-os-certs")){
cfg->tls_use_os_certs = true;
}else if(!strcmp(argv[0], "--tls-use-os-certs")){
cfg->tls_use_os_certs = true;
}else if(!strcmp(argv[0], "--tls-version")){
if((*argc) == 1){
fprintf(stderr, "Error: --tls-version argument given but no version specified.\n\n");
@ -620,12 +620,12 @@ int client_opts_set(struct mosquitto *mosq, struct mosq_config *cfg)
return 1;
}
# endif
}else if(cfg->port == 8883){
mosquitto_int_option(mosq, MOSQ_OPT_TLS_USE_OS_CERTS, 1);
}
if(cfg->tls_use_os_certs){
mosquitto_int_option(mosq, MOSQ_OPT_TLS_USE_OS_CERTS, 1);
}
}else if(cfg->port == 8883){
mosquitto_int_option(mosq, MOSQ_OPT_TLS_USE_OS_CERTS, 1);
}
if(cfg->tls_use_os_certs){
mosquitto_int_option(mosq, MOSQ_OPT_TLS_USE_OS_CERTS, 1);
}
if(cfg->insecure && mosquitto_tls_insecure_set(mosq, true)){
fprintf(stderr, "Error: Problem setting TLS insecure option.\n");

View File

@ -281,7 +281,7 @@ int main(int argc, char *argv[])
{
int rc;
#ifndef WIN32
struct sigaction sigact;
struct sigaction sigact;
#endif
mosquitto_lib_init();

View File

@ -318,7 +318,7 @@ int main(int argc, char *argv[])
{
int rc;
#ifndef WIN32
struct sigaction sigact;
struct sigaction sigact;
#endif
mosquitto_lib_init();

View File

@ -89,7 +89,7 @@ int main(int argc, char *argv[])
mosquitto_message_callback_set(mosq, message_callback);
rc = mosquitto_connect(mosq, mqtt_host, mqtt_port, 60);
rc = mosquitto_connect(mosq, mqtt_host, mqtt_port, 60);
mosquitto_subscribe(mosq, NULL, "#", 0);

View File

@ -193,8 +193,8 @@ static int mosquitto__reconnect(struct mosquitto *mosq, bool blocking)
message__reconnect_reset(mosq, false);
if(mosq->sock != INVALID_SOCKET){
net__socket_close(mosq);
}
net__socket_close(mosq);
}
#ifdef WITH_SOCKS
if(mosq->socks5_host){

View File

@ -275,12 +275,12 @@ void mosquitto__destroy(struct mosquitto *mosq)
if(mosq->user_ssl_ctx){
SSL_CTX_free(mosq->user_ssl_ctx);
}else if(mosq->ssl_ctx){
SSL_CTX_free(mosq->ssl_ctx);
}
SSL_CTX_free(mosq->ssl_ctx);
}
#else
if(mosq->ssl_ctx){
SSL_CTX_free(mosq->ssl_ctx);
}
if(mosq->ssl_ctx){
SSL_CTX_free(mosq->ssl_ctx);
}
#endif
mosquitto__free(mosq->tls_cafile);
mosquitto__free(mosq->tls_capath);

View File

@ -722,8 +722,8 @@ static int net__init_ssl_ctx(struct mosquitto *mosq)
}
#ifdef SSL_MODE_RELEASE_BUFFERS
/* Use even less memory per SSL connection. */
SSL_CTX_set_mode(mosq->ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
/* Use even less memory per SSL connection. */
SSL_CTX_set_mode(mosq->ssl_ctx, SSL_MODE_RELEASE_BUFFERS);
#endif
#if !defined(OPENSSL_NO_ENGINE)

View File

@ -89,7 +89,7 @@ int mosquitto__verify_ocsp_status_cb(SSL * ssl, void *arg)
ocsp_status = OCSP_response_status(rsp);
if(ocsp_status != OCSP_RESPONSE_STATUS_SUCCESSFUL) {
log__printf(mosq, MOSQ_LOG_DEBUG, "OCSP: invalid status: %s (%d)",
OCSP_response_status_str(ocsp_status), ocsp_status);
OCSP_response_status_str(ocsp_status), ocsp_status);
goto end;
}

View File

@ -247,7 +247,7 @@ int packet__write(struct mosquitto *mosq)
#ifdef WITH_BROKER
if(mosq->current_out_packet){
mux__add_out(mosq);
mux__add_out(mosq);
}
#endif

View File

@ -70,7 +70,7 @@ time_t mosquitto_time(void)
return (time_t) -1;
#elif defined(__APPLE__)
static mach_timebase_info_data_t tb;
uint64_t ticks;
uint64_t ticks;
uint64_t sec;
ticks = mach_absolute_time();

View File

@ -647,7 +647,7 @@ void bridge__packet_cleanup(struct mosquitto *context)
mosquitto__free(context->current_out_packet);
context->current_out_packet = NULL;
}
while(context->out_packet){
while(context->out_packet){
packet__cleanup(context->out_packet);
packet = context->out_packet;
context->out_packet = context->out_packet->next;

View File

@ -742,7 +742,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
size_t slen;
#ifdef WITH_TLS
char *kpass_sha = NULL, *kpass_sha_bin = NULL;
char *keyform ;
char *keyform;
#endif
*lineno = 0;
@ -2315,23 +2315,23 @@ static int config__check(struct mosquitto__config *config)
/* Check for missing TLS cafile/capath/certfile/keyfile */
for(int i=0; i<config->listener_count; i++){
bool cafile = !!config->listeners[i].cafile;
bool capath = !!config->listeners[i].capath;
bool certfile = !!config->listeners[i].certfile;
bool keyfile = !!config->listeners[i].keyfile;
bool cafile = !!config->listeners[i].cafile;
bool capath = !!config->listeners[i].capath;
bool certfile = !!config->listeners[i].certfile;
bool keyfile = !!config->listeners[i].keyfile;
if((certfile && !keyfile) || (!certfile && keyfile)){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Both certfile and keyfile must be provided to enable a TLS listener.");
return MOSQ_ERR_INVAL;
}
if(cafile && !certfile){
log__printf(NULL, MOSQ_LOG_ERR, "Error: cafile specified without certfile and keyfile.");
return MOSQ_ERR_INVAL;
}
if(capath && !certfile){
log__printf(NULL, MOSQ_LOG_ERR, "Error: capath specified without certfile and keyfile.");
return MOSQ_ERR_INVAL;
}
if((certfile && !keyfile) || (!certfile && keyfile)){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Both certfile and keyfile must be provided to enable a TLS listener.");
return MOSQ_ERR_INVAL;
}
if(cafile && !certfile){
log__printf(NULL, MOSQ_LOG_ERR, "Error: cafile specified without certfile and keyfile.");
return MOSQ_ERR_INVAL;
}
if(capath && !certfile){
log__printf(NULL, MOSQ_LOG_ERR, "Error: capath specified without certfile and keyfile.");
return MOSQ_ERR_INVAL;
}
}
return MOSQ_ERR_SUCCESS;
}

View File

@ -36,7 +36,7 @@ Contributors:
* will appear after this point at the position indexed by the time at which
* they will expire if they do not send another message, assuming they do not
* have keepalive==0 - in which case they are not part of this check. So a
* client that connects with keepalive=60 will be added at `now + 60*1.5`.
* client that connects with keepalive=60 will be added at `now + 60*1.5`.
*
* A client is added to an entry with a doubly linked list. When the client
* sends a new message, it is removed from the old position and added to the

View File

@ -134,7 +134,7 @@ int mux_epoll__remove_out(struct mosquitto *context)
ev.events = EPOLLIN;
if(epoll_ctl(db.epollfd, EPOLL_CTL_ADD, context->sock, &ev) == -1) {
if((errno != EEXIST)||(epoll_ctl(db.epollfd, EPOLL_CTL_MOD, context->sock, &ev) == -1)) {
log__printf(NULL, MOSQ_LOG_DEBUG, "Error in epoll re-registering to EPOLLIN: %s", strerror(errno));
log__printf(NULL, MOSQ_LOG_DEBUG, "Error in epoll re-registering to EPOLLIN: %s", strerror(errno));
}
}
context->events = EPOLLIN;

View File

@ -175,7 +175,7 @@ struct mosquitto *net__socket_accept(struct mosquitto__listener_sock *listensock
if(db.config->set_tcp_nodelay){
int flag = 1;
#ifdef WIN32
if (setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) != 0) {
if (setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)) != 0) {
#else
if(setsockopt(new_sock, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(int)) != 0){
#endif

View File

@ -54,7 +54,7 @@ int send__unsuback(struct mosquitto *mosq, uint16_t mid, int reason_code_count,
if(mosq->protocol == mosq_p_mqtt5){
property__write_all(packet, properties, true);
packet__write_bytes(packet, reason_codes, (uint32_t)reason_code_count);
packet__write_bytes(packet, reason_codes, (uint32_t)reason_code_count);
}
return packet__queue(mosq, packet);

View File

@ -809,22 +809,22 @@ void sub__tree_print(struct mosquitto__subhier *root, int level)
struct mosquitto__subleaf *leaf;
HASH_ITER(hh, root, branch, branch_tmp){
if(level > -1){
for(i=0; i<(level+2)*2; i++){
printf(" ");
}
printf("%s", branch->topic);
leaf = branch->subs;
while(leaf){
if(leaf->context){
printf(" (%s, %d)", leaf->context->id, leaf->qos);
}else{
printf(" (%s, %d)", "", leaf->qos);
if(level > -1){
for(i=0; i<(level+2)*2; i++){
printf(" ");
}
leaf = leaf->next;
printf("%s", branch->topic);
leaf = branch->subs;
while(leaf){
if(leaf->context){
printf(" (%s, %d)", leaf->context->id, leaf->qos);
}else{
printf(" (%s, %d)", "", leaf->qos);
}
leaf = leaf->next;
}
printf("\n");
}
printf("\n");
}
sub__tree_print(branch->children, level+1);
}

View File

@ -543,7 +543,7 @@ static int callback_http(
"Server: mosquitto\r\n"
"Content-Length: %u\r\n\r\n",
(unsigned int)filestat.st_size);
if(lws_write(wsi, buf, buflen, LWS_WRITE_HTTP) < 0){
if(lws_write(wsi, buf, buflen, LWS_WRITE_HTTP) < 0){
fclose(u->fptr);
u->fptr = NULL;
return -1;
@ -723,7 +723,7 @@ void mosq_websockets_init(struct mosquitto__listener *listener, const struct mos
if(listener->socket_domain == AF_INET){
info.options |= LWS_SERVER_OPTION_DISABLE_IPV6;
}
info.max_http_header_data = conf->websockets_headers_size;
info.max_http_header_data = conf->websockets_headers_size;
user = mosquitto__calloc(1, sizeof(struct libws_mqtt_hack));
if(!user){

View File

@ -104,24 +104,24 @@ int main(int argc, char *argv[])
UNUSED(argc);
UNUSED(argv);
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(0
if(0
|| init_bridge_tests()
){
CU_cleanup_registry();
return 1;
}
CU_cleanup_registry();
return 1;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
fails = CU_get_number_of_failures();
CU_cleanup_registry();
CU_cleanup_registry();
return (int)fails;
return (int)fails;
}

View File

@ -50,54 +50,54 @@ void db__msg_store_free(struct mosquitto_msg_store *store)
int db__message_store(const struct mosquitto *source, struct mosquitto_msg_store *stored, uint32_t message_expiry_interval, dbid_t store_id, enum mosquitto_msg_origin origin)
{
int rc = MOSQ_ERR_SUCCESS;
int rc = MOSQ_ERR_SUCCESS;
UNUSED(origin);
if(source && source->id){
stored->source_id = mosquitto__strdup(source->id);
}else{
stored->source_id = mosquitto__strdup("");
}
if(!stored->source_id){
rc = MOSQ_ERR_NOMEM;
goto error;
}
if(source && source->id){
stored->source_id = mosquitto__strdup(source->id);
}else{
stored->source_id = mosquitto__strdup("");
}
if(!stored->source_id){
rc = MOSQ_ERR_NOMEM;
goto error;
}
if(source && source->username){
stored->source_username = mosquitto__strdup(source->username);
if(!stored->source_username){
rc = MOSQ_ERR_NOMEM;
goto error;
}
}
if(source){
stored->source_listener = source->listener;
}
stored->mid = 0;
if(message_expiry_interval > 0){
stored->message_expiry_time = time(NULL) + message_expiry_interval;
}else{
stored->message_expiry_time = 0;
}
if(source && source->username){
stored->source_username = mosquitto__strdup(source->username);
if(!stored->source_username){
rc = MOSQ_ERR_NOMEM;
goto error;
}
}
if(source){
stored->source_listener = source->listener;
}
stored->mid = 0;
if(message_expiry_interval > 0){
stored->message_expiry_time = time(NULL) + message_expiry_interval;
}else{
stored->message_expiry_time = 0;
}
stored->dest_ids = NULL;
stored->dest_id_count = 0;
db.msg_store_count++;
db.msg_store_bytes += stored->payloadlen;
stored->dest_ids = NULL;
stored->dest_id_count = 0;
db.msg_store_count++;
db.msg_store_bytes += stored->payloadlen;
if(!store_id){
stored->db_id = ++db.last_db_id;
}else{
stored->db_id = store_id;
}
if(!store_id){
stored->db_id = ++db.last_db_id;
}else{
stored->db_id = store_id;
}
db.msg_store = stored;
return MOSQ_ERR_SUCCESS;
return MOSQ_ERR_SUCCESS;
error:
db__msg_store_free(stored);
return rc;
return rc;
}
int log__printf(struct mosquitto *mosq, unsigned int priority, const char *fmt, ...)

View File

@ -835,23 +835,23 @@ int main(int argc, char *argv[])
UNUSED(argc);
UNUSED(argv);
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(0
if(0
|| init_persist_read_tests()
){
CU_cleanup_registry();
return 1;
}
CU_cleanup_registry();
return 1;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
fails = CU_get_number_of_failures();
CU_cleanup_registry();
CU_cleanup_registry();
return (int)fails;
return (int)fails;
}

View File

@ -352,15 +352,15 @@ int main(int argc, char *argv[])
UNUSED(argc);
UNUSED(argv);
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
test_suite = CU_add_suite("Persist write", NULL, NULL);
if(!test_suite){
printf("Error adding CUnit persist write test suite.\n");
CU_cleanup_registry();
CU_cleanup_registry();
return 1;
}
@ -374,18 +374,18 @@ int main(int argc, char *argv[])
|| !CU_add_test(test_suite, "v6 client message", TEST_v6_client_message)
|| !CU_add_test(test_suite, "v6 client message+props", TEST_v6_client_message_props)
|| !CU_add_test(test_suite, "v6 sub", TEST_v6_sub)
//|| !CU_add_test(test_suite, "v5 full", TEST_v5_full)
//|| !CU_add_test(test_suite, "v5 full", TEST_v5_full)
){
printf("Error adding persist CUnit tests.\n");
CU_cleanup_registry();
return 1;
}
return 1;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
fails = CU_get_number_of_failures();
CU_cleanup_registry();
CU_cleanup_registry();
return (int)fails;
return (int)fails;
}

View File

@ -92,15 +92,15 @@ int main(int argc, char *argv[])
UNUSED(argc);
UNUSED(argv);
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
test_suite = CU_add_suite("Subs", NULL, NULL);
if(!test_suite){
printf("Error adding CUnit Subs test suite.\n");
CU_cleanup_registry();
CU_cleanup_registry();
return 1;
}
@ -110,13 +110,13 @@ int main(int argc, char *argv[])
printf("Error adding Subs CUnit tests.\n");
CU_cleanup_registry();
return 1;
}
return 1;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
fails = CU_get_number_of_failures();
CU_cleanup_registry();
CU_cleanup_registry();
return (int)fails;
return (int)fails;
}

View File

@ -21,12 +21,12 @@ int main(int argc, char *argv[])
UNUSED(argc);
UNUSED(argv);
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(0
if(0
|| init_utf8_tests()
|| init_datatype_read_tests()
|| init_datatype_write_tests()
@ -38,15 +38,15 @@ int main(int argc, char *argv[])
|| init_misc_trim_tests()
){
CU_cleanup_registry();
return 1;
}
CU_cleanup_registry();
return 1;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
fails = CU_get_number_of_failures();
CU_cleanup_registry();
CU_cleanup_registry();
return (int)fails;
return (int)fails;
}

View File

@ -68,15 +68,15 @@ int main(int argc, char *argv[])
UNUSED(argc);
UNUSED(argv);
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
if(CU_initialize_registry() != CUE_SUCCESS){
printf("Error initializing CUnit registry.\n");
return 1;
}
test_suite = CU_add_suite("Subs", NULL, NULL);
if(!test_suite){
printf("Error adding CUnit TLS test suite.\n");
CU_cleanup_registry();
CU_cleanup_registry();
return 1;
}
@ -90,13 +90,13 @@ int main(int argc, char *argv[])
printf("Error adding TLS CUnit tests.\n");
CU_cleanup_registry();
return 1;
}
return 1;
}
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
fails = CU_get_number_of_failures();
CU_cleanup_registry();
CU_cleanup_registry();
return (int)fails;
return (int)fails;
}

View File

@ -123,7 +123,7 @@ static void TEST_utf8_malformed_sequences(void)
/* 3.2 Lonely start characters */
/* 3.2.1 All 32 first bytes of 2-byte sequences (0xc0-0xdf),
each followed by a space character: */
each followed by a space character: */
utf8_helper("À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß ", MOSQ_ERR_MALFORMED_UTF8);
for(i=0xC0; i<0xE0; i++){
buf[0] = (uint8_t)i;
@ -133,7 +133,7 @@ static void TEST_utf8_malformed_sequences(void)
}
/* 3.2.2 All 16 first bytes of 3-byte sequences (0xe0-0xef),
each followed by a space character: */
each followed by a space character: */
utf8_helper("\"à á â ã ä å æ ç è é ê ë ì í î ï \"", MOSQ_ERR_MALFORMED_UTF8);
for(i=0xe0; i<0xf0; i++){
buf[0] = (uint8_t)i;
@ -143,7 +143,7 @@ static void TEST_utf8_malformed_sequences(void)
}
/* 3.2.3 All 8 first bytes of 4-byte sequences (0xf0-0xf7),
each followed by a space character: */
each followed by a space character: */
utf8_helper("\"ð ñ ò ó ô õ ö ÷ \"", MOSQ_ERR_MALFORMED_UTF8);
for(i=0xF0; i<0xF8; i++){
buf[0] = (uint8_t)i;
@ -153,7 +153,7 @@ static void TEST_utf8_malformed_sequences(void)
}
/* 3.2.4 All 4 first bytes of 5-byte sequences (0xf8-0xfb),
each followed by a space character: */
each followed by a space character: */
utf8_helper("\"ø ù ú û \"", MOSQ_ERR_MALFORMED_UTF8);
for(i=0xF8; i<0xFC; i++){
buf[0] = (uint8_t)i;
@ -163,7 +163,7 @@ static void TEST_utf8_malformed_sequences(void)
}
/* 3.2.5 All 2 first bytes of 6-byte sequences (0xfc-0xfd),
each followed by a space character: */
each followed by a space character: */
utf8_helper("\"ü ý \"", MOSQ_ERR_MALFORMED_UTF8);
utf8_helper("ü ", MOSQ_ERR_MALFORMED_UTF8);
utf8_helper("ý ", MOSQ_ERR_MALFORMED_UTF8);