Skip to content

Commit

Permalink
Merge pull request LiamBindle#142 from yamt/ifdef
Browse files Browse the repository at this point in the history
Replace #ifdef an #ifndef with #if defined() and #if !defined()
  • Loading branch information
LiamBindle authored Sep 6, 2021
2 parents 31af37b + 715a73a commit be12c34
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions examples/templates/bearssl_sockets.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __BEARSSL_SOCKET_TEMPLATE_H__
#if !defined(__BEARSSL_SOCKET_TEMPLATE_H__)
#define __BEARSSL_SOCKET_TEMPLATE_H__

#include <sys/socket.h>
Expand Down Expand Up @@ -136,4 +136,4 @@ int close_socket(bearssl_context *ctx) {
return rc;
}

#endif
#endif
4 changes: 2 additions & 2 deletions examples/templates/bio_sockets.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __BIO_SOCKET_TEMPLATE_H__
#if !defined(__BIO_SOCKET_TEMPLATE_H__)
#define __BIO_SOCKET_TEMPLATE_H__

#include <openssl/bio.h>
Expand All @@ -25,4 +25,4 @@ BIO* open_nb_socket(const char* addr, const char* port) {
return bio;
}

#endif
#endif
2 changes: 1 addition & 1 deletion examples/templates/mbedtls_sockets.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __MBEDTLS_SOCKET_TEMPLATE_H__
#if !defined(__MBEDTLS_SOCKET_TEMPLATE_H__)
#define __MBEDTLS_SOCKET_TEMPLATE_H__

#include <inttypes.h>
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/openssl_sockets.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __OPENSSL_SOCKET_TEMPLATE_H__
#if !defined(__OPENSSL_SOCKET_TEMPLATE_H__)
#define __OPENSSL_SOCKET_TEMPLATE_H__

#include <openssl/bio.h>
Expand Down Expand Up @@ -49,4 +49,4 @@ void open_nb_socket(BIO** bio, SSL_CTX** ssl_ctx, const char* addr, const char*
}
}

#endif
#endif
2 changes: 1 addition & 1 deletion examples/templates/posix_sockets.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __POSIX_SOCKET_TEMPLATE_H__
#if !defined(__POSIX_SOCKET_TEMPLATE_H__)
#define __POSIX_SOCKET_TEMPLATE_H__

#include <stdio.h>
Expand Down
8 changes: 4 additions & 4 deletions include/mqtt.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __MQTT_H__
#if !defined(__MQTT_H__)
#define __MQTT_H__

/*
Expand All @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down
14 changes: 7 additions & 7 deletions include/mqtt_pal.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#ifndef __MQTT_PAL_H__
#if !defined(__MQTT_PAL_H__)
#define __MQTT_PAL_H__

/*
Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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 <openssl/bio.h>
typedef BIO* mqtt_pal_socket_handle;
#else
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/mqtt_pal.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int _mqtt_pal_dummy;

#else /* defined(MQTT_USE_CUSTOM_SOCKET_HANDLE) */

#ifdef MQTT_USE_MBEDTLS
#if defined(MQTT_USE_MBEDTLS)
#include <mbedtls/ssl.h>

ssize_t mqtt_pal_sendall(mqtt_pal_socket_handle fd, const void* buf, size_t len, int flags) {
Expand Down

0 comments on commit be12c34

Please sign in to comment.