fixeria has uploaded this change for review. (
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
Recent commit 0f59cebf had a problem with passing signed and unsigned
values to OSMO_MIN, what caused tons of -Wsign-compare warnings being
printed for each *.c file including <osmocom/core/utils.h>.
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 has always been the case before 0f59cebf.
And somehow this did not show up when building libosmocore.git,
but only for projects written in C++ (osmo-pcu and osmo-trx).
Perhaps it has something to do with how g++ compules 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, 31 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/74/35474/1
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: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange