[PATCH][weston] ivi-shell: initialize all fields in create_layout_transition

Bryce Harrington bryce at osg.samsung.com
Tue Sep 22 17:28:32 PDT 2015


On Sun, Sep 20, 2015 at 02:47:37AM +0200, John-John Tedro wrote:
> create_layout_transition does not initialize is_transition_func.
> 
> This patch initializes it to NULL.
> 
> Signed-off-by: John-John Tedro <johnjohn.tedro at gmail.com>

Reviewed-by: Bryce Harrington <bryce at osg.samsung.com>

Btw, since this function sets nearly all the parameters to 0 or NULL, it
might be better to change the malloc to a calloc, which will ensure all
members are zero'd on allocation.

That would avoid problems like this one, when new members get added to
the struct.  In addition, using calloc sometimes lets the kernel pick
memory to give us that is already zero'd, which will be more efficient
than zeroing things manually.

Anyway, something you could consider as a follow up patch.  Meanwhile
I'll go ahead and land this one since it fixes a legit issue and is
technically correct.

> ---
>  ivi-shell/ivi-layout-transition.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/ivi-shell/ivi-layout-transition.c b/ivi-shell/ivi-layout-transition.c
> index d12a8f4..d45b332 100644
> --- a/ivi-shell/ivi-layout-transition.c
> +++ b/ivi-shell/ivi-layout-transition.c
> @@ -251,6 +251,7 @@ create_layout_transition(void)
>  
>  	transition->is_done = 0;
>  
> +	transition->is_transition_func = NULL;
>  	transition->private_data = NULL;
>  	transition->user_data = NULL;
>  
> -- 
> 2.1.4
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel


More information about the wayland-devel mailing list