From 3933f8b796523576c8e42abf80ca6ce650f9b7dc Mon Sep 17 00:00:00 2001 From: Ian Craggs Date: Thu, 27 Apr 2023 18:33:02 +0100 Subject: [PATCH] Change writeInt4 and readInt4 signatures to unsigned #1336 --- src/MQTTPacket.c | 8 ++++---- src/MQTTPacket.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/MQTTPacket.c b/src/MQTTPacket.c index 2ac8024ff..d01110fc3 100644 --- a/src/MQTTPacket.c +++ b/src/MQTTPacket.c @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2022 IBM Corp. and Ian Craggs + * Copyright (c) 2009, 2023 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 @@ -942,7 +942,7 @@ void MQTTPacket_free_packet(MQTTPacket* pack) * @param pptr pointer to the output buffer - incremented by the number of bytes used & returned * @param anInt the integer to write */ -void writeInt4(char** pptr, int anInt) +void writeInt4(char** pptr, unsigned int anInt) { unsigned char* ptr = (unsigned char*)*pptr; ptr[0] = (uint8_t) ((anInt >> 24) & 0xFF); @@ -958,10 +958,10 @@ void writeInt4(char** pptr, int anInt) * used & returned * @return the integer value calculated */ -int readInt4(char** pptr) +unsigned int readInt4(char** pptr) { unsigned char *ptr = (unsigned char *)*pptr; - int val = ((((uint32_t)ptr[0]) << 24) | (((uint32_t)ptr[1]) << 16) | (((uint32_t)ptr[2]) << 8) | ((uint32_t)ptr[3])); + unsigned int val = ((((uint32_t)ptr[0]) << 24) | (((uint32_t)ptr[1]) << 16) | (((uint32_t)ptr[2]) << 8) | ((uint32_t)ptr[3])); *pptr += 4; return val; } diff --git a/src/MQTTPacket.h b/src/MQTTPacket.h index 658404a7c..1fc8e06e4 100644 --- a/src/MQTTPacket.h +++ b/src/MQTTPacket.h @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2020 IBM Corp. + * Copyright (c) 2009, 2023 IBM Corp. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v2.0 @@ -259,8 +259,8 @@ int MQTTPacket_send_pubcomp(int MQTTVersion, int msgid, networkHandles* net, con void MQTTPacket_free_packet(MQTTPacket* pack); -void writeInt4(char** pptr, int anInt); -int readInt4(char** pptr); +void writeInt4(char** pptr, unsigned int anInt); +unsigned int readInt4(char** pptr); void writeMQTTLenString(char** pptr, MQTTLenString lenstring); int MQTTLenStringRead(MQTTLenString* lenstring, char** pptr, char* enddata); int MQTTPacket_VBIlen(int rem_len);