Skip to content

Commit

Permalink
Remove the MTR_PER_CONTROLLER_STORAGE_ENABLED define. (project-chip#3…
Browse files Browse the repository at this point in the history
…2956)

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.
  • Loading branch information
bzbarsky-apple authored Apr 12, 2024
1 parent a764531 commit 8b3d008
Show file tree
Hide file tree
Showing 24 changed files with 4 additions and 180 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ jobs:
options: # We don't need a full matrix
- flavor: asan
arguments: -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES
- flavor: asan-global-storage
arguments: -enableAddressSanitizer YES -enableUndefinedBehaviorSanitizer YES
defines: MTR_PER_CONTROLLER_STORAGE_ENABLED=0
- flavor: tsan
arguments: -enableThreadSanitizer YES
steps:
Expand Down
4 changes: 0 additions & 4 deletions src/darwin/Framework/CHIP/MTRDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@
#define MTR_UNSTABLE_API _MTR_UNAVAILABLE
#endif

#ifndef MTR_PER_CONTROLLER_STORAGE_ENABLED
#define MTR_PER_CONTROLLER_STORAGE_ENABLED 1
#endif

#pragma mark - Types

typedef NSData * MTRTLVBytes;
Expand Down
6 changes: 0 additions & 6 deletions src/darwin/Framework/CHIP/MTRDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
@class MTRBaseDevice;
@class MTRServerEndpoint; // Defined in MTRServerEndpoint.h, which imports MTRAccessGrant.h, which imports MTRBaseClusters.h, which imports this file, so we can't import it.

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
@class MTRDeviceControllerAbstractParameters;
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

NS_ASSUME_NONNULL_BEGIN

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

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

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

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
/**
* The ID assigned to this controller at creation time.
*/
@property (readonly, nonatomic) NSUUID * uniqueIdentifier MTR_NEWLY_AVAILABLE;
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

/**
* Return the Node ID assigned to the controller. Will return nil if the
Expand Down
9 changes: 0 additions & 9 deletions src/darwin/Framework/CHIP/MTRDeviceController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@
* limitations under the License.
*/
#import <Matter/MTRDefines.h>

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerParameters.h>
#else
#import "MTRDeviceControllerParameters_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

#import "MTRDeviceController_Internal.h"

Expand Down Expand Up @@ -169,19 +164,16 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
}

id<MTRDeviceControllerStorageDelegate> storageDelegateToUse = storageDelegate;
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
if (MTRDeviceControllerLocalTestStorage.localTestStorageEnabled) {
storageDelegateToUse = [[MTRDeviceControllerLocalTestStorage alloc] initWithPassThroughStorage:storageDelegate];
}
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
_controllerDataStore = [[MTRDeviceControllerDataStore alloc] initWithController:self
storageDelegate:storageDelegateToUse
storageDelegateQueue:storageDelegateQueue];
if (_controllerDataStore == nil) {
return nil;
}
} else {
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
if (MTRDeviceControllerLocalTestStorage.localTestStorageEnabled) {
dispatch_queue_t localTestStorageQueue = dispatch_queue_create("org.csa-iot.matter.framework.devicecontroller.localteststorage", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
MTRDeviceControllerLocalTestStorage * localTestStorage = [[MTRDeviceControllerLocalTestStorage alloc] initWithPassThroughStorage:nil];
Expand All @@ -192,7 +184,6 @@ - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory
return nil;
}
}
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
}

// Ensure the otaProviderDelegate, if any, is valid.
Expand Down
6 changes: 1 addition & 5 deletions src/darwin/Framework/CHIP/MTRDeviceControllerDataStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@
#import <Foundation/Foundation.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
#import <Matter/MTRDevice_Internal.h>
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerStorageDelegate.h>
#else
#import "MTRDeviceControllerStorageDelegate_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDevice_Internal.h>

#include <lib/core/CHIPError.h>

