Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -Wconversion in Darwin framework CI. #20891

Merged
merged 1 commit into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 8 additions & 6 deletions src/darwin/Framework/CHIP/MTRSetupPayload.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSInteger>(self.commissioningFlow) forKey:MTRSetupPayloadCodingKeyCommissioningFlow];
[coder encodeInteger:static_cast<NSInteger>(self.rendezvousInformation) forKey:MTRSetupPayloadCodingKeyRendezvousFlags];
[coder encodeObject:self.discriminator forKey:MTRSetupPayloadCodingKeyDiscriminator];
[coder encodeObject:self.setUpPINCode forKey:MTRSetupPayloadCodingKeySetupPINCode];
[coder encodeObject:self.serialNumber forKey:MTRSetupPayloadCodingKeySerialNumber];
Expand All @@ -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];
Expand All @@ -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<MTRCommissioningFlow>(commissioningFlow);
payload.rendezvousInformation = static_cast<MTRRendezvousInformationFlags>(rendezvousInformation);
payload.discriminator = discriminator;
payload.setUpPINCode = setUpPINCode;
payload.serialNumber = serialNumber;
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIPTests/MTRDeviceTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIPTests/MTRErrorTestUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ + (uint8_t)errorToZCLErrorCode:(NSError * _Nullable)error
return EMBER_ZCL_STATUS_FAILURE;
}

return error.code;
return static_cast<uint8_t>(error.code);
}
@end

Expand Down
12 changes: 6 additions & 6 deletions src/darwin/Framework/CHIPTests/MTRXPCProtocolTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down