Skip to content

Commit

Permalink
Updating format strings per feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
woody-apple committed May 24, 2024
1 parent 57f29a8 commit 07789a2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
12 changes: 6 additions & 6 deletions src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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];
Expand All @@ -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];
}
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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];
Expand Down
19 changes: 8 additions & 11 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
concurrentSubscriptionPoolSize = static_cast<NSUInteger>(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];

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}
Expand All @@ -1861,15 +1859,15 @@ - (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];
}
return nil;
}

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];
}
Expand All @@ -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<uint16_t>(duration)), chip::Crypto::kSpake2p_Min_PBKDF_Iterations,
Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 07789a2

Please sign in to comment.