Commit dc4318f7 authored by Al S-M's avatar Al S-M

Remove extra ( and fix indentation

parent 0efbc529
...@@ -83,11 +83,11 @@ extern mutex_type stack_mutex; ...@@ -83,11 +83,11 @@ extern mutex_type stack_mutex;
extern mutex_type heap_mutex; extern mutex_type heap_mutex;
extern mutex_type log_mutex; extern mutex_type log_mutex;
BOOL APIENTRY DllMain(HANDLE hModule, BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved) LPVOID lpReserved)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
Log(TRACE_MAX, -1, "DLL process attach"); Log(TRACE_MAX, -1, "DLL process attach");
if (mqttasync_mutex == NULL) if (mqttasync_mutex == NULL)
...@@ -104,8 +104,8 @@ BOOL APIENTRY DllMain(HANDLE hModule, ...@@ -104,8 +104,8 @@ BOOL APIENTRY DllMain(HANDLE hModule,
Log(TRACE_MAX, -1, "DLL thread detach"); Log(TRACE_MAX, -1, "DLL thread detach");
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
Log(TRACE_MAX, -1, "DLL process detach"); Log(TRACE_MAX, -1, "DLL process detach");
} }
return TRUE; return TRUE;
} }
#else #else
static pthread_mutex_t mqttasync_mutex_store = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mqttasync_mutex_store = PTHREAD_MUTEX_INITIALIZER;
...@@ -1486,11 +1486,11 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n) ...@@ -1486,11 +1486,11 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
m->connect.details.conn.serverURIs[m->connect.details.conn.currentURI]); m->connect.details.conn.serverURIs[m->connect.details.conn.currentURI]);
MQTTAsync_addCommand(conn, sizeof(m->connect)); MQTTAsync_addCommand(conn, sizeof(m->connect));
} }
else else
{ {
MQTTAsync_closeSession(m->c); MQTTAsync_closeSession(m->c);
MQTTAsync_freeConnect(m->connect); MQTTAsync_freeConnect(m->connect);
if (m->connect.onFailure) if (m->connect.onFailure)
{ {
MQTTAsync_failureData data; MQTTAsync_failureData data;
...@@ -1520,24 +1520,24 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n) ...@@ -1520,24 +1520,24 @@ thread_return_type WINAPI MQTTAsync_receiveThread(void* n)
Log(LOG_ERROR, -1, "Subscribe command not removed from command list"); Log(LOG_ERROR, -1, "Subscribe command not removed from command list");
if (command->command.onSuccess) if (command->command.onSuccess)
{ {
MQTTAsync_successData data; MQTTAsync_successData data;
Suback* sub = (Suback*)pack; Suback* sub = (Suback*)pack;
int* array = NULL; int* array = NULL;
if (sub->qoss->count == 1) if (sub->qoss->count == 1)
data.alt.qos = *(int*)(sub->qoss->first->content); data.alt.qos = *(int*)(sub->qoss->first->content);
else if (sub->qoss->count > 1) else if (sub->qoss->count > 1)
{ {
ListElement* cur_qos = NULL; ListElement* cur_qos = NULL;
int* element = array = data.alt.qosList = malloc(sub->qoss->count * sizeof(int)); int* element = array = data.alt.qosList = malloc(sub->qoss->count * sizeof(int));
while (ListNextElement(sub->qoss, &cur_qos)) while (ListNextElement(sub->qoss, &cur_qos))
*element++ = *(int*)(cur_qos->content); *element++ = *(int*)(cur_qos->content);
} }
data.token = command->command.token; data.token = command->command.token;
rc = MQTTProtocol_handleSubacks(pack, m->c->net.socket); rc = MQTTProtocol_handleSubacks(pack, m->c->net.socket);
handleCalled = 1; handleCalled = 1;
Log(TRACE_MIN, -1, "Calling subscribe success for client %s", m->c->clientID); Log(TRACE_MIN, -1, "Calling subscribe success for client %s", m->c->clientID);
Thread_unlock_mutex(mqttasync_mutex); Thread_unlock_mutex(mqttasync_mutex);
(*(command->command.onSuccess))(command->command.context, &data); (*(command->command.onSuccess))(command->command.context, &data);
Thread_lock_mutex(mqttasync_mutex); Thread_lock_mutex(mqttasync_mutex);
...@@ -2045,15 +2045,15 @@ int MQTTAsync_connect(MQTTAsync handle, MQTTAsync_connectOptions* options) ...@@ -2045,15 +2045,15 @@ int MQTTAsync_connect(MQTTAsync handle, MQTTAsync_connectOptions* options)
m->c->cleansession = options->cleansession; m->c->cleansession = options->cleansession;
m->c->maxInflightMessages = options->maxInflight; m->c->maxInflightMessages = options->maxInflight;
if (m->c->will) if (m->c->will)
{ {
free(m->c->will); free(m->c->will);
m->c->will = NULL; m->c->will = NULL;
} }
if (options->will && options->will->struct_version == 0) if (options->will && options->will->struct_version == 0)
{ {
m->c->will = malloc(sizeof(willMessages)); m->c->will = malloc(sizeof(willMessages));
m->c->will->msg = malloc(strlen(options->will->message) + 1); m->c->will->msg = malloc(strlen(options->will->message) + 1);
strcpy(m->c->will->msg, options->will->message); strcpy(m->c->will->msg, options->will->message);
m->c->will->qos = options->will->qos; m->c->will->qos = options->will->qos;
...@@ -2449,14 +2449,14 @@ int MQTTAsync_connecting(MQTTAsyncs* m) ...@@ -2449,14 +2449,14 @@ int MQTTAsync_connecting(MQTTAsyncs* m)
goto exit; goto exit;
} }
else if (rc == 1) { else if (rc == 1) {
rc = MQTTCLIENT_SUCCESS; rc = MQTTCLIENT_SUCCESS;
m->c->connect_state = 3; m->c->connect_state = 3;
if (MQTTPacket_send_connect(m->c) == SOCKET_ERROR) if (MQTTPacket_send_connect(m->c) == SOCKET_ERROR)
{ {
rc = SOCKET_ERROR; rc = SOCKET_ERROR;
goto exit; goto exit;
} }
if(!m->c->cleansession && m->c->session == NULL)) if(!m->c->cleansession && m->c->session == NULL)
m->c->session = SSL_get1_session(m->c->net.ssl); m->c->session = SSL_get1_session(m->c->net.ssl);
} }
} }
...@@ -2482,7 +2482,7 @@ int MQTTAsync_connecting(MQTTAsyncs* m) ...@@ -2482,7 +2482,7 @@ int MQTTAsync_connecting(MQTTAsyncs* m)
if ((rc = SSLSocket_connect(m->c->net.ssl, m->c->net.socket)) != 1) if ((rc = SSLSocket_connect(m->c->net.ssl, m->c->net.socket)) != 1)
goto exit; goto exit;
if(!m->c->cleansession && m->c->session == NULL)) if(!m->c->cleansession && m->c->session == NULL)
m->c->session = SSL_get1_session(m->c->net.ssl); m->c->session = SSL_get1_session(m->c->net.ssl);
m->c->connect_state = 3; /* SSL connect completed, in which case send the MQTT connect packet */ m->c->connect_state = 3; /* SSL connect completed, in which case send the MQTT connect packet */
if ((rc = MQTTPacket_send_connect(m->c)) == SOCKET_ERROR) if ((rc = MQTTPacket_send_connect(m->c)) == SOCKET_ERROR)
......
...@@ -70,11 +70,11 @@ extern mutex_type stack_mutex; ...@@ -70,11 +70,11 @@ extern mutex_type stack_mutex;
extern mutex_type heap_mutex; extern mutex_type heap_mutex;
extern mutex_type log_mutex; extern mutex_type log_mutex;
BOOL APIENTRY DllMain(HANDLE hModule, BOOL APIENTRY DllMain(HANDLE hModule,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved) LPVOID lpReserved)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
Log(TRACE_MAX, -1, "DLL process attach"); Log(TRACE_MAX, -1, "DLL process attach");
if (mqttclient_mutex == NULL) if (mqttclient_mutex == NULL)
...@@ -90,8 +90,8 @@ BOOL APIENTRY DllMain(HANDLE hModule, ...@@ -90,8 +90,8 @@ BOOL APIENTRY DllMain(HANDLE hModule,
Log(TRACE_MAX, -1, "DLL thread detach"); Log(TRACE_MAX, -1, "DLL thread detach");
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
Log(TRACE_MAX, -1, "DLL process detach"); Log(TRACE_MAX, -1, "DLL process detach");
} }
return TRUE; return TRUE;
} }
#else #else
static pthread_mutex_t mqttclient_mutex_store = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t mqttclient_mutex_store = PTHREAD_MUTEX_INITIALIZER;
...@@ -737,7 +737,7 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options, ...@@ -737,7 +737,7 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options,
if (options->will && options->will->struct_version == 0) if (options->will && options->will->struct_version == 0)
{ {
m->c->will = malloc(sizeof(willMessages)); m->c->will = malloc(sizeof(willMessages));
m->c->will->msg = options->will->message; m->c->will->msg = options->will->message;
m->c->will->qos = options->will->qos; m->c->will->qos = options->will->qos;
m->c->will->retained = options->will->retained; m->c->will->retained = options->will->retained;
...@@ -796,14 +796,14 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options, ...@@ -796,14 +796,14 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options,
goto exit; goto exit;
} }
else if (rc == 1) { else if (rc == 1) {
rc = MQTTCLIENT_SUCCESS; rc = MQTTCLIENT_SUCCESS;
m->c->connect_state = 3; m->c->connect_state = 3;
if (MQTTPacket_send_connect(m->c) == SOCKET_ERROR) if (MQTTPacket_send_connect(m->c) == SOCKET_ERROR)
{ {
rc = SOCKET_ERROR; rc = SOCKET_ERROR;
goto exit; goto exit;
} }
if(!m->c->cleansession && m->c->session == NULL)) if(!m->c->cleansession && m->c->session == NULL)
m->c->session = SSL_get1_session(m->c->net.ssl); m->c->session = SSL_get1_session(m->c->net.ssl);
} }
} }
...@@ -838,7 +838,7 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options, ...@@ -838,7 +838,7 @@ int MQTTClient_connectURI(MQTTClient handle, MQTTClient_connectOptions* options,
rc = SOCKET_ERROR; rc = SOCKET_ERROR;
goto exit; goto exit;
} }
if(!m->c->cleansession && m->c->session == NULL)) if(!m->c->cleansession && m->c->session == NULL)
m->c->session = SSL_get1_session(m->c->net.ssl); m->c->session = SSL_get1_session(m->c->net.ssl);
m->c->connect_state = 3; /* TCP connect completed, in which case send the MQTT connect packet */ m->c->connect_state = 3; /* TCP connect completed, in which case send the MQTT connect packet */
if (MQTTPacket_send_connect(m->c) == SOCKET_ERROR) if (MQTTPacket_send_connect(m->c) == SOCKET_ERROR)
...@@ -973,11 +973,11 @@ int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions* options) ...@@ -973,11 +973,11 @@ int MQTTClient_connect(MQTTClient handle, MQTTClient_connectOptions* options)
} }
exit: exit:
if (m->c->will) if (m->c->will)
{ {
free(m->c->will); free(m->c->will);
m->c->will = NULL; m->c->will = NULL;
} }
Thread_unlock_mutex(mqttclient_mutex); Thread_unlock_mutex(mqttclient_mutex);
FUNC_EXIT_RC(rc); FUNC_EXIT_RC(rc);
return rc; return rc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment