Skip to content

Commit 895a3fa

Browse files
committed
Fix some MacOS build warnings
1 parent 5e5cae6 commit 895a3fa

File tree

6 files changed

+38
-10
lines changed

6 files changed

+38
-10
lines changed

MQTTClient-C/test/test1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ int test6a(struct Options options)
10211021
int main(int argc, char** argv)
10221022
{
10231023
int rc = 0;
1024-
int (*tests[])() = {NULL, test1, test2, test3};
1024+
int (*tests[])(struct Options) = {NULL, test1, test2, test3};
10251025
int i;
10261026

10271027
xml = fopen("TEST-test1.xml", "w");

MQTTClient/samples/linux/hello.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2014, 2023 IBM Corp., Ian Craggs and others
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* and Eclipse Distribution License v1.0 which accompany this distribution.
7+
*
8+
* The Eclipse Public License is available at
9+
* http://www.eclipse.org/legal/epl-v10.html
10+
* and the Eclipse Distribution License is available at
11+
* http://www.eclipse.org/org/documents/edl-v10.php.
12+
*
13+
*******************************************************************************/
14+
115
#define MQTTCLIENT_QOS2 1
216

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

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

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

8094
// QoS 2
81-
sprintf(buf, "Hello World! QoS 2 message from app version %f", version);
95+
snprintf(buf, sizeof(buf), "Hello World! QoS 2 message from app version %f", version);
8296
message.qos = MQTT::QOS2;
8397
message.payloadlen = strlen(buf)+1;
8498
rc = client.publish(topic, message);

MQTTClient/samples/linux/hello_class.cpp

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2014, 2023 IBM Corp., Ian Craggs and others
3+
*
4+
* All rights reserved. This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License v1.0
6+
* and Eclipse Distribution License v1.0 which accompany this distribution.
7+
*
8+
* The Eclipse Public License is available at
9+
* http://www.eclipse.org/legal/epl-v10.html
10+
* and the Eclipse Distribution License is available at
11+
* http://www.eclipse.org/org/documents/edl-v10.php.
12+
*
13+
*******************************************************************************/
14+
115
#define MQTTCLIENT_QOS2 1
216

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

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

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

87101
// QoS 2
88-
sprintf(buf, "Hello World! QoS 2 message from app version %f", version);
102+
snprintf(buf, sizeof(buf), "Hello World! QoS 2 message from app version %f", version);
89103
message.qos = MQTT::QOS2;
90104
message.payloadlen = strlen(buf)+1;
91105
rc = client.publish(topic, message);

MQTTPacket/test/test1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ int test8(struct Options options)
665665
int main(int argc, char** argv)
666666
{
667667
int rc = 0;
668-
int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7, test8};
668+
int (*tests[])(struct Options) = {NULL, test1, test2, test3, test4, test5, test6, test7, test8};
669669

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

MQTTPacket/test/test2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ int test9(struct Options options)
941941
int main(int argc, char** argv)
942942
{
943943
int rc = 0;
944-
int (*tests[])() = {NULL, test1, test2, test3, test4, test5, test6, test7, test8, test9};
944+
int (*tests[])(struct Options) = {NULL, test1, test2, test3, test4, test5, test6, test7, test8, test9};
945945

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

MQTTPacket/test/test3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ int test1(struct Options options)
559559
int main(int argc, char** argv)
560560
{
561561
int rc = 0;
562-
int (*tests[])() = {NULL, test1};
562+
int (*tests[])(struct Options) = {NULL, test1};
563563

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

0 commit comments

Comments
 (0)