From 4c5cc5e59148229353ccf87bf84c0f86e069a07a Mon Sep 17 00:00:00 2001 From: Michael Graeb Date: Tue, 21 Nov 2023 09:56:12 -0800 Subject: [PATCH] CI checks for C compiler warnings (#528) Previously, we only checked for C compiler warnings when doing a local "development" build (`pip install --editable .`). Now, we also check in CI. Co-authored-by: Bret Ambrose --- builder.json | 3 +++ setup.py | 9 +++++++-- source/mqtt5_client.c | 5 ++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/builder.json b/builder.json index c2e186c31..958e87b57 100644 --- a/builder.json +++ b/builder.json @@ -3,6 +3,9 @@ "!cmake_args": [ "-DS2N_NO_PQ_ASM=ON" ], + "env": { + "AWS_CRT_BUILD_WARNINGS_ARE_ERRORS": "1" + }, "hosts": { "manylinux": { "_comment": "Use existing compiler on manylinux. These are the images we use for release. We want to be sure things work with the defaults.", diff --git a/setup.py b/setup.py index 0b106b2c4..5442777c3 100644 --- a/setup.py +++ b/setup.py @@ -353,14 +353,19 @@ def awscrt_ext(): extra_compile_args += ['-Wno-strict-aliasing', '-std=gnu99'] # treat warnings as errors in development mode - if is_development_mode(): + if is_development_mode() or os.getenv('AWS_CRT_BUILD_WARNINGS_ARE_ERRORS') == '1': extra_compile_args += ['-Wextra', '-Werror'] # ...except when we take shortcuts in development mode and don't make # a proper MacOS Universal2 binary. The linker warns us about this, # but WHATEVER. Building everything twice (x86_64 and arm64) takes too long. if not is_macos_universal2(): - extra_link_args += ['-Wl,-fatal_warnings'] + if sys.platform == 'darwin': + extra_link_args += ['-Wl,-fatal_warnings'] + elif 'bsd' in sys.platform: + extra_link_args += ['-Wl,-fatal-warnings'] + else: + extra_link_args += ['-Wl,--fatal-warnings'] if sys.version_info >= (3, 11): define_macros.append(('Py_LIMITED_API', '0x030B0000')) diff --git a/source/mqtt5_client.c b/source/mqtt5_client.c index a6d7270ae..c2de1f0fc 100644 --- a/source/mqtt5_client.c +++ b/source/mqtt5_client.c @@ -746,7 +746,7 @@ static bool s_py_topic_aliasing_options_init( py_outbound_behavior, "TopicAliasingOptions", "outbound_behavior", - &topic_aliasing_options->outbound_topic_alias_behavior)) { + (int *)&topic_aliasing_options->outbound_topic_alias_behavior)) { if (PyErr_Occurred()) { goto done; } @@ -766,7 +766,7 @@ static bool s_py_topic_aliasing_options_init( py_inbound_behavior, "TopicAliasingOptions", "inbound_behavior", - &topic_aliasing_options->inbound_topic_alias_behavior)) { + (int *)&topic_aliasing_options->inbound_topic_alias_behavior)) { if (PyErr_Occurred()) { goto done; } @@ -1204,7 +1204,6 @@ PyObject *aws_py_mqtt5_client_new(PyObject *self, PyObject *args) { int will_payload_format_tmp = 0; enum aws_mqtt5_payload_format_indicator will_payload_format_enum_tmp = 0; uint32_t will_message_expiry_interval_seconds_tmp = 0; - uint16_t will_topic_alias_tmp = 0; struct aws_byte_cursor will_correlation_data_tmp; if (!PyObject_IsTrue(is_will_none_py)) { will.qos = PyObject_GetIntEnum(will_qos_val_py, AWS_PYOBJECT_KEY_QOS);