diff --git a/MQTTClient-C/test/test1.c b/MQTTClient-C/test/test1.c index 24d8d992..99b33685 100644 --- a/MQTTClient-C/test/test1.c +++ b/MQTTClient-C/test/test1.c @@ -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"); diff --git a/MQTTClient/samples/linux/hello.cpp b/MQTTClient/samples/linux/hello.cpp index 0c139ef0..b59c63c6 100644 --- a/MQTTClient/samples/linux/hello.cpp +++ b/MQTTClient/samples/linux/hello.cpp @@ -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 @@ -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; @@ -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); @@ -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); diff --git a/MQTTClient/samples/linux/hello_class.cpp b/MQTTClient/samples/linux/hello_class.cpp index 443e195c..7253e8bd 100644 --- a/MQTTClient/samples/linux/hello_class.cpp +++ b/MQTTClient/samples/linux/hello_class.cpp @@ -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 @@ -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; @@ -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); @@ -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); diff --git a/MQTTPacket/test/test1.c b/MQTTPacket/test/test1.c index bfeeccab..a04c4a55 100644 --- a/MQTTPacket/test/test1.c +++ b/MQTTPacket/test/test1.c @@ -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, "\n", (int)(ARRAY_SIZE(tests) - 1)); diff --git a/MQTTPacket/test/test2.c b/MQTTPacket/test/test2.c index 7e0558ac..1c890ac3 100644 --- a/MQTTPacket/test/test2.c +++ b/MQTTPacket/test/test2.c @@ -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, "\n", (int)(ARRAY_SIZE(tests) - 1)); diff --git a/MQTTPacket/test/test3.c b/MQTTPacket/test/test3.c index fb7ac635..ba7577e6 100644 --- a/MQTTPacket/test/test3.c +++ b/MQTTPacket/test/test3.c @@ -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, "\n", (int)(ARRAY_SIZE(tests) - 1));