Skip to content

Commit

Permalink
Add parentheses around static_cast arguments
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei Menzopol <[email protected]>
  • Loading branch information
andrei-menzopol committed Apr 19, 2022
1 parent a162bfe commit 6b6455b
Show file tree
Hide file tree
Showing 24 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
break;
}

ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int> heap_caps_get_free_size(MALLOC_CAP_8BIT));
ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int>(heap_caps_get_free_size(MALLOC_CAP_8BIT)));
}

void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
Expand Down Expand Up @@ -197,7 +197,7 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
break;
}

ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int> heap_caps_get_free_size(MALLOC_CAP_8BIT));
ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int>(heap_caps_get_free_size(MALLOC_CAP_8BIT)));
}

void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
Expand Down
2 changes: 1 addition & 1 deletion examples/chef/esp32/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg)
break;
}

ChipLogProgress(Shell, "Current free heap: %u\n", static_cast<unsigned int> heap_caps_get_free_size(MALLOC_CAP_8BIT));
ChipLogProgress(Shell, "Current free heap: %u\n", static_cast<unsigned int>(heap_caps_get_free_size(MALLOC_CAP_8BIT)));
}

const char * TAG = "chef-app";
Expand Down
8 changes: 4 additions & 4 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
"number of ids (for examples 2 cluster ids, 2 attribute ids and 2 endpoint ids).\n The current command has %u "
"cluster ids, %u attribute ids, %u endpoint ids.",
interactionType == chip::app::ReadClient::InteractionType::Subscribe ? "Subscribe" : "Read",
static_cast<unsigned int> clusterCount, static_cast<unsigned int> attributeCount,
static_cast<unsigned int> endpointCount);
static_cast<unsigned int>(clusterCount), static_cast<unsigned int>(attributeCount),
static_cast<unsigned int>(endpointCount));
return CHIP_ERROR_INVALID_ARGUMENT;
}

Expand Down Expand Up @@ -269,8 +269,8 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
"number of ids (for examples 2 cluster ids, 2 event ids and 2 endpoint ids).\n The current command has %u "
"cluster ids, %u event ids, %u endpoint ids.",
interactionType == chip::app::ReadClient::InteractionType::Subscribe ? "Subscribe" : "Read",
static_cast<unsigned int> clusterCount, static_cast<unsigned int> eventCount,
static_cast<unsigned int> endpointCount);
static_cast<unsigned int>(clusterCount), static_cast<unsigned int>(eventCount),
static_cast<unsigned int>(endpointCount));
return CHIP_ERROR_INVALID_ARGUMENT;
}

Expand Down
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ bool Command::InitArguments(int argc, char ** argv)

VerifyOrExit((size_t)(argc) >= mandatoryArgsCount && (argvExtraArgsCount == 0 || (argvExtraArgsCount && optionalArgsCount)),
ChipLogError(chipTool, "InitArgs: Wrong arguments number: %d instead of %u", argc,
static_cast<unsigned int> mandatoryArgsCount));
static_cast<unsigned int>(mandatoryArgsCount)));

// Initialize mandatory arguments
for (size_t i = 0; i < mandatoryArgsCount; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
}

// TODO
// log_info("Current free heap: %u\r\n\n", static_cast<unsigned int>heap_caps_get_free_size(MALLOC_CAP_8BIT));
// log_info("Current free heap: %u\r\n\n", static_cast<unsigned int>(heap_caps_get_free_size(MALLOC_CAP_8BIT)));
}

void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
Expand Down
4 changes: 2 additions & 2 deletions examples/lighting-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
break;
}

ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int> heap_caps_get_free_size(MALLOC_CAP_8BIT));
ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int>(heap_caps_get_free_size(MALLOC_CAP_8BIT)));
}

void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
Expand Down Expand Up @@ -146,7 +146,7 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
break;
}

ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int> heap_caps_get_free_size(MALLOC_CAP_8BIT));
ESP_LOGI(TAG, "Current free heap: %u\n", static_cast<unsigned int>(heap_caps_get_free_size(MALLOC_CAP_8BIT)));
}

void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event)
Expand Down
6 changes: 3 additions & 3 deletions examples/lock-app/linux/src/LockEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::
"credentialRule=%u,credentials=%p,totalCredentials=%u]",
mEndpointId, userIndex, creator, modifier, static_cast<int>(userName.size()), userName.data(), uniqueId,
to_underlying(userStatus), to_underlying(usertype), to_underlying(credentialRule), credentials,
static_cast<unsigned int> totalCredentials);
static_cast<unsigned int>(totalCredentials));

