Skip to content

Commit e8f1afc

Browse files
Remove the MTR_PER_CONTROLLER_STORAGE_ENABLED define.
This is now enabled unconditionally. Also allows us to remove the wrapper headers we had to allow us to use the per-controller storage bits internally.
1 parent 9e0f288 commit e8f1afc

24 files changed

+4
-180
lines changed

.github/workflows/darwin.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ jobs:
7575
options: # We don't need a full matrix
7676
- flavor: asan
7777
arguments: -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES
78-
- flavor: asan-global-storage
79-
arguments: -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES
80-
defines: MTR_PER_CONTROLLER_STORAGE_ENABLED=0
8178
- flavor: tsan
8279
arguments: -enableThreadSanitizer YES
8380
steps:

src/darwin/Framework/CHIP/MTRDefines.h

-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@
102102
#define MTR_UNSTABLE_API _MTR_UNAVAILABLE
103103
#endif
104104

105-
#ifndef MTR_PER_CONTROLLER_STORAGE_ENABLED
106-
#define MTR_PER_CONTROLLER_STORAGE_ENABLED 1
107-
#endif
108-
109105
#pragma mark - Types
110106

111107
typedef NSData * MTRTLVBytes;

src/darwin/Framework/CHIP/MTRDeviceController.h

-6
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
@class MTRBaseDevice;
2525
@class MTRServerEndpoint; // Defined in MTRServerEndpoint.h, which imports MTRAccessGrant.h, which imports MTRBaseClusters.h, which imports this file, so we can't import it.
2626

27-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
2827
@class MTRDeviceControllerAbstractParameters;
29-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
3028

3129
NS_ASSUME_NONNULL_BEGIN
3230

@@ -49,7 +47,6 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
4947
- (instancetype)init NS_UNAVAILABLE;
5048
+ (instancetype)new NS_UNAVAILABLE;
5149

52-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
5350
/**
5451
* Initialize a device controller with the provided parameters. This will:
5552
*
@@ -62,19 +59,16 @@ MTR_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1))
6259
*/
6360
- (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParameters *)parameters
6461
error:(NSError * __autoreleasing *)error MTR_NEWLY_AVAILABLE;
65-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
6662

6763
/**
6864
* If true, the controller has not been shut down yet.
6965
*/
7066
@property (readonly, nonatomic, getter=isRunning) BOOL running;
7167

72-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
7368
/**
7469
* The ID assigned to this controller at creation time.
7570
*/
7671
@property (readonly, nonatomic) NSUUID * uniqueIdentifier MTR_NEWLY_AVAILABLE;
77-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
7872

7973
/**
8074
* Return the Node ID assigned to the controller. Will return nil if the

src/darwin/Framework/CHIP/MTRDeviceController.mm

-9
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,7 @@
1515
* limitations under the License.
1616
*/
1717
#import <Matter/MTRDefines.h>
18-
19-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
2018
#import <Matter/MTRDeviceControllerParameters.h>
21-
#else
22-
#import "MTRDeviceControllerParameters_Wrapper.h"
23-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
2419

2520
#import "MTRDeviceController_Internal.h"
2621

@@ -169,19 +164,16 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
169164
}
170165

171166
id<MTRDeviceControllerStorageDelegate> storageDelegateToUse = storageDelegate;
172-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
173167
if (MTRDeviceControllerLocalTestStorage.localTestStorageEnabled) {
174168
storageDelegateToUse = [[MTRDeviceControllerLocalTestStorage alloc] initWithPassThroughStorage:storageDelegate];
175169
}
176-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
177170
_controllerDataStore = [[MTRDeviceControllerDataStore alloc] initWithController:self
178171
storageDelegate:storageDelegateToUse
179172
storageDelegateQueue:storageDelegateQueue];
180173
if (_controllerDataStore == nil) {
181174
return nil;
182175
}
183176
} else {
184-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
185177
if (MTRDeviceControllerLocalTestStorage.localTestStorageEnabled) {
186178
dispatch_queue_t localTestStorageQueue = dispatch_queue_create("org.csa-iot.matter.framework.devicecontroller.localteststorage", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
187179
MTRDeviceControllerLocalTestStorage * localTestStorage = [[MTRDeviceControllerLocalTestStorage alloc] initWithPassThroughStorage:nil];
@@ -192,7 +184,6 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
192184
return nil;
193185
}
194186
}
195-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
196187
}
197188

198189
// Ensure the otaProviderDelegate, if any, is valid.

src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@
1717
#import <Foundation/Foundation.h>
1818
#import <Matter/MTRDefines.h>
1919
#import <Matter/MTRDeviceController.h>
20-
#import <Matter/MTRDevice_Internal.h>
21-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
2220
#import <Matter/MTRDeviceControllerStorageDelegate.h>
23-
#else
24-
#import "MTRDeviceControllerStorageDelegate_Wrapper.h"
25-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
21+
#import <Matter/MTRDevice_Internal.h>
2622

