Skip to content

Commit c72885a

Browse files
committed
Static casts
1 parent 5506707 commit c72885a

5 files changed

+25
-28
lines changed

src/darwin/Framework/CHIP/MTRAsyncCallbackWorkQueue.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ - (NSString *)description
7777
std::lock_guard lock(_lock);
7878

7979
return [NSString
80-
stringWithFormat:@"MTRAsyncCallbackWorkQueue context: %@ items count: %lu", self.context, (unsigned long) self.items.count];
80+
stringWithFormat:@"MTRAsyncCallbackWorkQueue context: %@ items count: %lu", self.context, self.items.count];
8181
}
8282

8383
- (void)enqueueWorkItem:(MTRAsyncCallbackQueueWorkItem *)item

src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm

+9-9
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ - (void)setDuplicateTypeID:(NSUInteger)opaqueDuplicateTypeID handler:(MTRAsyncWo
8484

8585
- (void)assertMutable
8686
{
87-
NSAssert(_state == MTRAsyncWorkItemMutable, @"work item is not mutable (%ld)", (long) _state);
87+
NSAssert(_state == MTRAsyncWorkItemMutable, @"work item is not mutable (%ld)", _state);
8888
}
8989

9090
#pragma mark Management by the work queue (queue lock held)
@@ -109,7 +109,7 @@ - (NSInteger)retryCount
109109

110110
- (void)callReadyHandlerWithContext:(id)context completion:(MTRAsyncWorkCompletionBlock)completion
111111
{
112-
NSAssert(_state >= MTRAsyncWorkItemEnqueued, @"work item is not enqueued (%ld)", (long) _state);
112+
NSAssert(_state >= MTRAsyncWorkItemEnqueued, @"work item is not enqueued (%ld)", _state);
113113
NSInteger retryCount = 0;
114114
if (_state == MTRAsyncWorkItemEnqueued) {
115115
_state = MTRAsyncWorkItemRunning;
@@ -161,7 +161,7 @@ - (BOOL)isComplete
161161

162162
- (void)markComplete
163163
{
164-
NSAssert(_state >= MTRAsyncWorkItemEnqueued, @"work item was not enqueued (%ld)", (long) _state);
164+
NSAssert(_state >= MTRAsyncWorkItemEnqueued, @"work item was not enqueued (%ld)", _state);
165165
_state = MTRAsyncWorkItemComplete;
166166

167167
// Clear all handlers in case any of them captured this object.
@@ -185,7 +185,7 @@ - (NSString *)description
185185
state = @"enqueued";
186186
break;
187187
default:
188-
return [NSString stringWithFormat:@"<%@ %llu running retry: %ld>", self.class, _uniqueID, (long) self.retryCount];
188+
return [NSString stringWithFormat:@"<%@ %llu running retry: %ld>", self.class, _uniqueID, self.retryCount];
189189
}
190190
return [NSString stringWithFormat:@"<%@ %llu %@>", self.class, _uniqueID, state];
191191
}
@@ -236,7 +236,7 @@ - (NSString *)description
236236
{
237237
ContextSnapshot context(self);
238238
std::lock_guard lock(_lock);
239-
return [NSString stringWithFormat:@"<%@ context: %@, items count: %lu>", self.class, context.description, (unsigned long) _items.count];
239+
return [NSString stringWithFormat:@"<%@ context: %@, items count: %lu>", self.class, context.description, _items.count];
240240
}
241241

242242
- (void)enqueueWorkItem:(MTRAsyncWorkItem *)item
@@ -268,9 +268,9 @@ - (void)enqueueWorkItem:(MTRAsyncWorkItem *)item
268268
// Logging the description once is enough because other log messages
269269
// related to the work item (execution, completion etc) can easily be
270270
// correlated using the unique id.
271-
MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> enqueued work item [%llu]: %@", context.description, (unsigned long) _items.count, item.uniqueID, description);
271+
MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> enqueued work item [%llu]: %@", context.description, _items.count, item.uniqueID, description);
272272
} else {
273-
MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> enqueued work item [%llu]", context.description, (unsigned long) _items.count, item.uniqueID);
273+
MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> enqueued work item [%llu]", context.description, _items.count, item.uniqueID);
274274
}
275275

276276
[self _callNextReadyWorkItemWithContext:context];
@@ -280,7 +280,7 @@ - (void)invalidate
280280
{
281281
ContextSnapshot context(self); // outside of lock
282282
std::lock_guard lock(_lock);
283-
MTR_LOG("MTRAsyncWorkQueue<%@> invalidate %lu items", context.description, (unsigned long) _items.count);
283+
MTR_LOG("MTRAsyncWorkQueue<%@> invalidate %lu items", context.description, _items.count);
284284
for (MTRAsyncWorkItem * item in _items) {
285285
[item cancel];
286286
}
@@ -316,7 +316,7 @@ - (void)_postProcessWorkItem:(MTRAsyncWorkItem *)workItem
316316

317317
[workItem markComplete];
318318
[_items removeObjectAtIndex:indexOfWorkItem];
319-
MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> completed work item [%llu]", context.description, (unsigned long) _items.count, workItem.uniqueID);
319+
MTR_LOG("MTRAsyncWorkQueue<%@, items count: %lu> completed work item [%llu]", context.description, _items.count, workItem.uniqueID);
320320

321321
// sanity check running work item count is positive
322322
if (_runningWorkItemCount == 0) {

src/darwin/Framework/CHIP/MTRDevice.mm

+6-6
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ - (id)strongObject
118118
UnsolicitedMessageFromPublisherHandler unsolicitedMessageFromPublisherHandler, ReportBeginHandler reportBeginHandler,
119119
ReportEndHandler reportEndHandler)
120120
: MTRBaseSubscriptionCallback(attributeReportCallback, eventReportCallback, errorCallback, resubscriptionCallback,
121-
subscriptionEstablishedHandler, onDoneHandler, unsolicitedMessageFromPublisherHandler, reportBeginHandler,
122-
reportEndHandler)
121+
subscriptionEstablishedHandler, onDoneHandler, unsolicitedMessageFromPublisherHandler, reportBeginHandler,
122+
reportEndHandler)
123123
{
124124
}
125125

@@ -1882,7 +1882,7 @@ - (void)_setupSubscription
18821882
return;
18831883
}
18841884

