@@ -6795,7 +6795,7 @@ - (void)test055_WatchdogNoOpsWhenAdvertisementRacesAhead
67956795 // measured from setDelegate; by now both the advertisement-driven
67966796 // scheduling and the watchdog deadline are in the past.
67976797 XCTestExpectation * settle = [self expectationWithDescription: @" Watchdog window has elapsed" ];
6798- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(2 * NSEC_PER_SEC)), queue, ^{
6798+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (2 * NSEC_PER_SEC)), queue, ^{
67996799 [settle fulfill ];
68006800 });
68016801 [self waitForExpectations: @[ settle ] timeout: 5 ];
@@ -6897,7 +6897,7 @@ - (void)test056_NodeMayBeAdvertisingOperationalAfterDeferralCompletes
68976897
68986898 // Allow time for any erroneous state churn to manifest.
68996899 XCTestExpectation * settle = [self expectationWithDescription: @" Post-establishment advertisement processed" ];
6900- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(2 * NSEC_PER_SEC)), queue, ^{
6900+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (2 * NSEC_PER_SEC)), queue, ^{
69016901 [settle fulfill ];
69026902 });
69036903 [self waitForExpectations: @[ settle ] timeout: 5 ];
@@ -7008,7 +7008,7 @@ - (void)test057_LatchIsPerInstanceFreshDeviceDefersAgain
70087008 // (it's set synchronously inside _ensureSubscriptionForExistingDelegates,
70097009 // before any subsequent state transitions), poll a few times via a
70107010 // dispatch_after as a safety net so the assertion is robust on busy CI.
7011- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(100 * NSEC_PER_MSEC)), queue, ^{
7011+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (100 * NSEC_PER_MSEC)), queue, ^{
70127012 if ([[deviceB valueForKey: @" hasDeferredFirstThreadSubscription" ] boolValue ]) {
70137013 [deferralEnteredOnB fulfill ];
70147014 }
@@ -7092,7 +7092,7 @@ - (void)test058_CachedIPAddressShortCircuitsFirstThreadSubscribeDeferral
70927092 // least one early callback. We accumulate samples and assert the
70937093 // strongest property afterwards: the flag was never observed YES.
70947094 NSMutableArray <NSNumber *> * deferringSamples = [NSMutableArray array ];
7095- os_unfair_lock samplesLock = OS_UNFAIR_LOCK_INIT;
7095+ __block os_unfair_lock samplesLock = OS_UNFAIR_LOCK_INIT;
70967096 delegate.onInternalStateChanged = ^{
70977097 NSNumber * sample = [device valueForKey: @" deferringFirstThreadSubscription" ];
70987098 os_unfair_lock_lock (&samplesLock);
@@ -7275,7 +7275,7 @@ - (void)test059_AdvertisementBeforeSetDelegateDoesNotPoisonDeferralGate
72757275 // _ensureSubscriptionForExistingDelegates before any state callback can
72767276 // fire, so a quick dispatch-after also fulfils the expectation if the
72777277 // initial state-change callback hasn't landed yet on busy CI.
7278- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(100 * NSEC_PER_MSEC)), queue, ^{
7278+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (100 * NSEC_PER_MSEC)), queue, ^{
72797279 if ([[device valueForKey: @" hasDeferredFirstThreadSubscription" ] boolValue ]) {
72807280 [latchSet fulfill ];
72817281 }
@@ -7356,7 +7356,7 @@ - (void)test060_RemoveDeviceDuringDeferralWindowIsSafe
73567356 // Track every Subscribing/Established transition along with a timestamp so
73577357 // we can prove no such transition fired after the removeDevice point.
73587358 NSMutableArray <NSDictionary *> * transitions = [NSMutableArray array ];
7359- os_unfair_lock transitionsLock = OS_UNFAIR_LOCK_INIT;
7359+ __block os_unfair_lock transitionsLock = OS_UNFAIR_LOCK_INIT;
73607360 delegate.onInternalStateChanged = ^{
73617361 MTRInternalDeviceState state = [device _getInternalState ];
73627362 if (state == MTRInternalDeviceStateSubscribing
@@ -7392,7 +7392,7 @@ - (void)test060_RemoveDeviceDuringDeferralWindowIsSafe
73927392 // we'd see a Subscribing transition (or worse, an InitialSubscriptionEstablished)
73937393 // recorded after `removeAt` in the transitions array.
73947394 XCTestExpectation * watchdogElapsed = [self expectationWithDescription: @" Watchdog window has elapsed" ];
7395- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(3 * NSEC_PER_SEC)), queue, ^{
7395+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (3 * NSEC_PER_SEC)), queue, ^{
73967396 [watchdogElapsed fulfill ];
73977397 });
73987398 [self waitForExpectations: @[ watchdogElapsed ] timeout: 10 ];
@@ -7418,10 +7418,12 @@ - (void)test060_RemoveDeviceDuringDeferralWindowIsSafe
74187418 for (NSDictionary * transition in snapshot) {
74197419 XCTAssertNotEqualObjects (transition[@" state" ], @(MTRInternalDeviceStateSubscribing),
74207420 @" Should not have reached Subscribing during the deferral window before removal; "
7421- @" transitions=%@ " , snapshot);
7421+ @" transitions=%@ " ,
7422+ snapshot);
74227423 XCTAssertNotEqualObjects (transition[@" state" ], @(MTRInternalDeviceStateInitialSubscriptionEstablished),
74237424 @" Should not have reached Established during the deferral window before removal; "
7424- @" transitions=%@ " , snapshot);
7425+ @" transitions=%@ " ,
7426+ snapshot);
74257427 }
74267428
74277429 delegate.onInternalStateChanged = nil ;
@@ -7462,7 +7464,7 @@ - (void)test061_WatchdogTimingIsApproximatelyOneSecond
74627464 // Capture the wall-clock instant Subscribing is first observed. We use
74637465 // an atomic-ish dance here: only the first transition sets the date.
74647466 __block NSDate * subscribingAt = nil ;
7465- os_unfair_lock subLock = OS_UNFAIR_LOCK_INIT;
7467+ __block os_unfair_lock subLock = OS_UNFAIR_LOCK_INIT;
74667468 delegate.onInternalStateChanged = ^{
74677469 MTRInternalDeviceState state = [device _getInternalState ];
74687470 if (state == MTRInternalDeviceStateSubscribing) {
@@ -7514,7 +7516,8 @@ - (void)test061_WatchdogTimingIsApproximatelyOneSecond
75147516 // stays well within the budget.
75157517 XCTAssertLessThan (elapsed, 5.0 ,
75167518 @" Subscribing reached in %.3f s after deferral was armed — exceeds the 1s watchdog budget plus generous slack; "
7517- @" a regression in kFirstThreadSubscribeWatchdogNs would land here" , elapsed);
7519+ @" a regression in kFirstThreadSubscribeWatchdogNs would land here" ,
7520+ elapsed);
75187521
75197522 // End-state invariants: the deferring flag must be NO (cleared by the
75207523 // watchdog), the latch must remain YES, and no advertisement was needed.
@@ -7603,7 +7606,7 @@ - (void)test062_MultipleAdvertisementsDuringDeferralWindowOnlyFirstReentersEnsur
76037606 // back to YES (no flag-bouncing).
76047607 // - The latch, once YES, must remain YES (one-shot for the instance).
76057608 NSMutableArray <NSDictionary *> * samples = [NSMutableArray array ];
7606- os_unfair_lock samplesLock = OS_UNFAIR_LOCK_INIT;
7609+ __block os_unfair_lock samplesLock = OS_UNFAIR_LOCK_INIT;
76077610
76087611 XCTestExpectation * established = [self expectationWithDescription: @" Subscription established" ];
76097612 established.assertForOverFulfill = NO ;
@@ -7706,7 +7709,8 @@ - (void)test062_MultipleAdvertisementsDuringDeferralWindowOnlyFirstReentersEnsur
77067709 BOOL deferring = [s[@" deferring" ] boolValue ];
77077710 if (sawDeferringCleared && deferring) {
77087711 XCTFail (@" deferringFirstThreadSubscription transitioned NO->YES after being cleared; "
7709- @" a regression in nodeMayBeAdvertisingOperational re-armed the flag. trace=%@ " , snapshot);
7712+ @" a regression in nodeMayBeAdvertisingOperational re-armed the flag. trace=%@ " ,
7713+ snapshot);
77107714 break ;
77117715 }
77127716 if (!deferring) {
@@ -7722,7 +7726,8 @@ - (void)test062_MultipleAdvertisementsDuringDeferralWindowOnlyFirstReentersEnsur
77227726 BOOL latch = [s[@" latch" ] boolValue ];
77237727 if (sawLatchSet && !latch) {
77247728 XCTFail (@" hasDeferredFirstThreadSubscription transitioned YES->NO; "
7725- @" the latch must be one-shot for the MTRDevice instance's lifetime. trace=%@ " , snapshot);
7729+ @" the latch must be one-shot for the MTRDevice instance's lifetime. trace=%@ " ,
7730+ snapshot);
77267731 break ;
77277732 }
77287733 if (latch) {
@@ -7737,7 +7742,7 @@ - (void)test062_MultipleAdvertisementsDuringDeferralWindowOnlyFirstReentersEnsur
77377742 // strongest "no double-scheduling" assertion we can make from outside.
77387743 XCTAssertEqual (establishedTransitions, 1 ,
77397744 @" Subscription must establish exactly once across multi-advertisement-during-deferral; got %ld " ,
7740- (long )establishedTransitions);
7745+ (long ) establishedTransitions);
77417746
77427747 XCTAssertEqualObjects ([device valueForKey: @" deferringFirstThreadSubscription" ], @NO ,
77437748 @" End state: deferral flag clear" );
@@ -7894,7 +7899,7 @@ - (void)test064_InvalidateClearsFirstThreadSubscribeDeferralFlags
78947899 // Spin past the 1s watchdog deadline and re-sample. If the watchdog
78957900 // misbehaved and somehow set the flag back, we'd see it here.
78967901 XCTestExpectation * pastWatchdog = [self expectationWithDescription: @" Past 1s watchdog deadline" ];
7897- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(1500 * NSEC_PER_MSEC)), queue, ^{
7902+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (1500 * NSEC_PER_MSEC)), queue, ^{
78987903 [pastWatchdog fulfill ];
78997904 });
79007905 [self waitForExpectations: @[ pastWatchdog ] timeout: 5 ];
@@ -7959,7 +7964,7 @@ - (void)test065_SuspendDuringDeferralAbortsWatchdogScheduling
79597964
79607965 // Wait past the 1s watchdog deadline.
79617966 XCTestExpectation * pastWatchdog = [self expectationWithDescription: @" Past 1s watchdog deadline" ];
7962- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(1500 * NSEC_PER_MSEC)), queue, ^{
7967+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (1500 * NSEC_PER_MSEC)), queue, ^{
79637968 [pastWatchdog fulfill ];
79647969 });
79657970 [self waitForExpectations: @[ pastWatchdog ] timeout: 5 ];
@@ -7974,7 +7979,7 @@ - (void)test065_SuspendDuringDeferralAbortsWatchdogScheduling
79747979 XCTAssertEqual (subscribingTransitionsAfterSuspend, 0 ,
79757980 @" Watchdog firing while subscriptions are not allowed must not schedule pool work; "
79767981 @" observed %ld Subscribing transitions" ,
7977- (long )subscribingTransitionsAfterSuspend);
7982+ (long ) subscribingTransitionsAfterSuspend);
79787983
79797984 // The deferring flag must end at NO regardless of which branch caught it.
79807985 XCTAssertEqualObjects ([device valueForKey: @" deferringFirstThreadSubscription" ], @NO ,
@@ -8155,7 +8160,7 @@ - (void)test_FirstThreadSubscribe_RecentReportShortCircuitsGate
81558160 // still NO. If the short-circuit had failed and the gate had armed the
81568161 // watchdog, we'd observe deferring == YES throughout this interval.
81578162 XCTestExpectation * sampled = [self expectationWithDescription: @" Deferral never arms post-recent-report" ];
8158- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(200 * NSEC_PER_MSEC)), queue, ^{
8163+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (200 * NSEC_PER_MSEC)), queue, ^{
81598164 [sampled fulfill ];
81608165 });
81618166 [self waitForExpectations: @[ sampled ] timeout: 5 ];
@@ -8477,7 +8482,7 @@ - (void)test_FirstThreadSubscribe_GatedDuringInterfaceColdStart
84778482 // already be MTRInternalDeviceStateSubscribing and the errno 65
84788483 // send would have already happened).
84798484 XCTestExpectation * earlySample = [self expectationWithDescription: @" Sampled state within 100ms of setDelegate" ];
8480- dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t )(50 * NSEC_PER_MSEC)), queue, ^{
8485+ dispatch_after (dispatch_time (DISPATCH_TIME_NOW, (int64_t ) (50 * NSEC_PER_MSEC)), queue, ^{
84818486 [earlySample fulfill ];
84828487 });
84838488 [self waitForExpectations: @[ earlySample ] timeout: 5 ];
@@ -8555,7 +8560,7 @@ - (void)test_FirstThreadSubscribe_AvoidsErrno65WastedBackoff
85558560 // observed. Only the FIRST transition counts — re-entries during a
85568561 // subsequent re-subscribe cycle don't represent the first SubscribeRequest.
85578562 __block NSDate * firstSubscribingAt = nil ;
8558- os_unfair_lock subLock = OS_UNFAIR_LOCK_INIT;
8563+ __block os_unfair_lock subLock = OS_UNFAIR_LOCK_INIT;
85598564 delegate.onInternalStateChanged = ^{
85608565 if ([device _getInternalState ] != MTRInternalDeviceStateSubscribing) {
85618566 return ;
@@ -8612,7 +8617,8 @@ - (void)test_FirstThreadSubscribe_AvoidsErrno65WastedBackoff
86128617 // breadcrumb if a regression sneaks below the 100ms floor above.
86138618 if (elapsed < 0.9 ) {
86148619 NSLog (@" [test_FirstThreadSubscribe_AvoidsErrno65WastedBackoff] elapsed=%.3f s <0.9s — "
8615- @" likely advertisement-release path; relying on >=100ms lower bound" , elapsed);
8620+ @" likely advertisement-release path; relying on >=100ms lower bound" ,
8621+ elapsed);
86168622 } else {
86178623 XCTAssertGreaterThanOrEqual (elapsed, 0.9 ,
86188624 @" Watchdog-release path must have held the gate for ~1s (observed %.3f s)" , elapsed);
0 commit comments