Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unnecessary _WIN64 conditional checks #1559

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Base64.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "Base64.h"

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#pragma comment(lib, "crypt32.lib")
#include <windows.h>
#include <wincrypt.h>
Expand All @@ -37,7 +37,7 @@ b64_size_t Base64_encode( char *out, b64_size_t out_len, const b64_data_t *in, b
ret = (b64_size_t)dw_out_len;
return ret;
}
#else /* if defined(_WIN32) || defined(_WIN64) */
#else /* if defined(_WIN32) */

#if defined(OPENSSL)
#include <openssl/bio.h>
Expand Down Expand Up @@ -234,7 +234,7 @@ b64_size_t Base64_encode( char *out, b64_size_t out_len, const b64_data_t *in, b
return ret;
}
#endif /* else if defined(OPENSSL) */
#endif /* if else defined(_WIN32) || defined(_WIN64) */
#endif /* if else defined(_WIN32) */

b64_size_t Base64_decodeLength( const char *in, b64_size_t in_len )
{
Expand Down
2 changes: 1 addition & 1 deletion src/Clients.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <stdint.h>
#include "MQTTTime.h"
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#include <winsock2.h>
#endif
#if defined(OPENSSL)
Expand Down
2 changes: 1 addition & 1 deletion src/Heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ char* Broker_recordFFDC(char* symptoms);
#undef realloc
#undef free

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
mutex_type heap_mutex;
#else
static pthread_mutex_t heap_mutex_store = PTHREAD_MUTEX_INITIALIZER;
Expand Down
10 changes: 5 additions & 5 deletions src/Log.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <time.h>
#include <string.h>

#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
#include <syslog.h>
#include <sys/stat.h>
#define GETTIMEOFDAY 1
Expand All @@ -52,7 +52,7 @@
#include <sys/timeb.h>
#endif

#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
/**
* _unlink mapping for linux
*/
Expand Down Expand Up @@ -123,7 +123,7 @@ struct timeb now_ts;
#endif
static char msg_buf[512];

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
mutex_type log_mutex;
#else
static pthread_mutex_t log_mutex_store = PTHREAD_MUTEX_INITIALIZER;
Expand All @@ -135,7 +135,7 @@ int Log_initialize(Log_nameValue* info)
{
int rc = SOCKET_ERROR;
char* envval = NULL;
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
struct stat buf;
#endif

Expand Down Expand Up @@ -198,7 +198,7 @@ int Log_initialize(Log_nameValue* info)
info++;
}
}
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
if (stat("/proc/version", &buf) != -1)
{
FILE* vfile;
Expand Down
2 changes: 1 addition & 1 deletion src/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#if !defined(LOG_H)
#define LOG_H

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#include <windows.h>
#define thread_id_type DWORD
#else
Expand Down
8 changes: 4 additions & 4 deletions src/MQTTAsync.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

#include <stdlib.h>
#include <string.h>
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
#include <sys/time.h>
#else
#if defined(_MSC_VER) && _MSC_VER < 1900
Expand Down Expand Up @@ -105,7 +105,7 @@ void MQTTAsync_global_init(MQTTAsync_init_options* inits)
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif

#if defined(WIN32) || defined(WIN64)
#if defined(_WIN32)
void MQTTAsync_init_rand(void)
{
START_TIME_TYPE now = MQTTTime_start_clock();
Expand All @@ -125,7 +125,7 @@ void MQTTAsync_init_rand(void)
}
#endif

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
mutex_type mqttasync_mutex = NULL;
mutex_type socket_mutex = NULL;
mutex_type mqttcommand_mutex = NULL;
Expand Down Expand Up @@ -300,7 +300,7 @@ int MQTTAsync_createWithOptions(MQTTAsync* handle, const char* serverURI, const
int rc = 0;
MQTTAsyncs *m = NULL;

#if (defined(_WIN32) || defined(_WIN64)) && defined(PAHO_MQTT_STATIC)
#if (defined(_WIN32)) && defined(PAHO_MQTT_STATIC)
/* intializes mutexes once. Must come before FUNC_ENTRY */
BOOL bStatus = InitOnceExecuteOnce(&g_InitOnce, InitMutexesOnce, NULL, NULL);
#endif
Expand Down
22 changes: 11 additions & 11 deletions src/MQTTAsyncUtils.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include <stdlib.h>
#include <string.h>
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
#include <sys/time.h>
#endif

Expand Down Expand Up @@ -81,7 +81,7 @@ extern List* MQTTAsync_handles;
extern List* MQTTAsync_commands;
extern int MQTTAsync_tostop;

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
#endif
Expand All @@ -108,7 +108,7 @@ extern cond_type send_cond;
void MQTTAsync_sleep(long milliseconds)
{
FUNC_ENTRY;
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
Sleep(milliseconds);
#else
usleep(milliseconds*1000);
Expand Down Expand Up @@ -936,7 +936,7 @@ int MQTTAsync_addCommand(MQTTAsync_queuedCommand* command, int command_size)
}
exit:
MQTTAsync_unlock_mutex(mqttcommand_mutex);
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
if ((rc1 = Thread_signal_cond(send_cond)) != 0)
Log(LOG_ERROR, 0, "Error %d from signal cond", rc1);
#else
Expand Down Expand Up @@ -1847,7 +1847,7 @@ thread_return_type WINAPI MQTTAsync_sendThread(void* n)
command_count = MQTTAsync_commands->count;
MQTTAsync_unlock_mutex(mqttcommand_mutex);
}
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
if ((rc = Thread_wait_cond(send_cond, timeout)) != 0 && rc != ETIMEDOUT)
Log(LOG_ERROR, -1, "Error %d waiting for condition variable", rc);
#else
Expand All @@ -1872,7 +1872,7 @@ thread_return_type WINAPI MQTTAsync_sendThread(void* n)
#endif

FUNC_EXIT;
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
ExitThread(0);
#endif
return 0;
Expand Down Expand Up @@ -2058,7 +2058,7 @@ static int MQTTAsync_completeConnection(MQTTAsyncs* m, Connack* connack)
}
}
m->pack = NULL;
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
Thread_signal_cond(send_cond);
#else
Thread_post_sem(send_sem);
Expand Down Expand Up @@ -2388,7 +2388,7 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
receiveThread_state = STOPPED;
receiveThread_id = 0;
MQTTAsync_unlock_mutex(mqttasync_mutex);
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
if (sendThread_state != STOPPED)
Thread_signal_cond(send_cond);
#else
Expand All @@ -2405,7 +2405,7 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
#endif

