[PATCH 2/3] Setting members to 0/NULL after a zalloc or calloc is redundant

Bryce Harrington bryce at osg.samsung.com
Thu Nov 20 22:21:56 PST 2014


calloc (and zalloc) set the allocated memory to 0, so there's really no
need to do it manually.

Signed-off-by: Bryce Harrington <bryce at osg.samsung.com>
---
 src/compositor-fbdev.c |  4 ----
 src/compositor.c       | 12 ------------
 src/evdev.c            |  4 ----
 src/gl-renderer.c      |  2 --
 src/rpi-renderer.c     |  1 -
 5 files changed, 23 deletions(-)

diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index 138aaab..ccc017a 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -533,10 +533,6 @@ fbdev_output_create(struct fbdev_compositor *compositor,
 	output->base.start_repaint_loop = fbdev_output_start_repaint_loop;
 	output->base.repaint = fbdev_output_repaint;
 	output->base.destroy = fbdev_output_destroy;
-	output->base.assign_planes = NULL;
-	output->base.set_backlight = NULL;
-	output->base.set_dpms = NULL;
-	output->base.switch_mode = NULL;
 
 	/* only one static mode in list */
 	output->mode.flags =
diff --git a/src/compositor.c b/src/compositor.c
index 72fe384..f19c33f 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -440,10 +440,6 @@ weston_view_create(struct weston_surface *surface)
 	wl_list_init(&view->link);
 	wl_list_init(&view->layer_link.link);
 
-	view->plane = NULL;
-	view->layer_link.layer = NULL;
-	view->parent_view = NULL;
-
 	pixman_region32_init(&view->clip);
 	pixman_region32_init(&view->transform.masked_boundingbox);
 	pixman_region32_init(&view->transform.masked_opaque);
@@ -459,8 +455,6 @@ weston_view_create(struct weston_surface *surface)
 	pixman_region32_init(&view->transform.boundingbox);
 	view->transform.dirty = 1;
 
-	view->output = NULL;
-
 	return view;
 }
 
@@ -617,8 +611,6 @@ weston_surface_create(struct weston_compositor *compositor)
 
 	wl_signal_init(&surface->destroy_signal);
 
-	surface->resource = NULL;
-
 	surface->compositor = compositor;
 	surface->ref_count = 1;
 
@@ -629,10 +621,6 @@ weston_surface_create(struct weston_compositor *compositor)
 
 	weston_surface_state_init(&surface->pending);
 
-	surface->output = NULL;
-
-	surface->viewport_resource = NULL;
-
 	pixman_region32_init(&surface->damage);
 	pixman_region32_init(&surface->opaque);
 	region_init_infinite(&surface->input);
diff --git a/src/evdev.c b/src/evdev.c
index 888dfbd..078bc21 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -638,14 +638,10 @@ evdev_device_create(struct weston_seat *seat, const char *path, int device_fd)
 
 	ec = seat->compositor;
 	device->seat = seat;
-	device->seat_caps = 0;
-	device->is_mt = 0;
-	device->mtdev = NULL;
 	device->devnode = strdup(path);
 	device->mt.slot = -1;
 	device->rel.dx = 0;
 	device->rel.dy = 0;
-	device->dispatch = NULL;
 	device->fd = device_fd;
 	device->pending_event = EVDEV_NONE;
 	wl_list_init(&device->link);
diff --git a/src/gl-renderer.c b/src/gl-renderer.c
index 076c242..677b43b 100644
--- a/src/gl-renderer.c
+++ b/src/gl-renderer.c
@@ -1780,8 +1780,6 @@ gl_renderer_output_create(struct weston_output *output,
 	for (i = 0; i < BUFFER_DAMAGE_COUNT; i++)
 		pixman_region32_init(&go->buffer_damage[i]);
 
-	go->buffer_damage_index = 0;
-
 	output->renderer_state = go;
 
 	log_egl_config_info(gr->egl_display, egl_config);
diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
index c222eb6..4d0f522 100644
--- a/src/rpi-renderer.c
+++ b/src/rpi-renderer.c
@@ -497,7 +497,6 @@ rpir_surface_create(struct rpi_renderer *renderer)
 		return NULL;
 
 	wl_list_init(&surface->views);
-	surface->visible_views = 0;
 	surface->single_buffer = renderer->single_buffer;
 	surface->enable_opaque_regions = renderer->enable_opaque_regions;
 	rpi_resource_init(&surface->resources[0]);
-- 
1.9.1



More information about the wayland-devel mailing list