1885-
MTR_LOG("%@ Subscribe with data version list size %lu, reduced by %lu", self, (unsigned long) dataVersions.count, (unsigned long) dataVersionFilterListSizeReduction);
1885+
MTR_LOG("%@ Subscribe with data version list size %lu, reduced by %lu", self, dataVersions.count, dataVersionFilterListSizeReduction);
18861886

18871887
// Callback and ClusterStateCache and ReadClient will be deleted
18881888
// when OnDone is called.
@@ -2113,7 +2113,7 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath)
21132113
[readRequestsNext removeObjectAtIndex:0];
21142114
[readRequestsCurrent addObject:readItem];
21152115
MTR_LOG("Batching read attribute work item [%llu]: added %@ (now %lu requests total) [0x%016llX:%@:0x%llx:0x%llx]",
2116-
workItemID, readItem, (unsigned long) readRequestsCurrent.count, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
2116+
workItemID, readItem, readRequestsCurrent.count, nodeID.unsignedLongLongValue, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue);
21172117
outcome = MTRBatchedPartially;
21182118
}
21192119
NSCAssert(readRequestsNext.count == 0, @"should have batched everything or returned early");
@@ -2240,7 +2240,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
22402240

22412241
if (writeRequestsCurrent.count != 1) {
22422242
// Very unexpected!
2243-
MTR_LOG_ERROR("Batching write attribute work item [%llu]: Unexpected write request count %lu", workItemID, (unsigned long) writeRequestsCurrent.count);
2243+
MTR_LOG_ERROR("Batching write attribute work item [%llu]: Unexpected write request count %lu", workItemID, writeRequestsCurrent.count);
22442244
return MTRNotBatched;
22452245
}
22462246

@@ -2275,7 +2275,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
22752275
MTRBaseDevice * baseDevice = [self newBaseDevice];
22762276
// Make sure to use writeRequests here, because that's what our batching
22772277
// handler will modify as needed.
2278-
NSCAssert(writeRequests.count == 1, @"Incorrect number of write requests: %lu", (unsigned long) writeRequests.count);
2278+
NSCAssert(writeRequests.count == 1, @"Incorrect number of write requests: %lu", writeRequests.count);
22792279

22802280
auto * request = writeRequests[0];
22812281
MTRAttributePath * path = request[MTRDeviceWriteRequestFieldPathIndex];

src/darwin/Framework/CHIP/MTRDeviceController.mm

+8-11
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,14 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
262262
concurrentSubscriptionPoolSize = static_cast<NSUInteger>(subscriptionPoolSizeOverride);
263263
}
264264

265-
MTR_LOG(" *** Overriding pool size of MTRDeviceController with: %lu", (unsigned long) concurrentSubscriptionPoolSize);
265+
MTR_LOG(" *** Overriding pool size of MTRDeviceController with: %lu", concurrentSubscriptionPoolSize);
266266
}
267267