Expand Down
7 changes: 1 addition & 6 deletions src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,8 @@

#import <Matter/MTRDefines.h>

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerParameters.h>
#else
#import "MTRDeviceControllerParameters_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

#import <Matter/MTRClusterConstants.h>
#import <Matter/MTRDeviceControllerParameters.h>
#import <Matter/MTRServerCluster.h>

#import "MTRCertificates.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,10 @@
#import <Matter/MTRBaseDevice.h> // for MTRClusterPath
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
#import <Matter/MTRDeviceControllerParameters.h>
#import <Matter/MTRDiagnosticLogsType.h>
#import <Matter/MTRServerEndpoint.h>

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerParameters.h>
#else
#import "MTRDeviceControllerParameters_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

#import "MTRDeviceControllerFactory.h"

#include <lib/core/CHIPPersistentStorageDelegate.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#import <Foundation/Foundation.h>
#import <Matter/Matter.h>

#if MTR_PER_CONTROLLER_STORAGE_ENABLED

NS_ASSUME_NONNULL_BEGIN

MTR_EXTERN MTR_EXPORT @interface MTRDeviceControllerLocalTestStorage : NSObject<MTRDeviceControllerStorageDelegate>
Expand All @@ -33,5 +31,3 @@ MTR_EXTERN MTR_EXPORT @interface MTRDeviceControllerLocalTestStorage : NSObject<
@end

NS_ASSUME_NONNULL_END

#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#import "MTRDeviceControllerLocalTestStorage.h"
#import "MTRLogging_Internal.h"

#if MTR_PER_CONTROLLER_STORAGE_ENABLED

static NSString * const kLocalTestUserDefaultDomain = @"org.csa-iot.matter.darwintest";
static NSString * const kLocalTestUserDefaultEnabledKey = @"enableTestStorage";

Expand Down Expand Up @@ -115,5 +113,3 @@ - (BOOL)controller:(MTRDeviceController *)controller
}
}
@end

#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
14 changes: 0 additions & 14 deletions src/darwin/Framework/CHIP/MTRDeviceControllerParameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@

#import <Matter/MTRDefines.h>

#if defined(MTR_INTERNAL_INCLUDE) && defined(MTR_INCLUDED_FROM_UMBRELLA_HEADER)
#error Internal includes should not happen from the umbrella header
#endif

#if MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)

#import <Matter/MTRDeviceControllerStorageDelegate.h>
#import <Matter/MTROTAProviderDelegate.h>

Expand All @@ -32,9 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
* interfaces inheriting from this one should be used to actually do the
* initialization.
*/
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_NEWLY_AVAILABLE
#endif
@interface MTRDeviceControllerAbstractParameters : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
Expand All @@ -44,9 +36,7 @@ MTR_NEWLY_AVAILABLE
* Parameters that can be used to initialize an MTRDeviceController which
* has a node identity.
*/
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_NEWLY_AVAILABLE
#endif
@interface MTRDeviceControllerParameters : MTRDeviceControllerAbstractParameters