uint16_t adjustedUserIndex = static_cast<uint16_t>(userIndex - 1);
if (adjustedUserIndex > mLockUsers.size())
Expand All @@ -104,7 +104,7 @@ bool LockEndpoint::SetUser(uint16_t userIndex, chip::FabricIndex creator, chip::
ChipLogError(Zcl,
"Cannot set user - total number of credentials is too big [endpoint=%d,index=%d,adjustedUserIndex=%u"
",totalCredentials=%u]",
mEndpointId, userIndex, adjustedUserIndex, static_cast<unsigned int> totalCredentials);
mEndpointId, userIndex, adjustedUserIndex, static_cast<unsigned int>(totalCredentials));
return false;
}

Expand Down Expand Up @@ -180,7 +180,7 @@ bool LockEndpoint::SetCredential(uint16_t credentialIndex, DlCredentialStatus cr
"Cannot get the credential - data size exceeds limit "
"[endpoint=%d,index=%d,dataSize=%u,maxDataSize=%u]",
mEndpointId, credentialIndex, static_cast<unsigned int>(credentialData.size()),
static_cast<unsigned int> DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE);
static_cast<unsigned int>(DOOR_LOCK_CREDENTIAL_INFO_MAX_DATA_SIZE));
return false;
}
credentialInStorage.status = credentialStatus;
Expand Down
4 changes: 2 additions & 2 deletions src/app/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ void CommandHandler::Close()
// in reasonable time or there is a bug. The only case for releasing CommandHandler without CommandHandler::Handle releasing its
// reference is the stack shutting down, in which case Close() is not called. So the below check should always pass.
VerifyOrDieWithMsg(mPendingWork == 0, DataManagement, "CommandHandler::Close() called with %u unfinished async work items",
static_cast<unsigned int> mPendingWork);
static_cast<unsigned int>(mPendingWork));

// OnDone below can destroy us before we unwind all the way back into the
// exchange code and it tries to close itself. Make sure that it doesn't
Expand Down Expand Up @@ -198,7 +198,7 @@ void CommandHandler::DecrementHoldOff()
{
mPendingWork--;
ChipLogDetail(DataManagement, "Decreasing reference count for CommandHandler, remaining %u",
static_cast<unsigned int> mPendingWork);
static_cast<unsigned int>(mPendingWork));
if (mPendingWork != 0)
{
return;
Expand Down
12 changes: 6 additions & 6 deletions src/app/clusters/door-lock-server/door-lock-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,8 +504,8 @@ void DoorLockServer::SetCredentialCommandHandler(
{
emberAfDoorLockClusterPrintln("[SetCredential] Credential data size is out of range "
"[endpointId=%d,credentialType=%u,minLength=%u,maxLength=%u,length=%u]",
commandPath.mEndpointId, to_underlying(credentialType), static_cast<unsigned int> minSize,
static_cast<unsigned int> maxSize, static_cast<unsigned int>(credentialData.size()));
commandPath.mEndpointId, to_underlying(credentialType), static_cast<unsigned int>(minSize),
static_cast<unsigned int>(maxSize), static_cast<unsigned int>(credentialData.size()));
sendSetCredentialResponse(commandObj, DlStatus::kInvalidField, 0, nextAvailableCredentialSlot);
return;
}
Expand Down Expand Up @@ -1546,7 +1546,7 @@ EmberAfStatus DoorLockServer::createUser(chip::EndpointId endpointId, chip::Fabr
"userType=%u,credentialRule=%u,totalCredentials=%u]",
endpointId, creatorFabricIdx, userIndex, static_cast<int>(newUserName.size()),
newUserName.data(), newUserUniqueId, to_underlying(newUserStatus), to_underlying(newUserType),
to_underlying(newCredentialRule), static_cast<unsigned int> newTotalCredentials);
to_underlying(newCredentialRule), static_cast<unsigned int>(newTotalCredentials));
return EMBER_ZCL_STATUS_FAILURE;
}

Expand All @@ -1556,7 +1556,7 @@ EmberAfStatus DoorLockServer::createUser(chip::EndpointId endpointId, chip::Fabr
"userType=%u,credentialRule=%u,totalCredentials=%u]",
endpointId, creatorFabricIdx, userIndex, static_cast<int>(newUserName.size()), newUserName.data(),
newUserUniqueId, to_underlying(newUserStatus), to_underlying(newUserType),
to_underlying(newCredentialRule), static_cast<unsigned int> newTotalCredentials);
to_underlying(newCredentialRule), static_cast<unsigned int>(newTotalCredentials));

sendRemoteLockUserChange(endpointId, DlLockDataType::kUserIndex, DlDataOperationType::kAdd, sourceNodeId, creatorFabricIdx,
userIndex, userIndex);
Expand Down Expand Up @@ -2403,15 +2403,15 @@ EmberAfStatus DoorLockServer::clearCredential(chip::EndpointId endpointId, chip:
"[endpointId=%d,credentialType=%u"
",credentialIndex=%d,modifier=%d,userIndex=%d,newCredentialsCount=%u]",
endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex,
static_cast<unsigned int> newCredentialsCount);
static_cast<unsigned int>(newCredentialsCount));
return EMBER_ZCL_STATUS_FAILURE;
}

