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

Marek Chalupa mchqwerty at gmail.com
Wed Nov 26 06:15:29 PST 2014


Hi,

this patch doesn't apply after 823ad33ef34fa32b14b300d987fb9d2e2a42e9c4
(src/evdev.c was deleted)
Otherwise looks OK

Reviewed-by: Marek Chalupa <mchqwerty at gmail.com>


P. S. there is one more setting to NULL after calloc in src/compositor.c in
weston_subsurface_create (sub->cached_buffer_ref.buffer = NULL)

On 21 November 2014 at 07:21, Bryce Harrington <bryce at osg.samsung.com>
wrote:

> 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
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20141126/192dae91/attachment.html>


More information about the wayland-devel mailing list