Skip to content

Commit

Permalink
Fix data types (#11763)
Browse files Browse the repository at this point in the history
* Fix data types

*std::min is a template requiring identical data types, so explicitly
specify the datatype.
*Fix signed vs unsigned bitwise operation.

* Update src/transport/FabricTable.h

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>

* Restyled by clang-format

Co-authored-by: Tennessee Carmel-Veilleux <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
3 people authored and pull[bot] committed May 18, 2022
1 parent 66a257d commit 1087736
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/support/CHIPArgParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,9 @@ bool ParseInt(const char * str, int16_t & output)
const int base = 10;
int32_t output32 = 0;

if ((ParseInt(str, output32, base)) && (output32 <= SHRT_MAX))
if ((ParseInt(str, output32, base)) && (output32 <= SHRT_MAX && output32 >= SHRT_MIN))
{
output = static_cast<int16_t>(UINT16_MAX & output32);
output = static_cast<int16_t>(output32);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/transport/FabricTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
namespace chip {

static constexpr FabricIndex kMinValidFabricIndex = 1;
static constexpr FabricIndex kMaxValidFabricIndex = std::min(UINT8_MAX, CHIP_CONFIG_MAX_DEVICE_ADMINS);
static constexpr FabricIndex kMaxValidFabricIndex = std::min<FabricIndex>(UINT8_MAX - 1, CHIP_CONFIG_MAX_DEVICE_ADMINS);
static constexpr uint8_t kFabricLabelMaxLengthInBytes = 32;

// KVS store is sensitive to length of key strings, based on the underlying
Expand Down

0 comments on commit 1087736

Please sign in to comment.