268268
if (!concurrentSubscriptionPoolSize) {
269269
concurrentSubscriptionPoolSize = 1;
270270
}
271271

272-
MTR_LOG("Setting up pool size of MTRDeviceController with: %lu", (unsigned long) concurrentSubscriptionPoolSize);
272+
MTR_LOG("Setting up pool size of MTRDeviceController with: %lu", concurrentSubscriptionPoolSize);
273273

274274
_concurrentSubscriptionPool = [[MTRAsyncWorkQueue alloc] initWithContext:self width:concurrentSubscriptionPoolSize];
275275

@@ -931,8 +931,7 @@ - (void)preWarmCommissioningSession
931931

932932
- (MTRBaseDevice *)deviceBeingCommissionedWithNodeID:(NSNumber *)nodeID error:(NSError * __autoreleasing *)error
933933
{
934-
auto block = ^MTRBaseDevice *
935-
{
934+
auto block = ^MTRBaseDevice * {
936935
chip::CommissioneeDeviceProxy * deviceProxy;
937936

938937
auto errorCode = self->_cppCommissioner->GetDeviceBeingCommissioned(nodeID.unsignedLongLongValue, &deviceProxy);
@@ -1089,8 +1088,7 @@ + (nullable NSData *)computePASEVerifierForSetupPasscode:(NSNumber *)setupPassco
10891088

10901089
- (NSData * _Nullable)attestationChallengeForDeviceID:(NSNumber *)deviceID
10911090
{
1092-
auto block = ^NSData *
1093-
{
1091+
auto block = ^NSData * {
10941092
chip::CommissioneeDeviceProxy * deviceProxy;
10951093

10961094
auto errorCode = CHIP_NO_ERROR;
@@ -1835,7 +1833,7 @@ - (MTRBaseDevice *)getDeviceBeingCommissioned:(uint64_t)deviceId error:(NSError
18351833
- (BOOL)openPairingWindow:(uint64_t)deviceID duration:(NSUInteger)duration error:(NSError * __autoreleasing *)error
18361834
{
18371835
if (duration > UINT16_MAX) {
1838-
MTR_LOG_ERROR("Error: Duration %lu is too large. Max value %d", (unsigned long) duration, UINT16_MAX);
1836+
MTR_LOG_ERROR("Error: Duration %lu is too large. Max value %d", duration, UINT16_MAX);
18391837
if (error) {
18401838
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE];
18411839
}
@@ -1861,15 +1859,15 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID
18611859
error:(NSError * __autoreleasing *)error
18621860
{
18631861
if (duration > UINT16_MAX) {
1864-
MTR_LOG_ERROR("Error: Duration %lu is too large. Max value %d", (unsigned long) duration, UINT16_MAX);
1862+
MTR_LOG_ERROR("Error: Duration %lu is too large. Max value %d", duration, UINT16_MAX);
18651863
if (error) {
18661864
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE];
18671865
}
18681866
return nil;
18691867
}
18701868

18711869
if (discriminator > 0xfff) {
1872-
MTR_LOG_ERROR("Error: Discriminator %lu is too large. Max value %d", (unsigned long) discriminator, 0xfff);
1870+
MTR_LOG_ERROR("Error: Discriminator %lu is too large. Max value %d", discriminator, 0xfff);
18731871
if (error) {
18741872
*error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_INTEGER_VALUE];
18751873
}
@@ -1888,8 +1886,7 @@ - (NSString *)openPairingWindowWithPIN:(uint64_t)deviceID
18881886
return nil;
18891887
}
18901888

1891-
auto block = ^NSString *
1892-
{
1889+
auto block = ^NSString * {
18931890
chip::SetupPayload setupPayload;
18941891
errorCode = chip::Controller::AutoCommissioningWindowOpener::OpenCommissioningWindow(self->_cppCommissioner, deviceID,
18951892
chip::System::Clock::Seconds16(static_cast<uint16_t>(duration)), chip::Crypto::kSpake2p_Min_PBKDF_Iterations,

src/darwin/Framework/CHIP/MTRThreadOperationalDataset.mm

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ - (BOOL)_populateCppOperationalDataset
102102
- (BOOL)_checkDataLength:(NSData *)data expectedLength:(size_t)expectedLength
103103
{
104104
if (data.length != expectedLength) {
105-
MTR_LOG_ERROR("Length Check Failed. Length:%lu is incorrect, must be %tu", (unsigned long) data.length, expectedLength);
105+
MTR_LOG_ERROR("Length Check Failed. Length:%lu is incorrect, must be %tu", data.length, expectedLength);
106106
return NO;
107107
}
108108
return YES;

0 commit comments

Comments
 (0)