Using standard constants for exit(3) and return

According to ISO/IEC 9899:2011, section 7.22.4.4 (The exit function),
"the constant EXIT_FAILURE is the implementation independent way to
issue failures to exit(3)." Whereas EXIT_SUCCESS is the portable way
to return success.
Signed-off-by: 's avatarGuilherme Maciel Ferreira <guilherme.maciel.ferreira@gmail.com>
parent 009fd7bf
......@@ -1265,7 +1265,7 @@ void onSend(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_disconnect(client, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
}
......@@ -1298,7 +1298,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_sendMessage(client, TOPIC, &pubmsg, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
}
......@@ -1323,7 +1323,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
printf("Waiting for publication of %s\n"
......@@ -1449,7 +1449,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
if ((rc = MQTTAsync_subscribe(client, TOPIC, QOS, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start subscribe, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
}
......@@ -1476,7 +1476,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTAsync_connect(client, &conn_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start connect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
while (!subscribed)
......@@ -1498,7 +1498,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTAsync_disconnect(client, &disc_opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start disconnect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
while (!disc_finished)
#if defined(WIN32) || defined(WIN64)
......
......@@ -1063,7 +1063,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
......@@ -1148,7 +1148,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
......@@ -1231,7 +1231,7 @@ int main(int argc, char* argv[])
if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
{
printf("Failed to connect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
printf("Subscribing to topic %s\nfor client %s using QoS%d\n\n"
"Press Q<Enter> to quit\n\n", TOPIC, CLIENTID, QOS);
......
......@@ -369,7 +369,7 @@ void handleTrace(enum MQTTASYNC_TRACE_LEVELS level, char* message)
!= MQTTASYNC_SUCCESS)
{
printf("Failed to start sendMessage, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
}
......@@ -382,7 +382,7 @@ void handleTrace(enum MQTTASYNC_TRACE_LEVELS level, char* message)
opts.context = client;
if ((rc = MQTTAsync_subscribe(client, options.topic, options.qos, &opts)) != MQTTASYNC_SUCCESS) {
printf("Failed to subscribe, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
}
......@@ -403,7 +403,7 @@ void handleTrace(enum MQTTASYNC_TRACE_LEVELS level, char* message)
if ((rc = MQTTAsync_disconnect(client, &opts)) != MQTTASYNC_SUCCESS)
{
printf("Failed to start disconnect, return code %d\n", rc);
exit(-1);
exit(EXIT_FAILURE);
}
toStop = 0;
}
......
......@@ -72,7 +72,7 @@ struct Options
void usage(void)
{
printf("options:\n connection, clientid1, clientid2, username, password, MQTTversion, iterations, verbose\n");
exit(-1);
exit(EXIT_FAILURE);
}
void getopts(int argc, char** argv)
......
......@@ -55,7 +55,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -49,7 +49,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -76,7 +76,7 @@ void usage(void)
printf("\t--verbose - Enable verbose output \n");
printf("\tserver connection URLs should be in the form; (tcp|ssl)://hostname:port\n");
printf("\t--help - This help output\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -49,7 +49,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -61,7 +61,7 @@ void usage(void)
printf("\t--server_key <key_file> - Use <key_file> as the trusted certificate for server\n");
printf("\t--verbose - Enable verbose output \n");
printf("\t--help - This help output\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -41,7 +41,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
static char pub_topic[200];
......
......@@ -49,7 +49,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -51,7 +51,7 @@ char unique[50]; // unique suffix/prefix to add to clientid/topic etc
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -55,7 +55,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
......@@ -55,7 +55,7 @@
void usage(void)
{
printf("help!!\n");
exit(-1);
exit(EXIT_FAILURE);
}
struct Options
......
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