Skip to content

Commit

Permalink
Enable -Wconversion for nrfconnect platform bits.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Feb 28, 2023
1 parent 20c65a2 commit 95127e7
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,8 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnNetworkScanFinished
scanResponse.lqi = aResult->mLqi;
scanResponse.extendedAddress = Encoding::BigEndian::Get64(aResult->mExtAddress.m8);
scanResponse.extendedPanId = Encoding::BigEndian::Get64(aResult->mExtendedPanId.m8);
scanResponse.networkNameLen = strnlen(aResult->mNetworkName.m8, OT_NETWORK_NAME_MAX_SIZE);
static_assert(OT_NETWORK_NAME_MAX_SIZE <= UINT8_MAX, "Network name length won't fit");
scanResponse.networkNameLen = static_cast<uint8_t>(strnlen(aResult->mNetworkName.m8, OT_NETWORK_NAME_MAX_SIZE));
memcpy(scanResponse.networkName, aResult->mNetworkName.m8, scanResponse.networkNameLen);

mScanResponseIter.Add(&scanResponse);
Expand Down Expand Up @@ -1168,7 +1169,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_WriteThreadNetw
}
else
{
lastRssi.SetNonNull(((neighInfo.mLastRssi > 0) ? 0 : neighInfo.mLastRssi));
lastRssi.SetNonNull(min(static_cast<int8_t>(0), neighInfo.mLastRssi));
}

neighborTable.averageRssi = averageRssi;
Expand Down
2 changes: 2 additions & 0 deletions src/platform/Zephyr/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,6 @@ static_library("Zephyr") {
if (chip_malloc_sys_heap) {
sources += [ "SysHeapMalloc.cpp" ]
}

cflags = [ "-Wconversion" ]
}
2 changes: 1 addition & 1 deletion src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetTotalOperationalHours(uint32_t & total

ReturnErrorOnFailure(ConfigurationMgr().GetTotalOperationalHours(reinterpret_cast<uint32_t &>(totalHours)));

totalOperationalHours = totalHours + deltaTime < UINT32_MAX ? totalHours + deltaTime : UINT32_MAX;
totalOperationalHours = static_cast<uint32_t>(totalHours + deltaTime < UINT32_MAX ? totalHours + deltaTime : UINT32_MAX);

return CHIP_NO_ERROR;
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void PlatformManagerImpl::UpdateOperationalHours(intptr_t arg)
if (ConfigurationMgr().GetTotalOperationalHours(reinterpret_cast<uint32_t &>(totalOperationalHours)) == CHIP_NO_ERROR)
{
ConfigurationMgr().StoreTotalOperationalHours(
totalOperationalHours + deltaTime < UINT32_MAX ? totalOperationalHours + deltaTime : UINT32_MAX);
static_cast<uint32_t>(totalOperationalHours + deltaTime < UINT32_MAX ? totalOperationalHours + deltaTime : UINT32_MAX));
sInstance.mSavedOperationalHoursSinceBoot = upTimeH;
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/platform/nrfconnect/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,6 @@ static_library("nrfconnect") {
if (chip_malloc_sys_heap) {
sources += [ "../Zephyr/SysHeapMalloc.cpp" ]
}

cflags = [ "-Wconversion" ]
}
12 changes: 10 additions & 2 deletions src/platform/nrfconnect/OTAImageProcessorImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,16 @@ CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & aBlock)
if (error == CHIP_NO_ERROR)
{
// DFU target library buffers data internally, so do not clone the block data.
error = System::MapErrorZephyr(dfu_multi_image_write(mParams.downloadedBytes, aBlock.data(), aBlock.size()));
mParams.downloadedBytes += aBlock.size();
if (mParams.downloadedBytes > std::numeric_limits<size_t>::max())
{
error = CHIP_ERROR_BUFFER_TOO_SMALL;
}
else
{
error = System::MapErrorZephyr(
dfu_multi_image_write(static_cast<size_t>(mParams.downloadedBytes), aBlock.data(), aBlock.size()));
mParams.downloadedBytes += aBlock.size();
}
}

// Report the result back to the downloader asynchronously.
Expand Down

0 comments on commit 95127e7

Please sign in to comment.