[PATCH] tevent: Fix some warnings in tevent_poll.c

Volker Lendecke vl at samba.org
Mon Feb 28 09:58:35 MST 2011


---
 lib/tevent/tevent_fd.c       |    2 +-
 lib/tevent/tevent_internal.h |    5 ++++-
 lib/tevent/tevent_poll.c     |   16 +++++-----------
 3 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/lib/tevent/tevent_fd.c b/lib/tevent/tevent_fd.c
index 455961b..1ccdf40 100644
--- a/lib/tevent/tevent_fd.c
+++ b/lib/tevent/tevent_fd.c
@@ -69,7 +69,7 @@ struct tevent_fd *tevent_common_add_fd(struct tevent_context *ev, TALLOC_CTX *me
 	fde->handler_name	= handler_name;
 	fde->location		= location;
 	fde->additional_flags	= 0;
-	fde->additional_data	= NULL;
+	fde->additional.p	= NULL;
 
 	DLIST_ADD(ev->fd_events, fde);
 
diff --git a/lib/tevent/tevent_internal.h b/lib/tevent/tevent_internal.h
index 3d71bfd..f6c0868 100644
--- a/lib/tevent/tevent_internal.h
+++ b/lib/tevent/tevent_internal.h
@@ -163,7 +163,10 @@ struct tevent_fd {
 	const char *location;
 	/* this is private for the events_ops implementation */
 	uint16_t additional_flags;
-	void *additional_data;
+	union {
+		void *p;
+		int i;
+	} additional;
 };
 
 struct tevent_timer {
diff --git a/lib/tevent/tevent_poll.c b/lib/tevent/tevent_poll.c
index c133194..7679b05 100644
--- a/lib/tevent/tevent_poll.c
+++ b/lib/tevent/tevent_poll.c
@@ -73,15 +73,12 @@ static int poll_event_fd_destructor(struct tevent_fd *fde)
 	poll_ev = talloc_get_type_abort(
 		ev->additional_data, struct poll_event_context);
 
-	/*
-	 * Assume a void * can carry enough bits to hold num_fds.
-	 */
-	del_idx = (int)(fde->additional_data);
+	del_idx = fde->additional.i;
 
 	moved_fde = poll_ev->fd_events[poll_ev->num_fds-1];
 	poll_ev->fd_events[del_idx] = moved_fde;
 	poll_ev->fds[del_idx] = poll_ev->fds[poll_ev->num_fds-1];
-	moved_fde->additional_data = (void *)del_idx;
+	moved_fde->additional.i = del_idx;
 
 	poll_ev->num_fds -= 1;
 done:
@@ -149,10 +146,7 @@ static struct tevent_fd *poll_event_add_fd(struct tevent_context *ev,
 		pfd->events |= (POLLOUT);
 	}
 
-	/*
-	 * Assume a void * can carry enough bits to hold num_fds.
-	 */
-	fde->additional_data = (void *)poll_ev->num_fds;
+	fde->additional.i = poll_ev->num_fds;
 	poll_ev->fd_events[poll_ev->num_fds] = fde;
 
 	poll_ev->num_fds += 1;
@@ -179,7 +173,7 @@ static void poll_event_set_fd_flags(struct tevent_fd *fde, uint16_t flags)
 		pollflags |= (POLLOUT);
 	}
 
-	idx = (int)(fde->additional_data);
+	idx = fde->additional.i;
 	poll_ev->fds[idx].events = pollflags;
 
 	fde->flags = flags;
@@ -240,7 +234,7 @@ static int poll_event_loop_poll(struct tevent_context *ev,
 			int pfd_idx;
 			uint16_t flags = 0;
 
-			pfd_idx = (int)(fde->additional_data);
+			pfd_idx = fde->additional.i;
 
 			pfd = &poll_ev->fds[pfd_idx];
 
-- 
1.7.3.4


--k+w/mQv8wyuph6w0--


More information about the samba-technical mailing list