Attention is currently required from: Arne Schwabe.

Hello Arne Schwabe,

I'd like you to do a code review.
Please visit

    https://gerrit.openvpn.net/c/openvpn/+/2393?usp=email

to review the following change.


Change subject: event: Avoid sign conversion warnings related to 
ALLOC_ARRAY_CLEAR
......................................................................

event: Avoid sign conversion warnings related to ALLOC_ARRAY_CLEAR

capacity is int, changing that is a big change without
much upside. We already make sure that everything is
positive. So just cast it when used as last argument
to ALLOC_ARRAY_CLEAR and be done with it.

Change-Id: Ic852ce88ca2a25c00c317ee89cae38a6e977773e
Signed-off-by: Frank Lichtenheld <[email protected]>
---
M src/openvpn/event.c
1 file changed, 6 insertions(+), 24 deletions(-)



  git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/93/2393/1

diff --git a/src/openvpn/event.c b/src/openvpn/event.c
index d083085..a10a4a0 100644
--- a/src/openvpn/event.c
+++ b/src/openvpn/event.c
@@ -486,11 +486,6 @@
 #endif
 }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-
 static struct event_set *
 we_init(int *maxevents, unsigned int flags)
 {
@@ -519,27 +514,18 @@
     *maxevents = min_int(*maxevents, WSA_MAXIMUM_WAIT_EVENTS);

     /* Allocate space for Win32 event handles */
-    ALLOC_ARRAY_CLEAR(wes->events, HANDLE, wes->capacity);
+    ALLOC_ARRAY_CLEAR(wes->events, HANDLE, (size_t)wes->capacity);

     /* Allocate space for event_set_return objects */
-    ALLOC_ARRAY_CLEAR(wes->esr, struct event_set_return, wes->capacity);
+    ALLOC_ARRAY_CLEAR(wes->esr, struct event_set_return, 
(size_t)wes->capacity);

     dmsg(D_EVENT_WAIT, "WE_INIT maxevents=%d capacity=%d", *maxevents, 
wes->capacity);

     return (struct event_set *)wes;
 }

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 #endif /* _WIN32 */

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-conversion"
-#endif
-
 #if EPOLL

 struct ep_set
@@ -695,7 +681,7 @@
     /* allocate space for epoll_wait return */
     ASSERT(*maxevents > 0);
     eps->maxevents = *maxevents;
-    ALLOC_ARRAY_CLEAR(eps->events, struct epoll_event, eps->maxevents);
+    ALLOC_ARRAY_CLEAR(eps->events, struct epoll_event, (size_t)eps->maxevents);

     /* set epoll control fd */
     eps->epfd = fd;
@@ -905,10 +891,10 @@
     pos->capacity = *maxevents;

     /* Allocate space for pollfd structures to be passed to poll() */
-    ALLOC_ARRAY_CLEAR(pos->events, struct pollfd, pos->capacity);
+    ALLOC_ARRAY_CLEAR(pos->events, struct pollfd, (size_t)pos->capacity);

     /* Allocate space for event_set_return objects */
-    ALLOC_ARRAY_CLEAR(pos->args, void *, pos->capacity);
+    ALLOC_ARRAY_CLEAR(pos->args, void *, (size_t)pos->capacity);

     return (struct event_set *)pos;
 }
@@ -1129,16 +1115,12 @@
     ses->capacity = SELECT_MAX_FDS;

     /* Allocate space for event_set_return void * args */
-    ALLOC_ARRAY_CLEAR(ses->args, void *, ses->capacity);
+    ALLOC_ARRAY_CLEAR(ses->args, void *, (size_t)ses->capacity);

     return (struct event_set *)ses;
 }
 #endif /* SELECT */

-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
-
 static struct event_set *
 event_set_init_simple(int *maxevents, unsigned int flags)
 {

--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2393?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ic852ce88ca2a25c00c317ee89cae38a6e977773e
Gerrit-Change-Number: 2393
Gerrit-PatchSet: 1
Gerrit-Owner: Frank Lichtenheld <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to