/**
Expand Down Expand Up @@ -89,9 +79,7 @@ MTR_NEWLY_AVAILABLE

@end

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_NEWLY_AVAILABLE
#endif
@interface MTRDeviceControllerExternalCertificateParameters : MTRDeviceControllerParameters

- (instancetype)init NS_UNAVAILABLE;
Expand Down Expand Up @@ -142,5 +130,3 @@ MTR_NEWLY_AVAILABLE
@end

NS_ASSUME_NONNULL_END

#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)
25 changes: 0 additions & 25 deletions src/darwin/Framework/CHIP/MTRDeviceControllerParameters_Wrapper.h

This file was deleted.

4 changes: 0 additions & 4 deletions src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.mm
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
#import "MTRP256KeypairBridge.h"
#import "NSDataSpanConversion.h"

#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerStorageDelegate.h>
#else
#import "MTRDeviceControllerStorageDelegate_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

#include <controller/OperationalCredentialsDelegate.h>
#include <credentials/CHIPCert.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@
#import <Foundation/Foundation.h>
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerParameters.h>
#else
#import "MTRDeviceControllerParameters_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

#include <crypto/CHIPCryptoPAL.h>
#include <lib/core/DataModelTypes.h>
Expand Down
13 changes: 0 additions & 13 deletions src/darwin/Framework/CHIP/MTRDeviceControllerStorageDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@
#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceController.h>

#if defined(MTR_INTERNAL_INCLUDE) && defined(MTR_INCLUDED_FROM_UMBRELLA_HEADER)
#error Internal includes should not happen from the umbrella header
#endif

#if MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)

NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, MTRStorageSecurityLevel) {
Expand Down Expand Up @@ -67,9 +61,7 @@ typedef NS_ENUM(NSUInteger, MTRStorageSharingType) {
* stored and calling MTRDeviceControllerStorageClasses(), is likely to lead
* to deadlocks.
*/
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_NEWLY_AVAILABLE
#endif
@protocol MTRDeviceControllerStorageDelegate <NSObject>
@required
/**
Expand Down Expand Up @@ -113,13 +105,8 @@ MTR_NEWLY_AVAILABLE
sharingType:(MTRStorageSharingType)sharingType;
@end

// TODO: FIXME: Is this a sane place to put this API?
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_EXTERN MTR_NEWLY_AVAILABLE
#endif
NSSet<Class> *
MTRDeviceControllerStorageClasses(void);

NS_ASSUME_NONNULL_END

#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED || defined(MTR_INTERNAL_INCLUDE)

This file was deleted.

13 changes: 1 addition & 12 deletions src/darwin/Framework/CHIP/MTRDeviceController_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@

#import <Matter/MTRDefines.h>
#import <Matter/MTRDeviceControllerStartupParams.h>
#import <Matter/MTRDiagnosticLogsType.h>
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDeviceControllerStorageDelegate.h>
#else
#import "MTRDeviceControllerStorageDelegate_Wrapper.h"
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED
#import <Matter/MTRDiagnosticLogsType.h>
#import <Matter/MTROTAProviderDelegate.h>

@class MTRDeviceControllerStartupParamsInternal;
Expand All @@ -59,13 +55,6 @@ NS_ASSUME_NONNULL_BEGIN

@interface MTRDeviceController ()

#if !MTR_PER_CONTROLLER_STORAGE_ENABLED
/**
* The ID assigned to this controller at creation time.
*/
@property (readonly, nonatomic) NSUUID * uniqueIdentifier;
#endif // MTR_PER_CONTROLLER_STORAGE_ENABLED

#pragma mark - MTRDeviceControllerFactory methods

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,8 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller

MTRDeviceController * existingController = _deviceController;
if (existingController != nil) {
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_LOG_ERROR("Cannot associate MTRServerAttribute with controller %@; already associated with controller %@",
controller.uniqueIdentifier, existingController.uniqueIdentifier);
#else
MTR_LOG_ERROR("Cannot associate MTRServerAttribute with controller; already associated with a different controller");
#endif
return NO;
}

Expand Down
4 changes: 0 additions & 4 deletions src/darwin/Framework/CHIP/ServerEndpoint/MTRServerCluster.mm
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,8 @@ - (BOOL)associateWithController:(nullable MTRDeviceController *)controller

MTRDeviceController * existingController = _deviceController;
if (existingController != nil) {
#if MTR_PER_CONTROLLER_STORAGE_ENABLED
MTR_LOG_ERROR("Cannot associate MTRServerCluster with controller %@; already associated with controller %@",
controller.uniqueIdentifier, existingController.uniqueIdentifier);
#else
MTR_LOG_ERROR("Cannot associate MTRServerCluster with controller; already associated with a different controller");
#endif
return NO;
}

Expand Down
Loading

0 comments on commit 8b3d008

Please sign in to comment.