2723
#include <lib/core/CHIPError.h>
2824

src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm

+1-6
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,8 @@
1919

2020
#import <Matter/MTRDefines.h>
2121

22-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
23-
#import <Matter/MTRDeviceControllerParameters.h>
24-
#else
25-
#import "MTRDeviceControllerParameters_Wrapper.h"
26-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
27-
2822
#import <Matter/MTRClusterConstants.h>
23+
#import <Matter/MTRDeviceControllerParameters.h>
2924
#import <Matter/MTRServerCluster.h>
3025

3126
#import "MTRCertificates.h"

src/darwin/Framework/CHIP/MTRDeviceControllerFactory_Internal.h

+1-6
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,10 @@
2424
#import <Matter/MTRBaseDevice.h> // for MTRClusterPath
2525
#import <Matter/MTRDefines.h>
2626
#import <Matter/MTRDeviceController.h>
27+
#import <Matter/MTRDeviceControllerParameters.h>
2728
#import <Matter/MTRDiagnosticLogsType.h>
2829
#import <Matter/MTRServerEndpoint.h>
2930

30-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
31-
#import <Matter/MTRDeviceControllerParameters.h>
32-
#else
33-
#import "MTRDeviceControllerParameters_Wrapper.h"
34-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
35-
3631
#import "MTRDeviceControllerFactory.h"
3732

3833
#include <lib/core/CHIPPersistentStorageDelegate.h>

src/darwin/Framework/CHIP/MTRDeviceControllerLocalTestStorage.h

-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#import <Foundation/Foundation.h>
1919
#import <Matter/Matter.h>
2020

21-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
22-
2321
NS_ASSUME_NONNULL_BEGIN
2422

2523
MTR_EXTERN MTR_EXPORT @interface MTRDeviceControllerLocalTestStorage : NSObject<MTRDeviceControllerStorageDelegate>
@@ -33,5 +31,3 @@ MTR_EXTERN MTR_EXPORT @interface MTRDeviceControllerLocalTestStorage : NSObject<
3331
@end
3432

3533
NS_ASSUME_NONNULL_END
36-
37-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

src/darwin/Framework/CHIP/MTRDeviceControllerLocalTestStorage.mm

-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
#import "MTRDeviceControllerLocalTestStorage.h"
1919
#import "MTRLogging_Internal.h"
2020

21-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
22-
2321
static NSString * const kLocalTestUserDefaultDomain = @"org.csa-iot.matter.darwintest";
2422
static NSString * const kLocalTestUserDefaultEnabledKey = @"enableTestStorage";
2523

@@ -115,5 +113,3 @@ - (BOOL)controller:(MTRDeviceController *)controller
115113
}
116114
}
117115
@end
118-
119-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

src/darwin/Framework/CHIP/MTRDeviceControllerParameters.h

-14
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616

1717
#import <Matter/MTRDefines.h>
1818

19-
#if defined(MTR_INTERNAL_INCLUDE) && defined(MTR_INCLUDED_FROM_UMBRELLA_HEADER)
20-
#error Internal includes should not happen from the umbrella header
21-
#endif
22-
23-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)
24-
2519
#import <Matter/MTRDeviceControllerStorageDelegate.h>
2620
#import <Matter/MTROTAProviderDelegate.h>
2721

@@ -32,9 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
3226
* interfaces inheriting from this one should be used to actually do the
3327
* initialization.
3428
*/
35-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
3629
MTR_NEWLY_AVAILABLE
37-
#endif
3830
@interface MTRDeviceControllerAbstractParameters : NSObject
3931
- (instancetype)init NS_UNAVAILABLE;
4032
+ (instancetype)new NS_UNAVAILABLE;
@@ -44,9 +36,7 @@ MTR_NEWLY_AVAILABLE
4436
* Parameters that can be used to initialize an MTRDeviceController which
4537
* has a node identity.
4638
*/
47-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
4839
MTR_NEWLY_AVAILABLE
49-
#endif
5040
@interface MTRDeviceControllerParameters : MTRDeviceControllerAbstractParameters
5141

