From a607ca2e2592b3097caeea12c82e5adf70ad2c53 Mon Sep 17 00:00:00 2001 From: Tony Josi Date: Thu, 25 Apr 2024 14:57:49 +0530 Subject: [PATCH] Fix build error with Werror=sign-compare is enabled (#283) Description ----------- This PR fixes a build issue when `Werror=sign-compare` is enabled while building the library. Test Steps ----------- Checklist: ---------- - [x] I have tested my changes. No regression in existing tests. - ~[ ] I have modified and/or added unit-tests to cover the code changes in this Pull Request.~ Related Issue ----------- #282 By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. --- .github/workflows/ci.yml | 2 +- source/core_mqtt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 82a877e9e..6dd9e59c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,7 +32,7 @@ jobs: -DCMAKE_BUILD_TYPE=Debug \ -DBUILD_CLONE_SUBMODULES=ON \ -DUNITTEST=1 \ - -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Werror -DNDEBUG -DLIBRARY_LOG_LEVEL=LOG_DEBUG' + -DCMAKE_C_FLAGS='--coverage -Wall -Wextra -Wsign-compare -Werror -DNDEBUG -DLIBRARY_LOG_LEVEL=LOG_DEBUG' make -C build/ all echo "::endgroup::" diff --git a/source/core_mqtt.c b/source/core_mqtt.c index 92a93b697..419fd6b27 100644 --- a/source/core_mqtt.c +++ b/source/core_mqtt.c @@ -2217,7 +2217,7 @@ static MQTTStatus_t sendConnectWithoutCopy( MQTTContext_t * pContext, pWillInfo, remainingLength ); - assert( ( pIndex - connectPacketHeader ) <= sizeof( connectPacketHeader ) ); + assert( ( ( size_t ) ( pIndex - connectPacketHeader ) ) <= sizeof( connectPacketHeader ) ); /* The header gets sent first. */ iterator->iov_base = connectPacketHeader;