[S] Change in libosmocore[master]: utils: fix -Wsign-compare in definition of OSMO_STRBUF_CHAR_COUNT
fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/35474?usp=email ) Change subject: utils: fix -Wsign-compare in definition of OSMO_STRBUF_CHAR_COUNT ...................................................................... utils: fix -Wsign-compare in definition of OSMO_STRBUF_CHAR_COUNT We're seeing tons of -Wsign-compare warnings since I merged 0f59cebf: include/osmocom/core/utils.h: In function 'size_t _osmo_strbuf_char_count(const osmo_strbuf*)': include/osmocom/core/utils.h:24:29: error: comparison of integer expressions of different signedness: 'long int' and 'long unsigned int' [-Werror=sign-compare] 24 | #define OSMO_MIN(a, b) ((a) >= (b) ? (b) : (a)) | ~~~~^~~~~~ include/osmocom/core/utils.h:309:16: note: in expansion of macro 'OSMO_MIN' 309 | return OSMO_MIN(sb->pos - sb->buf, sb->len - 1); | ^~~~~~~~ Interestingly enough, this -Wsign-compare problem has always been the case, even before commit 0f59cebf. And somehow this did not show up when building libosmocore.git, but only when building C++ projects (osmo-pcu and osmo-trx). Perhaps it has something to do with how g++ compiles extern "C" code. Change-Id: I8e396459409e4260b8715f9e890e8972d4609a31 Fixes: 0f59cebf "utils: improve readability of OSMO_STRBUF_CHAR_COUNT" --- M include/osmocom/core/utils.h 1 file changed, 30 insertions(+), 1 deletion(-) Approvals: fixeria: Looks good to me, approved Jenkins Builder: Verified diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 9a6e6b2..92bea59 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -306,7 +306,7 @@ return 0; if (sb->pos == NULL || sb->pos <= sb->buf) return 0; - return OSMO_MIN(sb->pos - sb->buf, sb->len - 1); + return OSMO_MIN((size_t)(sb->pos - sb->buf), sb->len - 1); } /*! Return number of actual characters contained in struct osmo_strbuf (without terminating nul). */ -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/35474?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I8e396459409e4260b8715f9e890e8972d4609a31 Gerrit-Change-Number: 35474 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy@sysmocom.de> Gerrit-MessageType: merged
participants (1)
-
fixeria