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

style: adjust some code alignment #240

Open
wants to merge 1 commit into
base: master
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
10 changes: 5 additions & 5 deletions MQTTClient-C/samples/linux/stdoutsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ int main(int argc, char** argv)
NetworkInit(&n);
NetworkConnect(&n, opts.host, opts.port);
MQTTClientInit(&c, &n, 1000, buf, 100, readbuf, 100);

MQTTPacket_connectData data = MQTTPacket_connectData_initializer;
data.willFlag = 0;
data.MQTTVersion = 3;
Expand All @@ -230,19 +230,19 @@ int main(int argc, char** argv)
data.keepAliveInterval = 10;
data.cleansession = 1;
printf("Connecting to %s %d\n", opts.host, opts.port);

rc = MQTTConnect(&c, &data);
printf("Connected %d\n", rc);
printf("Subscribing to %s\n", topic);

printf("Subscribing to %s\n", topic);
rc = MQTTSubscribe(&c, topic, opts.qos, messageArrived);
printf("Subscribed %d\n", rc);

while (!toStop)
{
MQTTYield(&c, 1000);
}

printf("Stopping\n");

MQTTDisconnect(&c);
Expand Down
2 changes: 1 addition & 1 deletion MQTTClient-C/src/FreeRTOS/MQTTFreeRTOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ int NetworkConnect(Network* n, char* addr, int port)
if ((retVal = FreeRTOS_connect(n->my_socket, &sAddr, sizeof(sAddr))) < 0)
{
FreeRTOS_closesocket(n->my_socket);
goto exit;
goto exit;
}

exit:
Expand Down
46 changes: 23 additions & 23 deletions MQTTClient-C/src/MQTTClient.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ void MQTTClientInit(MQTTClient* c, Network* network, unsigned int command_timeou
c->cleansession = 0;
c->ping_outstanding = 0;
c->defaultMessageHandler = NULL;
c->next_packetid = 1;
c->next_packetid = 1;
TimerInit(&c->last_sent);
TimerInit(&c->last_received);
#if defined(MQTT_TASK)
MutexInit(&c->mutex);
MutexInit(&c->mutex);
#endif
}

Expand Down Expand Up @@ -346,21 +346,21 @@ int MQTTYield(MQTTClient* c, int timeout_ms)
TimerInit(&timer);
TimerCountdownMS(&timer, timeout_ms);

do
do
{
if (cycle(c, &timer) < 0)
{
rc = FAILURE;
break;
}
} while (!TimerIsExpired(&timer));
} while (!TimerIsExpired(&timer));

return rc;
}

int MQTTIsConnected(MQTTClient* client)
{
return client->isconnected;
return client->isconnected;
}

void MQTTRun(void* parm)
Expand Down Expand Up @@ -418,10 +418,10 @@ int MQTTConnectWithResults(MQTTClient* c, MQTTPacket_connectData* options, MQTTC
int len = 0;

#if defined(MQTT_TASK)
MutexLock(&c->mutex);
MutexLock(&c->mutex);
#endif
if (c->isconnected) /* don't send connect packet again if we are already connected */
goto exit;
if (c->isconnected) /* don't send connect packet again if we are already connected */
goto exit;

TimerInit(&connect_timer);
TimerCountdownMS(&connect_timer, c->command_timeout_ms);
Expand Down Expand Up @@ -458,7 +458,7 @@ int MQTTConnectWithResults(MQTTClient* c, MQTTPacket_connectData* options, MQTTC
}

#if defined(MQTT_TASK)
MutexUnlock(&c->mutex);
MutexUnlock(&c->mutex);
#endif

return rc;
Expand Down Expand Up @@ -524,10 +524,10 @@ int MQTTSubscribeWithResults(MQTTClient* c, const char* topicFilter, enum QoS qo
topic.cstring = (char *)topicFilter;

#if defined(MQTT_TASK)
MutexLock(&c->mutex);
MutexLock(&c->mutex);
#endif
if (!c->isconnected)
goto exit;
if (!c->isconnected)
goto exit;

TimerInit(&timer);
TimerCountdownMS(&timer, c->command_timeout_ms);
Expand Down Expand Up @@ -556,7 +556,7 @@ int MQTTSubscribeWithResults(MQTTClient* c, const char* topicFilter, enum QoS qo
if (rc == FAILURE)
MQTTCloseSession(c);
#if defined(MQTT_TASK)
MutexUnlock(&c->mutex);
MutexUnlock(&c->mutex);
#endif
return rc;
}
Expand All @@ -579,10 +579,10 @@ int MQTTUnsubscribe(MQTTClient* c, const char* topicFilter)
int len = 0;

#if defined(MQTT_TASK)
MutexLock(&c->mutex);
MutexLock(&c->mutex);
#endif
if (!c->isconnected)
goto exit;
if (!c->isconnected)
goto exit;

TimerInit(&timer);
TimerCountdownMS(&timer, c->command_timeout_ms);
Expand All @@ -608,7 +608,7 @@ int MQTTUnsubscribe(MQTTClient* c, const char* topicFilter)
if (rc == FAILURE)
MQTTCloseSession(c);
#if defined(MQTT_TASK)
MutexUnlock(&c->mutex);
MutexUnlock(&c->mutex);
#endif
return rc;
}
Expand All @@ -623,10 +623,10 @@ int MQTTPublish(MQTTClient* c, const char* topicName, MQTTMessage* message)
int len = 0;

#if defined(MQTT_TASK)
MutexLock(&c->mutex);
MutexLock(&c->mutex);
#endif
if (!c->isconnected)
goto exit;
if (!c->isconnected)
goto exit;

TimerInit(&timer);
TimerCountdownMS(&timer, c->command_timeout_ms);
Expand Down Expand Up @@ -670,7 +670,7 @@ int MQTTPublish(MQTTClient* c, const char* topicName, MQTTMessage* message)
if (rc == FAILURE)
MQTTCloseSession(c);
#if defined(MQTT_TASK)
MutexUnlock(&c->mutex);
MutexUnlock(&c->mutex);
#endif
return rc;
}
Expand All @@ -688,13 +688,13 @@ int MQTTDisconnect(MQTTClient* c)
TimerInit(&timer);
TimerCountdownMS(&timer, c->command_timeout_ms);

len = MQTTSerialize_disconnect(c->buf, c->buf_size);
len = MQTTSerialize_disconnect(c->buf, c->buf_size);
if (len > 0)
rc = sendPacket(c, len, &timer); // send the disconnect packet
MQTTCloseSession(c);

#if defined(MQTT_TASK)
MutexUnlock(&c->mutex);
MutexUnlock(&c->mutex);
#endif
return rc;
}
2 changes: 1 addition & 1 deletion MQTTClient-C/src/cc3200/MQTTCC3200.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int ConnectNetwork(Network* n, char* addr, int port)
if( retVal < 0 ) {
// error
sl_Close(n->my_socket);
return retVal;
return retVal;
}

SysTickIntRegister(SysTickIntHandler);
Expand Down
2 changes: 1 addition & 1 deletion MQTTClient-C/src/linux/MQTTLinux.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int linux_read(Network* n, unsigned char* buffer, int len, int timeout_ms)
if (rc == -1)
{
if (errno != EAGAIN && errno != EWOULDBLOCK)
bytes = -1;
bytes = -1;
break;
}
else if (rc == 0)
Expand Down
Loading