<p dir="ltr"><br>
On Sep 4, 2015 1:48 AM, "Bryce Harrington" <<a href="mailto:bryce@osg.samsung.com">bryce@osg.samsung.com</a>> wrote:<br>
><br>
> On Fri, Sep 04, 2015 at 12:17:18AM +0530, Seedo Eldho Paul wrote:<br>
> > xzalloc is guaranteed to return a non-NULL value.<br>
> ><br>
> > Signed-off-by: Seedo Eldho Paul <<a href="mailto:seedoeldhopaul@gmail.com">seedoeldhopaul@gmail.com</a>><br>
> > ---<br>
> >  tests/internal-screenshot-test.c | 13 -------------<br>
> >  1 file changed, 13 deletions(-)<br>
><br>
> Good point.  The error handling code will never actually get executed.<br>
><br>
> > diff --git a/tests/internal-screenshot-test.c b/tests/internal-screenshot-test.c<br>
> > index e72a695..a74ae7a 100644<br>
> > --- a/tests/internal-screenshot-test.c<br>
> > +++ b/tests/internal-screenshot-test.c<br>
> > @@ -93,11 +93,6 @@ load_surface_from_png(const char *fname)<br>
> ><br>
> >       /* Disguise the cairo surface in a weston test surface */<br>
> >       reference = xzalloc(sizeof *reference);<br>
> > -     if (reference == NULL) {<br>
> > -             perror("xzalloc reference");<br>
> > -             cairo_surface_destroy(reference_cairo_surface);<br>
> > -             return NULL;<br>
> > -     }<br>
><br>
> This will skip the surface destruction.  I suppose who cares, we're<br>
> exiting anyway, but the xzalloc could be moved up prior to the surface<br>
> creation, and make it a non-issue.<br>
><br>
> >       reference->width = cairo_image_surface_get_width(reference_cairo_surface);<br>
> >       reference->height = cairo_image_surface_get_height(reference_cairo_surface);<br>
> >       stride = cairo_image_surface_get_stride(reference_cairo_surface);<br>
> > @@ -115,12 +110,6 @@ load_surface_from_png(const char *fname)<br>
> >       /* Allocate new buffer for our weston reference, and copy the data from<br>
> >          the cairo surface so we can destroy it */<br>
> >       reference->data = xzalloc(source_data_size);<br>
> > -     if (reference->data == NULL) {<br>
> > -             perror("xzalloc reference data");<br>
> > -             cairo_surface_destroy(reference_cairo_surface);<br>
> > -             free(reference);<br>
> > -             return NULL;<br>
> > -     }<br>
><br>
> Can't do that here though, since we depend on the surface to calculate<br>
> source_data_size.  Also freeing reference in this case is a good idea.<br>
> Maybe this is a case where we should plain zalloc instead?<br>
><br>
> >       memcpy(reference->data,<br>
> >              cairo_image_surface_get_data(reference_cairo_surface),<br>
> >              source_data_size);<br>
> > @@ -144,8 +133,6 @@ create_screenshot_surface(struct client *client)<br>
> >  {<br>
> >       struct surface* screenshot;<br>
> >       screenshot = xzalloc(sizeof *screenshot);<br>
> > -     if (screenshot == NULL)<br>
> > -             return NULL;<br>
> >       screenshot->wl_buffer = create_shm_buffer(client,<br>
> >                                                 client->output->width,<br>
> >                                                 client->output->height,<br>
><br>
> Same as above, maybe should use zalloc instead.<br>
><br>
> Thanks for reviewing this.  Sorry if these comments seem nit-picky for a<br>
> just a test case...  The reason is that I plan to move a lot of this<br>
> code out of this test into the testing infrastructure, so having it<br>
> handle errors cleanly in this test case will be worthwhile in the longer<br>
> run.<br>
></p>
<p dir="ltr">Thanks for the review. I agree with your rationale. I'll respin the patch later today.</p>
<p dir="ltr">SEEDO</p>
<p dir="ltr">> Bryce<br>
><br>
> > --<br>
> > 1.9.1<br>
> ><br>
> > _______________________________________________<br>
> > wayland-devel mailing list<br>
> > <a href="mailto:wayland-devel@lists.freedesktop.org">wayland-devel@lists.freedesktop.org</a><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/wayland-devel">http://lists.freedesktop.org/mailman/listinfo/wayland-devel</a><br>
</p>