[S] Change in openvpn[master]: mbuf: Fix conversion warnings in mbuf and related code
"cron2 \(Code Review\) via Openvpn-devel" <[email protected]>
| Newsgroups | gmane.network.openvpn.devel |
|---|---|
| Message-ID | <[email protected]> |
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1433?usp=email ) Change subject: mbuf: Fix conversion warnings in mbuf and related code ...................................................................... mbuf: Fix conversion warnings in mbuf and related code Mostly these were actually hidden by casts, but fix them as well by using more fitting types. Change-Id: I1d4e0233cf1cb09725dbd2caa121acdbf62f0452 Signed-off-by: Frank Lichtenheld <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1433 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg37182.html Signed-off-by: Gert Doering <[email protected]> --- M src/openvpn/buffer.c M src/openvpn/mbuf.c 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/src/openvpn/buffer.c b/src/openvpn/buffer.c index 1e19137..5f2b233 100644 --- a/src/openvpn/buffer.c +++ b/src/openvpn/buffer.c @@ -43,7 +43,7 @@ unsigned long long res = (unsigned long long)m1 * (unsigned long long)m2 + (unsigned long long)extra; if (unlikely(m1 > limit) || unlikely(m2 > limit) || unlikely(extra > limit) - || unlikely(res > (unsigned long long)limit)) + || unlikely(res > limit)) { msg(M_FATAL, "attempted allocation of excessively large array"); } diff --git a/src/openvpn/mbuf.c b/src/openvpn/mbuf.c index 5e1b585..7b790ed 100644 --- a/src/openvpn/mbuf.c +++ b/src/openvpn/mbuf.c @@ -34,11 +34,6 @@ #include "memdbg.h" -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#endif - struct mbuf_set * mbuf_init(unsigned int size) { @@ -46,22 +41,17 @@ struct mbuf_set *ret; ALLOC_OBJ_CLEAR(ret, struct mbuf_set); - ret->capacity = adjust_power_of_2(size); + ret->capacity = (unsigned int)adjust_power_of_2(size); ALLOC_ARRAY(ret->array, struct mbuf_item, ret->capacity); return ret; } -#if defined(__GNUC__) || defined(__clang__) -#pragma GCC diagnostic pop -#endif - void mbuf_free(struct mbuf_set *ms) { if (ms) { - int i; - for (i = 0; i < (int)ms->len; ++i) + for (unsigned int i = 0; i < ms->len; ++i) { struct mbuf_item *item = &ms->array[MBUF_INDEX(ms->head, i, ms->capacity)]; mbuf_free_buf(item->buffer); @@ -145,8 +135,7 @@ struct multi_instance *ret = NULL; if (ms) { - int i; - for (i = 0; i < (int)ms->len; ++i) + for (unsigned int i = 0; i < ms->len; ++i) { struct mbuf_item *item = &ms->array[MBUF_INDEX(ms->head, i, ms->capacity)]; if (item->instance) @@ -164,8 +153,7 @@ { if (ms) { - int i; - for (i = 0; i < (int)ms->len; ++i) + for (unsigned int i = 0; i < ms->len; ++i) { struct mbuf_item *item = &ms->array[MBUF_INDEX(ms->head, i, ms->capacity)]; if (item->instance == mi) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/1433?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I1d4e0233cf1cb09725dbd2caa121acdbf62f0452 Gerrit-Change-Number: 1433 Gerrit-PatchSet: 7 Gerrit-Owner: flichtenheld <[email protected]> Gerrit-Reviewer: cron2 <[email protected]> Gerrit-Reviewer: plaisthos <[email protected]> Gerrit-CC: openvpn-devel <[email protected]> _______________________________________________ Openvpn-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openvpn-devel