From 803ddb0beb333981ceb2b023e95f307a106ddf68 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 6 Mar 2023 19:33:07 -0500 Subject: [PATCH] Enable -Wconversion in openiotsdk platform code. (#25410) --- src/platform/openiotsdk/BUILD.gn | 2 ++ src/platform/openiotsdk/KVBlockDeviceStore.cpp | 2 +- src/platform/openiotsdk/KVPsaPsStore.cpp | 4 ++-- .../openiotsdk/NetworkCommissioningEthernetDriver.cpp | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/platform/openiotsdk/BUILD.gn b/src/platform/openiotsdk/BUILD.gn index a8cd947ae411bc..726b2face0b36e 100644 --- a/src/platform/openiotsdk/BUILD.gn +++ b/src/platform/openiotsdk/BUILD.gn @@ -95,4 +95,6 @@ static_library("openiotsdk") { "KVBlockDeviceStore.h", ] } + + cflags = [ "-Wconversion" ] } diff --git a/src/platform/openiotsdk/KVBlockDeviceStore.cpp b/src/platform/openiotsdk/KVBlockDeviceStore.cpp index fc6f364976b0d7..f42d76300e7efb 100644 --- a/src/platform/openiotsdk/KVBlockDeviceStore.cpp +++ b/src/platform/openiotsdk/KVBlockDeviceStore.cpp @@ -457,7 +457,7 @@ KVBlockDeviceStoreKeyBuilder::KVBlockDeviceStoreKeyBuilder(const char * key) if (illegal_ptr) { *out++ = '!'; - *out++ = 'A' + (int) (illegal_ptr - illegalCharacters); + *out++ = static_cast('A' + (int) (illegal_ptr - illegalCharacters)); } else { diff --git a/src/platform/openiotsdk/KVPsaPsStore.cpp b/src/platform/openiotsdk/KVPsaPsStore.cpp index 74023134ec0e97..0e46cec64d5919 100644 --- a/src/platform/openiotsdk/KVPsaPsStore.cpp +++ b/src/platform/openiotsdk/KVPsaPsStore.cpp @@ -601,7 +601,7 @@ void KVPsaPsStoreKeyBuilder::AddKey() return; } - uint32_t keyIndex = CONVERT_KEY_TO_INDEX(keyValue); + auto keyIndex = CONVERT_KEY_TO_INDEX(keyValue); memset(mKvsStoredKeyString[keyIndex], 0, sizeof(mKvsStoredKeyString[keyIndex])); Platform::CopyString(mKvsStoredKeyString[keyIndex], buffer); KVPsaPsStore::ScheduleKVSKeyMapUpdate(); @@ -614,7 +614,7 @@ void KVPsaPsStoreKeyBuilder::RemoveKey() return; } - uint32_t keyIndex = CONVERT_KEY_TO_INDEX(keyValue); + auto keyIndex = CONVERT_KEY_TO_INDEX(keyValue); memset(mKvsStoredKeyString[keyIndex], 0, sizeof(mKvsStoredKeyString[keyIndex])); KVPsaPsStore::ScheduleKVSKeyMapUpdate(); } diff --git a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp index df36092c5e2e8d..caeadc2451a361 100644 --- a/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp +++ b/src/platform/openiotsdk/NetworkCommissioningEthernetDriver.cpp @@ -41,7 +41,7 @@ NetworkIterator * OpenIoTSDKEthernetDriver::GetNetworks() char buf[NETIF_NAMESIZE]; char * ifname = netif_index_to_name(0, buf); - ret->interfaceNameLen = strlen(ifname); + ret->interfaceNameLen = static_cast(strlen(ifname)); memcpy(ret->interfaceName, ifname, ret->interfaceNameLen); return ret;