Skip to content

Commit

Permalink
Enable -Wconversion tree-wide on darwin. (project-chip#25376)
Browse files Browse the repository at this point in the history
* Enable -Wconversion tree-wide on darwin.

* Also fix mbedtls, since apparently someone is building with that on Darwin.
  • Loading branch information
bzbarsky-apple authored and David Lechner committed Mar 22, 2023
1 parent 7ae44af commit 90500d6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 5 deletions.
4 changes: 4 additions & 0 deletions build/config/compiler/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ config("strict_warnings") {
]
}

if (current_os == "mac" || current_os == "ios") {
cflags += [ "-Wconversion" ]
}

if (build_java_matter_controller) {
cflags -= [ "-Wshadow" ]
}
Expand Down
5 changes: 3 additions & 2 deletions src/crypto/CHIPCryptoPALmbedTLS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1445,8 +1445,9 @@ CHIP_ERROR VerifyAttestationCertificateFormat(const ByteSpan & cert, Attestation
{
bool keyCertSignFlag = keyUsage & MBEDTLS_X509_KU_KEY_CERT_SIGN;
bool crlSignFlag = keyUsage & MBEDTLS_X509_KU_CRL_SIGN;
bool otherFlags =
keyUsage & ~(MBEDTLS_X509_KU_CRL_SIGN | MBEDTLS_X509_KU_KEY_CERT_SIGN | MBEDTLS_X509_KU_DIGITAL_SIGNATURE);
bool otherFlags = keyUsage &
~static_cast<unsigned int>(MBEDTLS_X509_KU_CRL_SIGN | MBEDTLS_X509_KU_KEY_CERT_SIGN |
MBEDTLS_X509_KU_DIGITAL_SIGNATURE);
VerifyOrExit(keyCertSignFlag && crlSignFlag && !otherFlags, error = CHIP_ERROR_INTERNAL);
}
}
Expand Down
5 changes: 4 additions & 1 deletion third_party/boringssl/repo/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import("BUILD.generated.gni")
config("boringssl_config") {
include_dirs = [ "src/include" ]

cflags = [ "-Wno-unused-variable" ]
cflags = [
"-Wno-unused-variable",
"-Wno-conversion",
]

if (is_clang) {
cflags += [ "-Wno-shorten-64-to-32" ]
Expand Down
4 changes: 3 additions & 1 deletion third_party/editline/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import("${build_root}/config/compiler/compiler.gni")
config("editline_config") {
include_dirs = [ "repo/include" ]

cflags = [ "-Wno-conversion" ]

if (is_clang) {
cflags = [ "-Wno-shorten-64-to-32" ]
cflags += [ "-Wno-shorten-64-to-32" ]
}
}

Expand Down
1 change: 1 addition & 0 deletions third_party/mbedtls/mbedtls.gni
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ template("mbedtls_target") {
"-Wno-string-concatenation",
"-Wno-unused-but-set-parameter",
"-Wno-format-nonliteral", # Because of mbedtls_debug_print_msg
"-Wno-conversion", # Lots of -Wconversion warnings, sadly.
]

if (is_clang) {
Expand Down
4 changes: 3 additions & 1 deletion third_party/nlunit-test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import("${build_root}/config/compiler/compiler.gni")
config("nlunit-test_config") {
include_dirs = [ "repo/src" ]

cflags = [ "-Wno-conversion" ]

if (is_clang) {
cflags = [ "-Wno-shorten-64-to-32" ]
cflags += [ "-Wno-shorten-64-to-32" ]
}
}

Expand Down

0 comments on commit 90500d6

Please sign in to comment.