From 715a73a989bd2529c0617e300389890f47488018 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 6 Sep 2021 11:22:26 +0900 Subject: [PATCH] Replace #ifdef an #ifndef with #if defined() and #if !defined() Just for consistency. No functional changes are intended. I didn't touch ones in the docs because I'm not sure if it's appropriate to manually edit these files. --- examples/templates/bearssl_sockets.h | 4 ++-- examples/templates/bio_sockets.h | 4 ++-- examples/templates/mbedtls_sockets.h | 2 +- examples/templates/openssl_sockets.h | 4 ++-- examples/templates/posix_sockets.h | 2 +- include/mqtt.h | 8 ++++---- include/mqtt_pal.h | 14 +++++++------- src/mqtt_pal.c | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/templates/bearssl_sockets.h b/examples/templates/bearssl_sockets.h index 2181fcd..e0c138c 100644 --- a/examples/templates/bearssl_sockets.h +++ b/examples/templates/bearssl_sockets.h @@ -1,4 +1,4 @@ -#ifndef __BEARSSL_SOCKET_TEMPLATE_H__ +#if !defined(__BEARSSL_SOCKET_TEMPLATE_H__) #define __BEARSSL_SOCKET_TEMPLATE_H__ #include @@ -136,4 +136,4 @@ int close_socket(bearssl_context *ctx) { return rc; } -#endif \ No newline at end of file +#endif diff --git a/examples/templates/bio_sockets.h b/examples/templates/bio_sockets.h index 78acd60..b5a146a 100644 --- a/examples/templates/bio_sockets.h +++ b/examples/templates/bio_sockets.h @@ -1,4 +1,4 @@ -#ifndef __BIO_SOCKET_TEMPLATE_H__ +#if !defined(__BIO_SOCKET_TEMPLATE_H__) #define __BIO_SOCKET_TEMPLATE_H__ #include @@ -25,4 +25,4 @@ BIO* open_nb_socket(const char* addr, const char* port) { return bio; } -#endif \ No newline at end of file +#endif diff --git a/examples/templates/mbedtls_sockets.h b/examples/templates/mbedtls_sockets.h index f14ffef..56b4c18 100644 --- a/examples/templates/mbedtls_sockets.h +++ b/examples/templates/mbedtls_sockets.h @@ -1,4 +1,4 @@ -#ifndef __MBEDTLS_SOCKET_TEMPLATE_H__ +#if !defined(__MBEDTLS_SOCKET_TEMPLATE_H__) #define __MBEDTLS_SOCKET_TEMPLATE_H__ #include diff --git a/examples/templates/openssl_sockets.h b/examples/templates/openssl_sockets.h index c826036..89056cc 100644 --- a/examples/templates/openssl_sockets.h +++ b/examples/templates/openssl_sockets.h @@ -1,4 +1,4 @@ -#ifndef __OPENSSL_SOCKET_TEMPLATE_H__ +#if !defined(__OPENSSL_SOCKET_TEMPLATE_H__) #define __OPENSSL_SOCKET_TEMPLATE_H__ #include @@ -49,4 +49,4 @@ void open_nb_socket(BIO** bio, SSL_CTX** ssl_ctx, const char* addr, const char* } } -#endif \ No newline at end of file +#endif diff --git a/examples/templates/posix_sockets.h b/examples/templates/posix_sockets.h index f469d65..6b254a2 100644 --- a/examples/templates/posix_sockets.h +++ b/examples/templates/posix_sockets.h @@ -1,4 +1,4 @@ -#ifndef __POSIX_SOCKET_TEMPLATE_H__ +#if !defined(__POSIX_SOCKET_TEMPLATE_H__) #define __POSIX_SOCKET_TEMPLATE_H__ #include diff --git a/include/mqtt.h b/include/mqtt.h index 13911ee..93cc73c 100644 --- a/include/mqtt.h +++ b/include/mqtt.h @@ -1,4 +1,4 @@ -#ifndef __MQTT_H__ +#if !defined(__MQTT_H__) #define __MQTT_H__ /* @@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif @@ -35,7 +35,7 @@ extern "C" { // If MQTTC_PAL_FILE is used, none of the default utils will be emitted and must be // provided by the config file. To start, I would suggest copying mqtt_pal.h // and modifying as needed. -#ifdef MQTTC_PAL_FILE +#if defined(MQTTC_PAL_FILE) #define MQTTC_STR2(x) #x #define MQTTC_STR(x) MQTTC_STR2(x) #include MQTTC_STR(MQTTC_PAL_FILE) @@ -1615,7 +1615,7 @@ enum MQTTErrors mqtt_disconnect(struct mqtt_client *client); */ enum MQTTErrors mqtt_reconnect(struct mqtt_client *client); -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/include/mqtt_pal.h b/include/mqtt_pal.h index 85c32cd..8ee8b3d 100644 --- a/include/mqtt_pal.h +++ b/include/mqtt_pal.h @@ -1,4 +1,4 @@ -#ifndef __MQTT_PAL_H__ +#if !defined(__MQTT_PAL_H__) #define __MQTT_PAL_H__ /* @@ -25,7 +25,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifdef __cplusplus +#if defined(__cplusplus) extern "C" { #endif @@ -89,8 +89,8 @@ extern "C" { #define MQTT_PAL_MUTEX_LOCK(mtx_ptr) pthread_mutex_lock(mtx_ptr) #define MQTT_PAL_MUTEX_UNLOCK(mtx_ptr) pthread_mutex_unlock(mtx_ptr) - #ifndef MQTT_USE_CUSTOM_SOCKET_HANDLE - #ifdef MQTT_USE_MBEDTLS + #if !defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) + #if defined(MQTT_USE_MBEDTLS) struct mbedtls_ssl_context; typedef struct mbedtls_ssl_context *mqtt_pal_socket_handle; #elif defined(MQTT_USE_WOLFSSL) @@ -139,8 +139,8 @@ extern "C" { #define MQTT_PAL_MUTEX_UNLOCK(mtx_ptr) LeaveCriticalSection(mtx_ptr) - #ifndef MQTT_USE_CUSTOM_SOCKET_HANDLE - #ifdef MQTT_USE_BIO + #if !defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) + #if defined(MQTT_USE_BIO) #include typedef BIO* mqtt_pal_socket_handle; #else @@ -176,7 +176,7 @@ ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, */ ssize_t mqtt_pal_recvall(mqtt_pal_socket_handle fd, void* buf, size_t bufsz, int flags); -#ifdef __cplusplus +#if defined(__cplusplus) } #endif diff --git a/src/mqtt_pal.c b/src/mqtt_pal.c index d83b3f6..ae0231e 100644 --- a/src/mqtt_pal.c +++ b/src/mqtt_pal.c @@ -32,7 +32,7 @@ SOFTWARE. */ -#ifdef MQTT_USE_MBEDTLS +#if defined(MQTT_USE_MBEDTLS) #include ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) {