emberAfDoorLockClusterPrintln(
"[clearCredential] Successfully clear credential and related user "
"[endpointId=%d,credentialType=%u,credentialIndex=%d,modifier=%d,userIndex=%d,newCredentialsCount=%u]",
endpointId, to_underlying(credentialType), credentialIndex, modifier, relatedUserIndex,
static_cast<unsigned int> newCredentialsCount);
static_cast<unsigned int>(newCredentialsCount));

if (sendUserChangeEvent)
{
Expand Down
8 changes: 4 additions & 4 deletions src/app/clusters/ota-provider/ota-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestCallback(

if (updateToken.size() > kUpdateTokenMaxLength || updateToken.size() < kUpdateTokenMinLength)
{
ChipLogError(Zcl, "expected size %u for UpdateToken, got %u", static_cast<unsigned int> kUpdateTokenMaxLength,
ChipLogError(Zcl, "expected size %u for UpdateToken, got %u", static_cast<unsigned int>(kUpdateTokenMaxLength),
static_cast<unsigned int>(updateToken.size()));
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
Expand Down Expand Up @@ -130,7 +130,7 @@ bool emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback(

if (updateToken.size() > kUpdateTokenMaxLength || updateToken.size() < kUpdateTokenMinLength)
{
ChipLogError(Zcl, "expected size %u for UpdateToken, got %u", static_cast<unsigned int> kUpdateTokenMaxLength,
ChipLogError(Zcl, "expected size %u for UpdateToken, got %u", static_cast<unsigned int>(kUpdateTokenMaxLength),
static_cast<unsigned int>(updateToken.size()));
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
Expand Down Expand Up @@ -200,15 +200,15 @@ bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(app::CommandHandl
if (location.HasValue() && location.Value().size() != kLocationLen)
{
ChipLogError(Zcl, "location param length %u != expected length %u", static_cast<unsigned int>(location.Value().size()),
static_cast<unsigned int> kLocationLen);
static_cast<unsigned int>(kLocationLen));
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
}

if (metadataForProvider.HasValue() && metadataForProvider.Value().size() > kMaxMetadataLen)
{
ChipLogError(Zcl, "metadata size %u exceeds max %u", static_cast<unsigned int>(metadataForProvider.Value().size()),
static_cast<unsigned int> kMaxMetadataLen);
static_cast<unsigned int>(kMaxMetadataLen));
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/reporting/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ CHIP_ERROR Engine::BuildSingleReportDataEventReports(ReportDataMessage::Builder
eventReportIBs.EndOfEventReports();
SuccessOrExit(err = eventReportIBs.GetError());
}
ChipLogDetail(DataManagement, "Fetched %u events", static_cast<unsigned int> eventCount);
ChipLogDetail(DataManagement, "Fetched %u events", static_cast<unsigned int>(eventCount));

exit:
if (apHasEncodedData != nullptr)
Expand Down
10 changes: 5 additions & 5 deletions src/app/tests/TestEventLogging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void PrintEventLog()
chip::app::EventManagement::GetInstance().GetEventReader(reader, chip::app::PriorityLevel::Debug, &bufWrapper);

chip::TLV::Utilities::Count(reader, elementCount, false);
printf("Found %u elements\n", static_cast<unsigned int> elementCount);
printf("Found %u elements\n", static_cast<unsigned int>(elementCount));
chip::TLV::Debug::Dump(reader, SimpleDumpWriter);
}

Expand All @@ -137,8 +137,8 @@ static void CheckLogState(nlTestSuite * apSuite, chip::app::EventManagement & aL
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

NL_TEST_ASSERT(apSuite, elementCount == expectedNumEvents);
printf("elementCount vs expectedNumEvents : %u vs %u \n", static_cast<unsigned int> elementCount,
static_cast<unsigned int> expectedNumEvents);
printf("elementCount vs expectedNumEvents : %u vs %u \n", static_cast<unsigned int>(elementCount),
static_cast<unsigned int>(expectedNumEvents));
}

static void CheckLogReadOut(nlTestSuite * apSuite, chip::app::EventManagement & alogMgmt, chip::EventNumber startingEventNumber,
Expand All @@ -159,8 +159,8 @@ static void CheckLogReadOut(nlTestSuite * apSuite, chip::app::EventManagement &
err = chip::TLV::Utilities::Count(reader, totalNumElements, false);
NL_TEST_ASSERT(apSuite, err == CHIP_NO_ERROR);

printf("totalNumElements vs expectedNumEvents vs eventCount : %u vs %u vs %u \n", static_cast<unsigned int> totalNumElements,
static_cast<unsigned int> expectedNumEvents, static_cast<unsigned int> eventCount);
printf("totalNumElements vs expectedNumEvents vs eventCount : %u vs %u vs %u \n", static_cast<unsigned int>(totalNumElements),
static_cast<unsigned int>(expectedNumEvents), static_cast<unsigned int>(eventCount));
NL_TEST_ASSERT(apSuite, totalNumElements == expectedNumEvents && totalNumElements == eventCount);
reader.Init(backingStore, writer.GetLengthWritten());
chip::TLV::Debug::Dump(reader, SimpleDumpWriter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void ClearSecretData(NSMutableData * data)

chip::Crypto::P256SerializedKeypair serialized;
if ([keypairData length] != serialized.Capacity()) {
NSLog(@"Keypair length %u does not match expected length %u", static_cast<unsigned int>[keypairData length],
NSLog(@"Keypair length %u does not match expected length %u", static_cast<unsigned int>([keypairData length]),
static_cast<unsigned int>(serialized.Capacity()));
ClearSecretData(keypairData);
return CHIP_ERROR_INTERNAL;
Expand Down Expand Up @@ -200,7 +200,7 @@ static void ClearSecretData(NSMutableData * data)

NSMutableData * ipkData = [[NSMutableData alloc] initWithBase64EncodedData:keyData options:0];
if ([ipkData length] != mIPK.Length()) {
NSLog(@"IPK length %u does not match expected length %u", static_cast<unsigned int>[ipkData length],
NSLog(@"IPK length %u does not match expected length %u", static_cast<unsigned int>([ipkData length]),
static_cast<unsigned int>(mIPK.Length()));
ClearSecretData(ipkData);
return CHIP_ERROR_INTERNAL;
Expand Down
2 changes: 1 addition & 1 deletion src/inet/tests/TestInetAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ void CheckAddressQuartet(nlTestSuite * inSuite, const uint32_t & inFirstAddressQ
if (!lResult)
{
fprintf(stdout, "Address quartet %u mismatch: actual 0x%08" PRIX32 ", expected: 0x%08" PRIX32 "\n",
static_cast<unsigned int> inWhich, inFirstAddressQuartet, inSecondAddressQuartet);
static_cast<unsigned int>(inWhich), inFirstAddressQuartet, inSecondAddressQuartet);
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/lib/core/tests/TestCHIPTLV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2569,9 +2569,9 @@ void CheckCHIPTLVPutStringF(nlTestSuite * inSuite, void * inContext)
CHIP_ERROR err = CHIP_NO_ERROR;

writer.Init(backingStore, bufsize);
snprintf(strBuffer, sizeof(strBuffer), "Sample string %u", static_cast<unsigned int> num);
snprintf(strBuffer, sizeof(strBuffer), "Sample string %u", static_cast<unsigned int>(num));

err = writer.PutStringF(ProfileTag(TestProfile_1, 1), "Sample string %u", static_cast<unsigned int> num);
err = writer.PutStringF(ProfileTag(TestProfile_1, 1), "Sample string %u", static_cast<unsigned int>(num));
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = writer.Finalize();
Expand Down Expand Up @@ -2651,15 +2651,15 @@ void CheckCHIPTLVPutStringFCircular(nlTestSuite * inSuite, void * inContext)
// Initial test: Verify that a straight printf works as expected into continuous buffer.

writer.Init(buffer);
snprintf(strBuffer, sizeof(strBuffer), "Sample string %u", static_cast<unsigned int> num);
snprintf(strBuffer, sizeof(strBuffer), "Sample string %u", static_cast<unsigned int>(num));

err = writer.PutBoolean(ProfileTag(TestProfile_1, 2), true);
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = writer.Finalize();
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = writer.PutStringF(ProfileTag(TestProfile_1, 1), "Sample string %u", static_cast<unsigned int> num);
err = writer.PutStringF(ProfileTag(TestProfile_1, 1), "Sample string %u", static_cast<unsigned int>(num));
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = writer.Finalize();
Expand All @@ -2683,9 +2683,9 @@ void CheckCHIPTLVPutStringFCircular(nlTestSuite * inSuite, void * inContext)
// This print will both stradle the boundary of the buffer and displace the previous two elements.
num = 2;

snprintf(strBuffer, sizeof(strBuffer), "Sample string %u", static_cast<unsigned int> num);
snprintf(strBuffer, sizeof(strBuffer), "Sample string %u", static_cast<unsigned int>(num));

err = writer.PutStringF(ProfileTag(TestProfile_1, 1), "Sample string %u", static_cast<unsigned int> num);
err = writer.PutStringF(ProfileTag(TestProfile_1, 1), "Sample string %u", static_cast<unsigned int>(num));
NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR);

err = writer.Finalize();
Expand Down
Loading

0 comments on commit 6b6455b

Please sign in to comment.