Skip to content

Commit

Permalink
Change writeInt4 and readInt4 signatures to unsigned #1336
Browse files Browse the repository at this point in the history
  • Loading branch information
icraggs committed Apr 27, 2023
1 parent ed07139 commit 3933f8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/MQTTPacket.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/MQTTPacket.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3933f8b

Please sign in to comment.