From 07789a2e56b521f88ca3479c5dbddebcb021825d Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Thu, 23 May 2024 18:27:52 -0700 Subject: [PATCH] Updating format strings per feedback --- .../pairing/DeviceControllerDelegateBridge.mm | 2 +- .../Framework/CHIP/MTRAsyncWorkQueue.mm | 12 ++++++------ src/darwin/Framework/CHIP/MTRDevice.mm | 8 ++++---- .../Framework/CHIP/MTRDeviceController.mm | 19 ++++++++----------- .../CHIP/MTRThreadOperationalDataset.mm | 2 +- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm index c8594a6f4fa87c..2874d9d2286a55 100644 --- a/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm +++ b/examples/darwin-framework-tool/commands/pairing/DeviceControllerDelegateBridge.mm @@ -22,7 +22,7 @@ @implementation CHIPToolDeviceControllerDelegate - (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommissioningStatus)status { - NSLog(@"Pairing Status Update: %tu", status); + NSLog(@"Pairing Status Update: %ld", (long) status); switch (status) { case MTRCommissioningStatusSuccess: ChipLogProgress(chipTool, "Secure Pairing Success"); diff --git a/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm b/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm index 7220b6f72fc208..804580bb0d8ab5 100644 --- a/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm +++ b/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm @@ -185,7 +185,7 @@ - (NSString *)description state = @"enqueued"; break; default: - return [NSString stringWithFormat:@"<%@ %llu running retry: %tu>", self.class, _uniqueID, self.retryCount]; + return [NSString stringWithFormat:@"<%@ %llu running retry: %ld>", self.class, _uniqueID, (long) self.retryCount]; } return [NSString stringWithFormat:@"<%@ %llu %@>", self.class, _uniqueID, state]; } @@ -236,7 +236,7 @@ - (NSString *)description { ContextSnapshot context(self); std::lock_guard lock(_lock); - return [NSString stringWithFormat:@"<%@ context: %@, items count: %tu>", self.class, context.description, _items.count]; + return [NSString stringWithFormat:@"<%@ context: %@, items count: %lu>", self.class, context.description, (unsigned long) _items.count]; } - (void)enqueueWorkItem:(MTRAsyncWorkItem *)item @@ -268,9 +268,9 @@ - (void)enqueueWorkItem:(MTRAsyncWorkItem *)item // Logging the description once is enough because other log messages // related to the work item (execution, completion etc) can easily be // correlated using the unique id. - MTR_LOG("MTRAsyncWorkQueue<%@, items count: %tu> enqueued work item [%llu]: %@", context.description, _items.count, item.uniqueID, description); + MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> enqueued work item [%llu]: %@", context.description, (unsigned long) _items.count, item.uniqueID, description); } else { - MTR_LOG("MTRAsyncWorkQueue<%@, items count: %tu> enqueued work item [%llu]", context.description, _items.count, item.uniqueID); + MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> enqueued work item [%llu]", context.description, (unsigned long) _items.count, item.uniqueID); } [self _callNextReadyWorkItemWithContext:context]; @@ -280,7 +280,7 @@ - (void)invalidate { ContextSnapshot context(self); // outside of lock std::lock_guard lock(_lock); - MTR_LOG("MTRAsyncWorkQueue<%@> invalidate %tu items", context.description, _items.count); + MTR_LOG("MTRAsyncWorkQueue<%@> invalidate %lu items", context.description, (unsigned long) _items.count); for (MTRAsyncWorkItem * item in _items) { [item cancel]; } @@ -316,7 +316,7 @@ - (void)_postProcessWorkItem:(MTRAsyncWorkItem *)workItem [workItem markComplete]; [_items removeObjectAtIndex:indexOfWorkItem]; - MTR_LOG("MTRAsyncWorkQueue<%@, items count: %tu> completed work item [%llu]", context.description, _items.count, workItem.uniqueID); + MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> completed work item [%llu]", context.description, (unsigned long) _items.count, workItem.uniqueID); // sanity check running work item count is positive if (_runningWorkItemCount == 0) { diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 01f56756942b16..70c63f9b8107a0 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -2112,8 +2112,8 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath) auto readItem = readRequestsNext.firstObject; [readRequestsNext removeObjectAtIndex:0]; [readRequestsCurrent addObject:readItem]; - MTR_LOG("Batching read attribute work item [%llu]: added %@ (now %tu requests total) [0x%016llX:%@:0x%llx:0x%llx]", - workItemID, readItem, readRequestsCurrent.count, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue); + MTR_LOG("Batching read attribute work item [%llu]: added %@ (now %lu requests total) [0x%016llX:%@:0x%llx:0x%llx]", + workItemID, readItem, (unsigned long) readRequestsCurrent.count, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue); outcome = MTRBatchedPartially; } NSCAssert(readRequestsNext.count == 0, @"should have batched everything or returned early"); @@ -2240,7 +2240,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID if (writeRequestsCurrent.count != 1) { // Very unexpected! - MTR_LOG_ERROR("Batching write attribute work item [%llu]: Unexpected write request count %tu", workItemID, writeRequestsCurrent.count); + MTR_LOG_ERROR("Batching write attribute work item [%llu]: Unexpected write request count %lu", workItemID, (unsigned long) writeRequestsCurrent.count); return MTRNotBatched; } @@ -2275,7 +2275,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID MTRBaseDevice * baseDevice = [self newBaseDevice]; // Make sure to use writeRequests here, because that's what our batching // handler will modify as needed. - NSCAssert(writeRequests.count == 1, @"Incorrect number of write requests: %tu", writeRequests.count); + NSCAssert(writeRequests.count == 1, @"Incorrect number of write requests: %lu", (unsigned long) writeRequests.count); auto * request = writeRequests[0]; MTRAttributePath * path = request[MTRDeviceWriteRequestFieldPathIndex]; diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 1bc4e6e039221e..097229a70599a8 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -262,14 +262,14 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory concurrentSubscriptionPoolSize = static_cast(subscriptionPoolSizeOverride); } - MTR_LOG(" *** Overriding pool size of MTRDeviceController with: %tu", concurrentSubscriptionPoolSize); + MTR_LOG(" *** Overriding pool size of MTRDeviceController with: %lu", (unsigned long) concurrentSubscriptionPoolSize); } if (!concurrentSubscriptionPoolSize) { concurrentSubscriptionPoolSize = 1; } - MTR_LOG("Setting up pool size of MTRDeviceController with: %tu", concurrentSubscriptionPoolSize); + MTR_LOG("Setting up pool size of MTRDeviceController with: %lu", (unsigned long) concurrentSubscriptionPoolSize); _concurrentSubscriptionPool = [[MTRAsyncWorkQueue alloc] initWithContext:self width:concurrentSubscriptionPoolSize]; @@ -931,8 +931,7 @@ - (void)preWarmCommissioningSession - (MTRBaseDevice *)deviceBeingCommissionedWithNodeID:(NSNumber *)nodeID error:(NSError * __autoreleasing *)error { - auto block = ^MTRBaseDevice * - { + auto block = ^MTRBaseDevice * { chip::CommissioneeDeviceProxy * deviceProxy; auto errorCode = self->_cppCommissioner->GetDeviceBeingCommissioned(nodeID.unsignedLongLongValue, &deviceProxy); @@ -1089,8 +1088,7 @@ + (nullable NSData *)computePASEVerifierForSetupPasscode:(NSNumber *)setupPassco - (NSData * _Nullable)attestationChallengeForDeviceID:(NSNumber *)deviceID { - auto block = ^NSData * - { + auto block = ^NSData * { chip::CommissioneeDeviceProxy * deviceProxy; auto errorCode = CHIP_NO_ERROR; @@ -1835,7 +1833,7 @@ - (MTRBaseDevice *)getDeviceBeingCommissioned:(uint64_t)deviceId error:(NSError - (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error:(NSError * __autoreleasing *)error { if (duration > UINT16_MAX) { - MTR_LOG_ERROR("Error: Duration %tu is too large. Max value %d", duration, UINT16_MAX); + MTR_LOG_ERROR("Error: Duration %lu is too large. Max value %d", (unsigned long) duration, UINT16_MAX); if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; } @@ -1861,7 +1859,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID error:(NSError * __autoreleasing *)error { if (duration > UINT16_MAX) { - MTR_LOG_ERROR("Error: Duration %tu is too large. Max value %d", duration, UINT16_MAX); + MTR_LOG_ERROR("Error: Duration %lu is too large. Max value %d", (unsigned long) duration, UINT16_MAX); if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; } @@ -1869,7 +1867,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID } if (discriminator > 0xfff) { - MTR_LOG_ERROR("Error: Discriminator %tu is too large. Max value %d", discriminator, 0xfff); + MTR_LOG_ERROR("Error: Discriminator %lu is too large. Max value %d", (unsigned long) discriminator, 0xfff); if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE]; } @@ -1888,8 +1886,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID return nil; } - auto block = ^NSString * - { + auto block = ^NSString * { chip::SetupPayload setupPayload; errorCode = chip::Controller::AutoCommissioningWindowOpener::OpenCommissioningWindow(self->_cppCommissioner, deviceID, chip::System::Clock::Seconds16(static_cast(duration)), chip::Crypto::kSpake2p_Min_PBKDF_Iterations, diff --git a/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm b/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm index a547321d88c2e0..dd3b62f3a57833 100644 --- a/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm +++ b/src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm @@ -102,7 +102,7 @@ - (BOOL)_populateCppOperationalDataset - (BOOL)_checkDataLength:(NSData *)data expectedLength:(size_t)expectedLength { if (data.length != expectedLength) { - MTR_LOG_ERROR("Length Check Failed. Length:%tu is incorrect, must be %tu", data.length, expectedLength); + MTR_LOG_ERROR("Length Check Failed. Length:%lu is incorrect, must be %tu", (unsigned long) data.length, expectedLength); return NO; } return YES;