Skip to content

Commit

Permalink
use numeric_limits to avoid problems with underlying type change
Browse files Browse the repository at this point in the history
  • Loading branch information
jtung-apple committed Aug 25, 2022
1 parent c2b0bf3 commit 1c13217
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/system/SystemPacketBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <stdlib.h>
#include <string.h>
#include <utility>
#include <limits>

#if CHIP_SYSTEM_CONFIG_USE_LWIP
#include <lwip/mem.h>
Expand Down Expand Up @@ -431,7 +432,7 @@ void PacketBuffer::AddRef()
pbuf_ref(this);
#else // !CHIP_SYSTEM_CONFIG_USE_LWIP
LOCK_BUF_POOL();
VerifyOrDieWithMsg(this->ref < UINT16_MAX, chipSystemLayer, "packet buffer refcount overflow");
VerifyOrDieWithMsg(this->ref < std::numeric_limits<decltype(this->ref)>::max(), chipSystemLayer, "packet buffer refcount overflow");
++this->ref;
UNLOCK_BUF_POOL();
#endif // !CHIP_SYSTEM_CONFIG_USE_LWIP
Expand Down

0 comments on commit 1c13217

Please sign in to comment.