On Mon, Aug 11, 2014 at 08:36:51AM +0200, Marek Chalupa wrote: > > proxy->flags = 0; > > > > After memset, this line can be removed as well. > > > > @@ -331,10 +331,10 @@ wl_proxy_create_for_id(struct wl_proxy *factory, > > if (proxy == NULL) > > return NULL; > > > > + memset(proxy, 0, sizeof *proxy); > > + > > proxy->object.interface = interface; > > - proxy->object.implementation = NULL; > > proxy->object.id = id; > > - proxy->dispatcher = NULL; > > proxy->display = display; > > proxy->queue = factory->queue; > > proxy->flags = 0; > > > > The same. >
Yes, of course. I guess we can also remove similar lines from wl_display_connect_to_fd then? New patch including this: >From ec5eff0720efd90e868711a9b58bf1a435d156ce Mon Sep 17 00:00:00 2001 From: "Nils Chr. Brause" <nilschrbra...@googlemail.com> Date: Fri, 8 Aug 2014 18:06:16 +0200 Subject: [PATCH] wayland-client: Initialize newly created wl_proxys to zero. Up until now, newly created wl_proxys (with proxy_create or wl_proxy_create_for_id) are not initialized properly after memory allocation. The wl_display object in contrast is. To prevent giving uninitialized data to the user (e.g. user_data) an appropriate memset has been added. Also, after a memset members don't have to be explicitly initialized with zero anymore. Signed-off-by: Nils Chr. Brause <nilschrbra...@googlemail.com> --- src/wayland-client.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/wayland-client.c b/src/wayland-client.c index 3e401d3..8054999 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -274,12 +274,11 @@ proxy_create(struct wl_proxy *factory, const struct wl_interface *interface) if (proxy == NULL) return NULL; + memset(proxy, 0, sizeof *proxy); + proxy->object.interface = interface; - proxy->object.implementation = NULL; - proxy->dispatcher = NULL; proxy->display = display; proxy->queue = factory->queue; - proxy->flags = 0; proxy->refcount = 1; proxy->object.id = wl_map_insert_new(&display->objects, 0, proxy); @@ -331,13 +330,12 @@ wl_proxy_create_for_id(struct wl_proxy *factory, if (proxy == NULL) return NULL; + memset(proxy, 0, sizeof *proxy); + proxy->object.interface = interface; - proxy->object.implementation = NULL; proxy->object.id = id; - proxy->dispatcher = NULL; proxy->display = display; proxy->queue = factory->queue; - proxy->flags = 0; proxy->refcount = 1; wl_map_insert_at(&display->objects, 0, id, proxy); @@ -771,7 +769,6 @@ wl_display_connect_to_fd(int fd) wl_list_init(&display->event_queue_list); pthread_mutex_init(&display->mutex, NULL); pthread_cond_init(&display->reader_cond, NULL); - display->reader_count = 0; wl_map_insert_new(&display->objects, 0, NULL); @@ -782,7 +779,6 @@ wl_display_connect_to_fd(int fd) display->proxy.object.implementation = (void(**)(void)) &display_listener; display->proxy.user_data = display; display->proxy.queue = &display->default_queue; - display->proxy.flags = 0; display->proxy.refcount = 1; display->connection = wl_connection_create(display->fd); -- 2.0.4 _______________________________________________ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel