Change writeInt4 and readInt4 signatures to unsigned #1336

This commit is contained in:
Ian Craggs 2023-04-27 18:33:02 +01:00
parent ed07139291
commit 3933f8b796
2 changed files with 7 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);