diff --git a/.github/workflows/darwin.yaml b/.github/workflows/darwin.yaml index 7011285bf64dc4..0219bb309c1963 100644 --- a/.github/workflows/darwin.yaml +++ b/.github/workflows/darwin.yaml @@ -83,10 +83,9 @@ jobs: # enable it for various reasons. Keep whatever Xcode settings # for OTHER_CFLAGS exist by using ${inherited}. # - # Disable -Wmacro-redefined because CHIP_DEVICE_CONFIG_ENABLE_MDNS - # seems to be unconditionally defined in CHIPDeviceBuildConfig.h, - # which is apparently being included after CHIPDeviceConfig.h. - run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-macro-redefined' + # Enable -Wconversion by hand as well, because it seems to not be + # enabled by default in the Xcode config. + run: xcodebuild -target "Matter" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion' working-directory: src/darwin/Framework - name: Clean Build run: xcodebuild clean @@ -111,7 +110,7 @@ jobs: run: | mkdir -p /tmp/darwin/framework-tests ../../../out/debug/chip-all-clusters-app --interface-id -1 > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) & - xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wno-incomplete-umbrella' > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2) + xcodebuild test -target "Matter" -scheme "Matter Framework Tests" -sdk macosx OTHER_CFLAGS='${inherited} -Werror -Wconversion -Wno-incomplete-umbrella' > >(tee /tmp/darwin/framework-tests/darwin-tests.log) 2> >(tee /tmp/darwin/framework-tests/darwin-tests-err.log >&2) working-directory: src/darwin/Framework - name: Uploading log files uses: actions/upload-artifact@v2 diff --git a/src/darwin/Framework/CHIP/MTRSetupPayload.mm b/src/darwin/Framework/CHIP/MTRSetupPayload.mm index 9e202b2f915094..3c026cfb68e850 100644 --- a/src/darwin/Framework/CHIP/MTRSetupPayload.mm +++ b/src/darwin/Framework/CHIP/MTRSetupPayload.mm @@ -148,8 +148,10 @@ - (void)encodeWithCoder:(NSCoder *)coder [coder encodeObject:self.version forKey:MTRSetupPayloadCodingKeyVersion]; [coder encodeObject:self.vendorID forKey:MTRSetupPayloadCodingKeyVendorID]; [coder encodeObject:self.productID forKey:MTRSetupPayloadCodingKeyProductID]; - [coder encodeInteger:self.commissioningFlow forKey:MTRSetupPayloadCodingKeyCommissioningFlow]; - [coder encodeInteger:self.rendezvousInformation forKey:MTRSetupPayloadCodingKeyRendezvousFlags]; + // Casts are safe because commissioning flow and rendezvous information + // values are all pretty small and non-negative. + [coder encodeInteger:static_cast(self.commissioningFlow) forKey:MTRSetupPayloadCodingKeyCommissioningFlow]; + [coder encodeInteger:static_cast(self.rendezvousInformation) forKey:MTRSetupPayloadCodingKeyRendezvousFlags]; [coder encodeObject:self.discriminator forKey:MTRSetupPayloadCodingKeyDiscriminator]; [coder encodeObject:self.setUpPINCode forKey:MTRSetupPayloadCodingKeySetupPINCode]; [coder encodeObject:self.serialNumber forKey:MTRSetupPayloadCodingKeySerialNumber]; @@ -160,8 +162,8 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder NSNumber * version = [decoder decodeObjectOfClass:[NSNumber class] forKey:MTRSetupPayloadCodingKeyVersion]; NSNumber * vendorID = [decoder decodeObjectOfClass:[NSNumber class] forKey:MTRSetupPayloadCodingKeyVendorID]; NSNumber * productID = [decoder decodeObjectOfClass:[NSNumber class] forKey:MTRSetupPayloadCodingKeyProductID]; - NSUInteger commissioningFlow = [decoder decodeIntegerForKey:MTRSetupPayloadCodingKeyCommissioningFlow]; - NSUInteger rendezvousInformation = [decoder decodeIntegerForKey:MTRSetupPayloadCodingKeyRendezvousFlags]; + NSInteger commissioningFlow = [decoder decodeIntegerForKey:MTRSetupPayloadCodingKeyCommissioningFlow]; + NSInteger rendezvousInformation = [decoder decodeIntegerForKey:MTRSetupPayloadCodingKeyRendezvousFlags]; NSNumber * discriminator = [decoder decodeObjectOfClass:[NSNumber class] forKey:MTRSetupPayloadCodingKeyDiscriminator]; NSNumber * setUpPINCode = [decoder decodeObjectOfClass:[NSNumber class] forKey:MTRSetupPayloadCodingKeySetupPINCode]; NSString * serialNumber = [decoder decodeObjectOfClass:[NSString class] forKey:MTRSetupPayloadCodingKeySerialNumber]; @@ -170,8 +172,8 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder payload.version = version; payload.vendorID = vendorID; payload.productID = productID; - payload.commissioningFlow = (MTRCommissioningFlow) commissioningFlow; - payload.rendezvousInformation = (MTRRendezvousInformationFlags) rendezvousInformation; + payload.commissioningFlow = static_cast(commissioningFlow); + payload.rendezvousInformation = static_cast(rendezvousInformation); payload.discriminator = discriminator; payload.setUpPINCode = setUpPINCode; payload.serialNumber = serialNumber; diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 676fb31eba184f..ee9e61a22d06c9 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1321,7 +1321,7 @@ - (void)testOctetString - (void)testFloat { NSDictionary * input = - [NSDictionary dictionaryWithObjectsAndKeys:@"Float", @"type", [NSNumber numberWithFloat:0.1245], @"value", nil]; + [NSDictionary dictionaryWithObjectsAndKeys:@"Float", @"type", [NSNumber numberWithFloat:0.1245f], @"value", nil]; id output = [MTRBaseDevice CHIPEncodeAndDecodeNSObject:input]; NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); @@ -1333,7 +1333,7 @@ - (void)testFloat - (void)testDouble { NSDictionary * input = - [NSDictionary dictionaryWithObjectsAndKeys:@"Double", @"type", [NSNumber numberWithFloat:0.1245], @"value", nil]; + [NSDictionary dictionaryWithObjectsAndKeys:@"Double", @"type", [NSNumber numberWithDouble:0.1245], @"value", nil]; id output = [MTRBaseDevice CHIPEncodeAndDecodeNSObject:input]; NSLog(@"Conversion input: %@\nOutput: %@", input, output); XCTAssertNotNil(output); diff --git a/src/darwin/Framework/CHIPTests/MTRErrorTestUtils.mm b/src/darwin/Framework/CHIPTests/MTRErrorTestUtils.mm index 68eaa3adf98040..24ee02dd7d12bc 100644 --- a/src/darwin/Framework/CHIPTests/MTRErrorTestUtils.mm +++ b/src/darwin/Framework/CHIPTests/MTRErrorTestUtils.mm @@ -38,7 +38,7 @@ + (uint8_t)errorToZCLErrorCode:(NSError * _Nullable)error return EMBER_ZCL_STATUS_FAILURE; } - return error.code; + return static_cast(error.code); } @end diff --git a/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m b/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m index 017313aad905fd..c029f9479b7dd2 100644 --- a/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m +++ b/src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m @@ -2062,15 +2062,15 @@ - (void)testMutiSubscriptions _xpcDisconnectExpectation = [self expectationWithDescription:@"XPC Disconnected"]; // Multi-subscriptions - for (int i = 0; i < 2; i++) { + for (unsigned int i = 0; i < 2; i++) { myNodeId = nodeIds[i]; myEndpointId = endpointIds[i]; myClusterId = clusterIds[i]; myAttributeId = attributeIds[i]; myMinInterval = minIntervals[i]; myMaxInterval = maxIntervals[i]; - callExpectation = [self expectationWithDescription:[NSString stringWithFormat:@"XPC call (%d) received", i]]; - establishExpectation = [self expectationWithDescription:[NSString stringWithFormat:@"Established (%d) called", i]]; + callExpectation = [self expectationWithDescription:[NSString stringWithFormat:@"XPC call (%u) received", i]]; + establishExpectation = [self expectationWithDescription:[NSString stringWithFormat:@"Established (%u) called", i]]; [_remoteDeviceController getBaseDevice:myNodeId queue:dispatch_get_main_queue() @@ -2122,7 +2122,7 @@ - (void)testMutiSubscriptions @"data" : @ { @"type" : @"SignedInteger", @"value" : [NSNumber numberWithInteger:123457 + count * 100] } } ] ]; - for (int i = 0; i < 2; i++) { + for (unsigned int i = 0; i < 2; i++) { NSUInteger nodeId = nodeIds[i]; dispatch_async(dispatch_get_main_queue(), ^{ [clientObject handleReportWithController:uuid @@ -2180,7 +2180,7 @@ - (void)testMutiSubscriptions @"data" : @ { @"type" : @"SignedInteger", @"value" : [NSNumber numberWithInteger:223457 + count * 100] } } ] ]; - for (int i = 0; i < 2; i++) { + for (unsigned int i = 0; i < 2; i++) { NSUInteger nodeId = nodeIds[i]; dispatch_async(dispatch_get_main_queue(), ^{ [clientObject handleReportWithController:uuid @@ -2242,7 +2242,7 @@ - (void)testMutiSubscriptions @"data" : @ { @"type" : @"SignedInteger", @"value" : [NSNumber numberWithInteger:223457 + count * 100] } } ] ]; - for (int i = 0; i < 2; i++) { + for (unsigned int i = 0; i < 2; i++) { NSUInteger nodeId = nodeIds[i]; dispatch_async(dispatch_get_main_queue(), ^{ [clientObject handleReportWithController:uuid