Skip to content

Commit

Permalink
Fix some MacOS build warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
icraggs committed Aug 1, 2023
1 parent 5e5cae6 commit 895a3fa
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MQTTClient-C/test/test1.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ int test6a(struct Options options)
int main(int argc, char** argv)
{
int rc = 0;
int (*tests[])() = {NULL, test1, test2, test3};
int (*tests[])(struct Options) = {NULL, test1, test2, test3};
int i;

xml = fopen("TEST-test1.xml", "w");
Expand Down
20 changes: 17 additions & 3 deletions MQTTClient/samples/linux/hello.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*******************************************************************************
* Copyright (c) 2014, 2023 IBM Corp., Ian Craggs and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*******************************************************************************/

#define MQTTCLIENT_QOS2 1

#include <memory.h>
Expand Down Expand Up @@ -54,7 +68,7 @@ int main(int argc, char* argv[])

// QoS 0
char buf[100];
sprintf(buf, "Hello World! QoS 0 message from app version %f", version);
snprintf(buf, sizeof(buf), "Hello World! QoS 0 message from app version %f", version);
message.qos = MQTT::QOS0;
message.retained = false;
message.dup = false;
Expand All @@ -68,7 +82,7 @@ int main(int argc, char* argv[])

// QoS 1
printf("Now QoS 1\n");
sprintf(buf, "Hello World! QoS 1 message from app version %f", version);
snprintf(buf, sizeof(buf), "Hello World! QoS 1 message from app version %f", version);
message.qos = MQTT::QOS1;
message.payloadlen = strlen(buf)+1;
rc = client.publish(topic, message);
Expand All @@ -78,7 +92,7 @@ int main(int argc, char* argv[])
client.yield(100);

// QoS 2
sprintf(buf, "Hello World! QoS 2 message from app version %f", version);
snprintf(buf, sizeof(buf), "Hello World! QoS 2 message from app version %f", version);
message.qos = MQTT::QOS2;
message.payloadlen = strlen(buf)+1;
rc = client.publish(topic, message);
Expand Down
20 changes: 17 additions & 3 deletions MQTTClient/samples/linux/hello_class.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
/*******************************************************************************
* Copyright (c) 2014, 2023 IBM Corp., Ian Craggs and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Eclipse Distribution License v1.0 which accompany this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
*******************************************************************************/

#define MQTTCLIENT_QOS2 1

#include <memory.h>
Expand Down Expand Up @@ -61,7 +75,7 @@ int main(int argc, char* argv[])

// QoS 0
char buf[100];
sprintf(buf, "Hello World! QoS 0 message from app version %f", version);
snprintf(buf, sizeof(buf), "Hello World! QoS 0 message from app version %f", version);
message.qos = MQTT::QOS0;
message.retained = false;
message.dup = false;
Expand All @@ -75,7 +89,7 @@ int main(int argc, char* argv[])

// QoS 1
printf("Now QoS 1\n");
sprintf(buf, "Hello World! QoS 1 message from app version %f", version);
snprintf(buf, sizeof(buf), "Hello World! QoS 1 message from app version %f", version);
message.qos = MQTT::QOS1;
message.payloadlen = strlen(buf)+1;
rc = client.publish(topic, message);
Expand All @@ -85,7 +99,7 @@ int main(int argc, char* argv[])
client.yield(100);

// QoS 2
sprintf(buf, "Hello World! QoS 2 message from app version %f", version);
snprintf(buf, sizeof(buf), "Hello World! QoS 2 message from app version %f", version);
message.qos = MQTT::QOS2;
message.payloadlen = strlen(buf)+1;
rc = client.publish(topic, message);
Expand Down
2 changes: 1 addition & 1 deletion MQTTPacket/test/test1.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ int test8(struct Options options)
int main(int argc, char** argv)
{
int rc = 0;
int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7, test8};
int (*tests[])(struct Options) = {NULL, test1, test2, test3, test4, test5, test6, test7, test8};

xml = fopen("TEST-test1.xml", "w");
fprintf(xml, "<testsuite name=\"test1\" tests=\"%d\">\n", (int)(ARRAY_SIZE(tests) - 1));
Expand Down
2 changes: 1 addition & 1 deletion MQTTPacket/test/test2.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ int test9(struct Options options)
int main(int argc, char** argv)
{
int rc = 0;
int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7, test8, test9};
int (*tests[])(struct Options) = {NULL, test1, test2, test3, test4, test5, test6, test7, test8, test9};

xml = fopen("TEST-test1.xml", "w");
fprintf(xml, "<testsuite name=\"test1\" tests=\"%d\">\n", (int)(ARRAY_SIZE(tests) - 1));
Expand Down
2 changes: 1 addition & 1 deletion MQTTPacket/test/test3.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ int test1(struct Options options)
int main(int argc, char** argv)
{
int rc = 0;
int (*tests[])() = {NULL, test1};
int (*tests[])(struct Options) = {NULL, test1};

xml = fopen("TEST-test3.xml", "w");
fprintf(xml, "<testsuite name=\"test1\" tests=\"%d\">\n", (int)(ARRAY_SIZE(tests) - 1));
Expand Down

0 comments on commit 895a3fa

Please sign in to comment.