[PATCH] pixman-renderer: don't forget to initialize the debug fields

Kristian Høgsberg hoegsberg at gmail.com
Mon Mar 18 19:32:18 PDT 2013


On Fri, Mar 08, 2013 at 09:05:06PM +0100, Philipp Brüschweiler wrote:
> Sorry, forgot Reply All.
> 
> 
> On Fri, Mar 8, 2013 at 9:04 PM, Philipp Brüschweiler <blei42 at gmail.com>wrote:
> 
> > On Fri, Mar 8, 2013 at 8:44 PM, Scott Moreau <oreaus at gmail.com> wrote:
> >
> >>
> >>
> >> On Fri, Mar 8, 2013 at 12:35 PM, Philipp Brüschweiler <blei42 at gmail.com>wrote:
> >>
> >>> Fixes https://bugs.freedesktop.org/show_bug.cgi?id=61930
> >>> ---
> >>>  src/pixman-renderer.c | 2 ++
> >>>  1 file changed, 2 insertions(+)
> >>>
> >>> diff --git a/src/pixman-renderer.c b/src/pixman-renderer.c
> >>> index 9571f6f..9dbe9f0 100644
> >>> --- a/src/pixman-renderer.c
> >>> +++ b/src/pixman-renderer.c
> >>> @@ -485,6 +485,8 @@ pixman_renderer_init(struct weston_compositor *ec)
> >>>         if (renderer == NULL)
> >>>                 return -1;
> >>>
> >>> +       renderer->repaint_debug = 0;
> >>> +       renderer->debug_color = NULL;
> >>>
> >>
> >> Alternatively you could change malloc to calloc so the entire struct is
> >> initialized.
> >>
> >
> > True. Though this has the downside that valgrind will not be able to tell
> > you when you are using uninitialized memory. Which is a pretty small
> > downside compared to this bug. What is the general convention in
> > wayland/weston regarding malloc vs. calloc?

There's really no firm rule.  My pet peeve is that calloc is a
function for allocating an array (nelems * size bytes) *and* it zeroes
the memory.  So it kinda conflates two features.  Using calloc to
allocate a single object just so it will be zeroed seems like abusing
the API a bit (if ever so slightly), so I tend to prefer
malloc+memset.  If there was a zalloc(size_t size) that just allocated
the given size and zeroed it, we'd just use that, but as it is... meh.

Kristian

> >
> >>
> >>
> >>>          renderer->base.read_pixels = pixman_renderer_read_pixels;
> >>>         renderer->base.repaint_output = pixman_renderer_repaint_output;
> >>>         renderer->base.flush_damage = pixman_renderer_flush_damage;
> >>> --
> >>> 1.8.1.5
> >>>
> >>> _______________________________________________
> >>> wayland-devel mailing list
> >>> wayland-devel at lists.freedesktop.org
> >>> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> >>>
> >>
> >>
> >

> _______________________________________________
> 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