FUNC_EXIT;
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
ExitThread(0);
#endif
return 0;
Expand Down Expand Up @@ -3134,7 +3134,7 @@ static MQTTPacket* MQTTAsync_cycle(SOCKET* sock, unsigned long timeout, int* rc)
{
*rc = MQTTProtocol_handlePubcomps(pack, *sock, &pubToRemove);
if (sendThread_state != STOPPED)
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
Thread_signal_cond(send_cond);
#else
Thread_post_sem(send_sem);
Expand All @@ -3146,7 +3146,7 @@ static MQTTPacket* MQTTAsync_cycle(SOCKET* sock, unsigned long timeout, int* rc)
{
*rc = MQTTProtocol_handlePubacks(pack, *sock, &pubToRemove);
if (sendThread_state != STOPPED)
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
Thread_signal_cond(send_cond);
#else
Thread_post_sem(send_sem);
Expand Down
2 changes: 1 addition & 1 deletion src/MQTTAsyncUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void MQTTAsync_writeComplete(SOCKET socket, int rc);
void setRetryLoopInterval(int keepalive);
void MQTTAsync_NULLPublishResponses(MQTTAsyncs* m);

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#else
#define WINAPI
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/MQTTClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

#include <stdlib.h>
#include <string.h>
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
#include <sys/time.h>
#else
#if defined(_MSC_VER) && _MSC_VER < 1900
Expand Down Expand Up @@ -114,7 +114,7 @@ ClientStates* bstate = &ClientState;

MQTTProtocol state;

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
static mutex_type mqttclient_mutex = NULL;
mutex_type socket_mutex = NULL;
static mutex_type subscribe_mutex = NULL;
Expand Down Expand Up @@ -370,7 +370,7 @@ int MQTTClient_createWithOptions(MQTTClient* handle, const char* serverURI, cons
int rc = 0;
MQTTClients *m = NULL;

#if (defined(_WIN32) || defined(_WIN64)) && defined(PAHO_MQTT_STATIC)
#if (defined(_WIN32)) && defined(PAHO_MQTT_STATIC)
/* intializes mutexes once. Must come before FUNC_ENTRY */
BOOL bStatus = InitOnceExecuteOnce(&g_InitOnce, InitOnceFunction, NULL, NULL);
#endif
Expand Down Expand Up @@ -1026,7 +1026,7 @@ static thread_return_type WINAPI MQTTClient_run(void* n)
running = tostop = 0;
Paho_thread_unlock_mutex(mqttclient_mutex);
FUNC_EXIT;
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
ExitThread(0);
#endif
return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/MQTTExportDeclarations.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#if !defined(EXPORTDECLARATIONS_H)
#define EXPORTDECLARATIONS_H

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
# if defined(PAHO_MQTT_EXPORTS)
# define LIBMQTT_API __declspec(dllexport)
# elif defined(PAHO_MQTT_IMPORTS)
Expand Down
2 changes: 1 addition & 1 deletion src/MQTTPacket.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ int MQTTPacket_send_publish(Publish* pack, int dup, int qos, int retained, netwo
memcpy(pack->mask, packetbufs.mask, sizeof(pack->mask));
}
{
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#define buflen 30
#else
const int buflen = 30;
Expand Down
6 changes: 3 additions & 3 deletions src/MQTTPersistence.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#include "MQTTProtocolClient.h"
#include "Heap.h"

#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#define snprintf _snprintf
#endif

Expand Down Expand Up @@ -658,7 +658,7 @@ void MQTTPersistence_wrapMsgID(Clients *client)
int MQTTPersistence_unpersistQueueEntry(Clients* client, MQTTPersistence_qEntry* qe)
{
int rc = 0;
#if defined(_WIN32) || defined(_WIN64)
#if defined(_WIN32)
#define KEYSIZE PERSISTENCE_MAX_KEY_LENGTH + 1
#else
const size_t KEYSIZE = PERSISTENCE_MAX_KEY_LENGTH + 1;
Expand Down Expand Up @@ -688,7 +688,7 @@ int MQTTPersistence_persistQueueEntry(Clients* aclient, MQTTPersistence_qEntry*
{
int rc = 0;
int bufindex = 0;
#if !defined(_WIN32) && !defined(_WIN64)
#if !defined(_WIN32)
const size_t KEYSIZE = PERSISTENCE_MAX_KEY_LENGTH + 1;
#endif
char key[KEYSIZE];
Expand Down
Loading
Loading