1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

libev: clean cast abuse

assuming that you can cast to the first field of an struct is very
risky

Signed-off-by: Alejandro Mery <amery@geeks.cl>
This commit is contained in:
Alejandro Mery 2014-12-07 03:36:12 +01:00 committed by Andy Green
parent ead8afe8a1
commit 95ab6ca557

View file

@ -33,7 +33,7 @@ static void
libwebsocket_accept_cb(struct ev_loop *loop, struct ev_io *watcher, int revents)
{
struct libwebsocket_pollfd eventfd;
struct lws_io_watcher *lws_io = (struct lws_io_watcher *)watcher;
struct lws_io_watcher *lws_io = container_of(watcher, struct lws_io_watcher, watcher);
struct libwebsocket_context *context = lws_io->context;
if (revents & EV_ERROR)
@ -65,8 +65,8 @@ libwebsocket_initloop(
int status = 0;
int backend;
const char * backend_name;
struct ev_io *w_accept = (ev_io *)&context->w_accept;
struct ev_signal *w_sigint = (ev_signal *)&context->w_sigint;
struct ev_io *w_accept = &context->w_accept.watcher;
struct ev_signal *w_sigint = &context->w_sigint.watcher;
if (!loop)
loop = ev_default_loop(0);