From bd011d8fd8347a5ebd7fcafba38103633f8c56a0 Mon Sep 17 00:00:00 2001 From: Links2004 Date: Fri, 6 Sep 2024 20:20:30 +0200 Subject: [PATCH] clang --- src/SocketIOclient.h | 4 ++-- src/WebSockets.h | 10 +++++----- src/WebSocketsClient.cpp | 31 +++++++++++++++---------------- src/WebSocketsClient.h | 8 ++++---- src/WebSocketsServer.cpp | 22 +++++++++++----------- 5 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/SocketIOclient.h b/src/SocketIOclient.h index 99af80b..cd5d2ec 100644 --- a/src/SocketIOclient.h +++ b/src/SocketIOclient.h @@ -56,10 +56,10 @@ class SocketIOclient : protected WebSocketsClient { #ifndef SSL_AXTLS void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", const char * CA_cert = NULL, const char * protocol = "arduino", uint32_t pingInterval = 60 * 1000, uint32_t pongTimeout = 90 * 1000, uint8_t disconnectTimeoutCount = 5); void setSSLClientCertKey(const char * clientCert = NULL, const char * clientPrivateKey = NULL); - #if defined(SSL_BARESSL) +#if defined(SSL_BARESSL) void beginSSLWithCA(const char * host, uint16_t port, const char * url = "/socket.io/?EIO=3", BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino", uint32_t pingInterval = 60 * 1000, uint32_t pongTimeout = 90 * 1000, uint8_t disconnectTimeoutCount = 5); void setSSLClientCertKey(BearSSL::X509List * clientCert = NULL, BearSSL::PrivateKey * clientPrivateKey = NULL); - #endif +#endif #endif #endif bool isConnected(void); diff --git a/src/WebSockets.h b/src/WebSockets.h index 13a022a..c918c9f 100644 --- a/src/WebSockets.h +++ b/src/WebSockets.h @@ -262,9 +262,9 @@ #elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) #if __has_include() - #include +#include #else - #error "Please install WiFiNINA library!" +#error "Please install WiFiNINA library!" #endif #define WEBSOCKETS_NETWORK_CLASS WiFiClient @@ -273,10 +273,10 @@ #elif(WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) #if __has_include() && __has_include() - #include - #include +#include +#include #else - #error "Please install rpcWiFi library!" +#error "Please install rpcWiFi library!" #endif #define WEBSOCKETS_NETWORK_CLASS WiFiClient diff --git a/src/WebSocketsClient.cpp b/src/WebSocketsClient.cpp index 34357ab..e8394f3 100644 --- a/src/WebSocketsClient.cpp +++ b/src/WebSocketsClient.cpp @@ -177,7 +177,6 @@ void WebSocketsClient::setSSLClientCertKey(BearSSL::X509List * clientCert, BearS } #endif // SSL_BARESSL - #endif // SSL_AXTLS #endif // HAS_SSL @@ -245,12 +244,12 @@ void WebSocketsClient::loop(void) { if(_client.isSSL) { DEBUG_WEBSOCKETS("[WS-Client] connect wss...\n"); if(_client.ssl) { - #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) || (WEBSOCKETS_NETWORK_TYPE ==NETWORK_UNOWIFIR4) - // does not support delete (no destructor) - #else - delete _client.ssl; - #endif - +#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_UNOWIFIR4) + // does not support delete (no destructor) +#else + delete _client.ssl; +#endif + _client.ssl = NULL; _client.tcp = NULL; } @@ -295,11 +294,11 @@ void WebSocketsClient::loop(void) { } else { DEBUG_WEBSOCKETS("[WS-Client] connect ws...\n"); if(_client.tcp) { - #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) || (WEBSOCKETS_NETWORK_TYPE ==NETWORK_UNOWIFIR4) - // does not support delete (no destructor) - #else +#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_UNOWIFIR4) + // does not support delete (no destructor) +#else delete _client.tcp; - #endif +#endif _client.tcp = NULL; } _client.tcp = new WEBSOCKETS_NETWORK_CLASS(); @@ -550,11 +549,11 @@ void WebSocketsClient::clientDisconnect(WSclient_t * client) { #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266_ASYNC) client->status = WSC_NOT_CONNECTED; #else - #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) || (WEBSOCKETS_NETWORK_TYPE ==NETWORK_UNOWIFIR4) - // does not support delete (no destructor) - #else - delete client->tcp; - #endif +#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_UNOWIFIR4) + // does not support delete (no destructor) +#else + delete client->tcp; +#endif #endif client->tcp = NULL; } diff --git a/src/WebSocketsClient.h b/src/WebSocketsClient.h index 95a126a..e60088b 100644 --- a/src/WebSocketsClient.h +++ b/src/WebSocketsClient.h @@ -48,10 +48,10 @@ class WebSocketsClient : protected WebSockets { void beginSSL(String host, uint16_t port, String url = "/", String fingerprint = "", String protocol = "arduino"); #else void beginSSL(const char * host, uint16_t port, const char * url = "/", const uint8_t * fingerprint = NULL, const char * protocol = "arduino"); - #if defined(SSL_BARESSL) +#if defined(SSL_BARESSL) void beginSslWithCA(const char * host, uint16_t port, const char * url = "/", BearSSL::X509List * CA_cert = NULL, const char * protocol = "arduino"); void setSSLClientCertKey(BearSSL::X509List * clientCert = NULL, BearSSL::PrivateKey * clientPrivateKey = NULL); - #endif +#endif void setSSLClientCertKey(const char * clientCert = NULL, const char * clientPrivateKey = NULL); #endif void beginSslWithCA(const char * host, uint16_t port, const char * url = "/", const char * CA_cert = NULL, const char * protocol = "arduino"); @@ -131,11 +131,11 @@ class WebSocketsClient : protected WebSockets { #define SSL_FINGERPRINT_NULL "" #else const uint8_t * _fingerprint; - #if defined(SSL_BARESSL) +#if defined(SSL_BARESSL) BearSSL::X509List * _CA_cert; BearSSL::X509List * _client_cert; BearSSL::PrivateKey * _client_key; - #endif +#endif #define SSL_FINGERPRINT_IS_SET (_fingerprint != NULL) #define SSL_FINGERPRINT_NULL NULL #endif diff --git a/src/WebSocketsServer.cpp b/src/WebSocketsServer.cpp index 2eccbc4..3f60c53 100644 --- a/src/WebSocketsServer.cpp +++ b/src/WebSocketsServer.cpp @@ -65,11 +65,11 @@ WebSocketsServerCore::~WebSocketsServerCore() { } WebSocketsServer::~WebSocketsServer() { - #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) - // does not support delete (no destructor) - #else - delete _server; - #endif +#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) || (WEBSOCKETS_NETWORK_TYPE == NETWORK_SAMD_SEED) + // does not support delete (no destructor) +#else + delete _server; +#endif } /** @@ -660,12 +660,12 @@ void WebSocketsServer::handleNewClients(void) { while(_server->hasClient()) { #endif - // store new connection - #if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) - WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->available()); - #else - WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->accept()); - #endif +// store new connection +#if(WEBSOCKETS_NETWORK_TYPE == NETWORK_WIFI_NINA) + WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->available()); +#else + WEBSOCKETS_NETWORK_CLASS * tcpClient = new WEBSOCKETS_NETWORK_CLASS(_server->accept()); +#endif if(!tcpClient) { DEBUG_WEBSOCKETS("[WS-Client] creating Network class failed!");