5242
/**
@@ -89,9 +79,7 @@ MTR_NEWLY_AVAILABLE
8979

9080
@end
9181

92-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
9382
MTR_NEWLY_AVAILABLE
94-
#endif
9583
@interface MTRDeviceControllerExternalCertificateParameters : MTRDeviceControllerParameters
9684

9785
- (instancetype)init NS_UNAVAILABLE;
@@ -142,5 +130,3 @@ MTR_NEWLY_AVAILABLE
142130
@end
143131

144132
NS_ASSUME_NONNULL_END
145-
146-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)

src/darwin/Framework/CHIP/MTRDeviceControllerParameters_Wrapper.h

-25
This file was deleted.

src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm

-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
#import "MTRP256KeypairBridge.h"
2424
#import "NSDataSpanConversion.h"
2525

26-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
2726
#import <Matter/MTRDeviceControllerStorageDelegate.h>
28-
#else
29-
#import "MTRDeviceControllerStorageDelegate_Wrapper.h"
30-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
3127

3228
#include <controller/OperationalCredentialsDelegate.h>
3329
#include <credentials/CHIPCert.h>

src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams_Internal.h

-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
#import <Foundation/Foundation.h>
2121
#import <Matter/MTRDefines.h>
2222
#import <Matter/MTRDeviceController.h>
23-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
2423
#import <Matter/MTRDeviceControllerParameters.h>
25-
#else
26-
#import "MTRDeviceControllerParameters_Wrapper.h"
27-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
2824

2925
#include <crypto/CHIPCryptoPAL.h>
3026
#include <lib/core/DataModelTypes.h>

src/darwin/Framework/CHIP/MTRDeviceControllerStorageDelegate.h

-13
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818
#import <Matter/MTRDefines.h>
1919
#import <Matter/MTRDeviceController.h>
2020

21-
#if defined(MTR_INTERNAL_INCLUDE) && defined(MTR_INCLUDED_FROM_UMBRELLA_HEADER)
22-
#error Internal includes should not happen from the umbrella header
23-
#endif
24-
25-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)
26-
2721
NS_ASSUME_NONNULL_BEGIN
2822

2923
typedef NS_ENUM(NSUInteger, MTRStorageSecurityLevel) {
@@ -67,9 +61,7 @@ typedef NS_ENUM(NSUInteger, MTRStorageSharingType) {
6761
* stored and calling MTRDeviceControllerStorageClasses(), is likely to lead
6862
* to deadlocks.
6963
*/
70-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
7164
MTR_NEWLY_AVAILABLE
72-
#endif
7365
@protocol MTRDeviceControllerStorageDelegate <NSObject>
7466
@required
7567
/**
@@ -113,13 +105,8 @@ MTR_NEWLY_AVAILABLE
113105
sharingType:(MTRStorageSharingType)sharingType;
114106
@end
115107

116-
// TODO: FIXME: Is this a sane place to put this API?
117-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
118108
MTR_EXTERN MTR_NEWLY_AVAILABLE
119-
#endif
120109
NSSet<Class> *
121110
MTRDeviceControllerStorageClasses(void);
122111

123112
NS_ASSUME_NONNULL_END
124-
125-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)

src/darwin/Framework/CHIP/MTRDeviceControllerStorageDelegate_Wrapper.h

-25
This file was deleted.

src/darwin/Framework/CHIP/MTRDeviceController_Internal.h

+1-12
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@
3535

3636
#import <Matter/MTRDefines.h>
3737
#import <Matter/MTRDeviceControllerStartupParams.h>
38-
#import <Matter/MTRDiagnosticLogsType.h>
39-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
4038
#import <Matter/MTRDeviceControllerStorageDelegate.h>
41-
#else
42-
#import "MTRDeviceControllerStorageDelegate_Wrapper.h"
43-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
39+
#import <Matter/MTRDiagnosticLogsType.h>
4440
#import <Matter/MTROTAProviderDelegate.h>
4541

4642
@class MTRDeviceControllerStartupParamsInternal;
@@ -59,13 +55,6 @@ NS_ASSUME_NONNULL_BEGIN
5955

6056
@interface MTRDeviceController ()
6157

62-
#if !MTR_PER_CONTROLLER_STORAGE_ENABLED
63-
/**
64-
* The ID assigned to this controller at creation time.
65-
*/
66-
@property (readonly, nonatomic) NSUUID * uniqueIdentifier;
67-
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
68-
6958
#pragma mark - MTRDeviceControllerFactory methods
7059

7160
/**

src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm

-4
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,8 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller
173173

174174
MTRDeviceController * existingController = _deviceController;
175175
if (existingController != nil) {
176-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
177176
MTR_LOG_ERROR("Cannot associate MTRServerAttribute with controller %@; already associated with controller %@",
178177
controller.uniqueIdentifier, existingController.uniqueIdentifier);
179-
#else
180-
MTR_LOG_ERROR("Cannot associate MTRServerAttribute with controller; already associated with a different controller");
181-
#endif
182178
return NO;
183179
}
184180

src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm

-4
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,8 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller
250250

251251
MTRDeviceController * existingController = _deviceController;
252252
if (existingController != nil) {
253-
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
254253
MTR_LOG_ERROR("Cannot associate MTRServerCluster with controller %@; already associated with controller %@",
255254
controller.uniqueIdentifier, existingController.uniqueIdentifier);
256-
#else
257-
MTR_LOG_ERROR("Cannot associate MTRServerCluster with controller; already associated with a different controller");
258-
#endif
259255
return NO;
260256
}
261257

0 commit comments

Comments
 (0)