From 02db68bf7645dfa2f9562201cedef28250698120 Mon Sep 17 00:00:00 2001 From: Ian Craggs Date: Sat, 7 Feb 2026 21:56:17 +0000 Subject: [PATCH] Use macros instead of constants to eliminate compile warnings --- src/MQTTPacket.c | 6 +----- src/MQTTPersistence.c | 11 ++--------- src/MQTTProtocolClient.c | 6 +----- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/src/MQTTPacket.c b/src/MQTTPacket.c index 841d453b..7bc18d59 100644 --- a/src/MQTTPacket.c +++ b/src/MQTTPacket.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2025 IBM Corp. and Ian Craggs + * Copyright (c) 2009, 2026 IBM Corp. and Ian Craggs * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -945,11 +945,7 @@ int MQTTPacket_send_publish(Publish* pack, int dup, int qos, int retained, netwo memcpy(pack->mask, packetbufs.mask, sizeof(pack->mask)); } { -#if defined(_WIN32) #define buflen 30 -#else - const int buflen = 30; -#endif char buf[buflen]; int len = 0; diff --git a/src/MQTTPersistence.c b/src/MQTTPersistence.c index f8486a85..6978c8b5 100644 --- a/src/MQTTPersistence.c +++ b/src/MQTTPersistence.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2023 IBM Corp. + * Copyright (c) 2009, 2026 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -655,14 +655,10 @@ void MQTTPersistence_wrapMsgID(Clients *client) #if !defined(NO_PERSISTENCE) +#define KEYSIZE PERSISTENCE_MAX_KEY_LENGTH + 1 int MQTTPersistence_unpersistQueueEntry(Clients* client, MQTTPersistence_qEntry* qe) { int rc = 0; -#if defined(_WIN32) -#define KEYSIZE PERSISTENCE_MAX_KEY_LENGTH + 1 -#else - const size_t KEYSIZE = PERSISTENCE_MAX_KEY_LENGTH + 1; -#endif char key[KEYSIZE]; int chars = 0; @@ -688,9 +684,6 @@ int MQTTPersistence_persistQueueEntry(Clients* aclient, MQTTPersistence_qEntry* { int rc = 0; int bufindex = 0; -#if !defined(_WIN32) - const size_t KEYSIZE = PERSISTENCE_MAX_KEY_LENGTH + 1; -#endif char key[KEYSIZE]; int chars = 0; int lens[MAX_NO_OF_BUFFERS]; diff --git a/src/MQTTProtocolClient.c b/src/MQTTProtocolClient.c index 90673886..c95b1980 100644 --- a/src/MQTTProtocolClient.c +++ b/src/MQTTProtocolClient.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2024 IBM Corp. and Ian Craggs + * Copyright (c) 2009, 2026 IBM Corp. and Ian Craggs * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -334,11 +334,7 @@ int MQTTProtocol_handlePublishes(void* pack, SOCKET sock) /* Format and print publish data to trace */ { -#if defined(_WIN32) #define buflen 30 -#else - const int buflen = 30; -#endif char buf[buflen]; int len = 0;