[PATCH weston 3/3] ivi-shell: use zalloc instead of calloc
Yong Bakos
junk at humanoriented.com
Sat Jul 9 23:10:20 UTC 2016
Hi Emre,
> On Jul 1, 2016, at 2:34 AM, Ucan, Emre (ADITG/SW1) <eucan at de.adit-jv.com> wrote:
>
> Signed-off-by: Emre Ucan <eucan at de.adit-jv.com>
Since `zalloc(sizeof *foo)` just inlines calloc(1, sizeof *foo),
the patch is fine. However, I'd like to make a couple comments.
First, please add an explicit include of zalloc.h in any .c file
that uses zalloc. eg:
#include "shared/zalloc.h"
Second, this patch in the 1/3 series doesn't seem like it's part
of a cohesive series at all, and this patch can stand alone. In fact,
there are a few other cases within ivi-shell/* where calloc can be
replaced with zalloc... why not just fix them all, and let this patch
stand alone instead of being part of the series.
Third, I feel that the commit messages in 1 & 2 need some work before
they can be accepted. Here's a simple recipe I use:
A description of the problem that prompts the patch.
A description of how this patch fixes the problem.
For example, in 1/3 I would have written something like:
Numerous internal/private ivi_layout* struct members are no longer
used. This clutters the interfaces and makes it confusing when...
(why is this a problem that deserves fixing?)
Remove all unused ivi_layout* struct members.
---
Regards,
yong
> ---
> ivi-shell/input-panel-ivi.c | 2 +-
> ivi-shell/ivi-layout.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/ivi-shell/input-panel-ivi.c b/ivi-shell/input-panel-ivi.c
> index 581b56b..be9799f 100644
> --- a/ivi-shell/input-panel-ivi.c
> +++ b/ivi-shell/input-panel-ivi.c
> @@ -236,7 +236,7 @@ create_input_panel_surface(struct ivi_shell *shell,
> {
> struct input_panel_surface *input_panel_surface;
>
> - input_panel_surface = calloc(1, sizeof *input_panel_surface);
> + input_panel_surface = zalloc(sizeof *input_panel_surface);
> if (!input_panel_surface)
> return NULL;
>
> diff --git a/ivi-shell/ivi-layout.c b/ivi-shell/ivi-layout.c
> index 4e56ace..9bd631b 100644
> --- a/ivi-shell/ivi-layout.c
> +++ b/ivi-shell/ivi-layout.c
> @@ -162,7 +162,7 @@ ivi_view_create(struct ivi_layout_layer *ivilayer,
> {
> struct ivi_layout_view *ivi_view;
>
> - ivi_view = calloc(1, sizeof *ivi_view);
> + ivi_view = zalloc(sizeof *ivi_view);
> if (ivi_view == NULL) {
> weston_log("fails to allocate memory\n");
> return NULL;
> @@ -259,7 +259,7 @@ create_screen(struct weston_compositor *ec)
> struct weston_output *output = NULL;
>
> wl_list_for_each(output, &ec->output_list, link) {
> - iviscrn = calloc(1, sizeof *iviscrn);
> + iviscrn = zalloc(sizeof *iviscrn);
> if (iviscrn == NULL) {
> weston_log("fails to allocate memory\n");
> continue;
> @@ -1318,7 +1318,7 @@ ivi_layout_layer_create_with_dimension(uint32_t id_layer,
> return ivilayer;
> }
>
> - ivilayer = calloc(1, sizeof *ivilayer);
> + ivilayer = zalloc(sizeof *ivilayer);
> if (ivilayer == NULL) {
> weston_log("fails to allocate memory\n");
> return NULL;
> @@ -1967,7 +1967,7 @@ ivi_layout_surface_create(struct weston_surface *wl_surface,
> }
> }
>
> - ivisurf = calloc(1, sizeof *ivisurf);
> + ivisurf = zalloc(sizeof *ivisurf);
> if (ivisurf == NULL) {
> weston_log("fails to allocate memory\n");
> return NULL;
> --
> 1.7.9.5
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list