[cairo] [PATCH] pdf: Assure compiler that data, data_size will always be initialized

Bryce W. Harrington b.harrington at samsung.com
Wed Jun 19 20:17:38 PDT 2013


There are only three possible color states:  COLOR, GRAYSCALE, or
MONOCHROME thus data and data_size will always be set to some value,
so assert the default is never reached.

Fixes these warning:
  cairo-pdf-surface.c:2517:32: warning: ‘data_size’ may be used
   uninitialized in this function [-Wuninitialized]
  cairo-pdf-surface.c:2338:19: note: ‘data_size’ was declared here
  cairo-pdf-surface.c:2446:11: warning: ‘data’ may be used uninitialized
   in this function [-Wuninitialized]
  cairo-pdf-surface.c:2337:11: note: ‘data’ was declared here

Signed-off-by: Bryce Harrington <b.harrington at samsung.com>
---
 src/cairo-pdf-surface.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 133f6f2..707ba97 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -2403,6 +2403,9 @@ _cairo_pdf_surface_emit_image (cairo_pdf_surface_t     *surface,
 	    data_size = (image->width + 7) / 8 * image->height;
 	    data = _cairo_malloc_ab ((image->width+7) / 8, image->height);
 	    break;
+        default:
+	    ASSERT_NOT_REACHED;
+	    break;
     }
     if (unlikely (data == NULL)) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-- 
1.7.9.5


--
Bryce Harrington
Senior Open Source Developer  -  b.harrington at samsung.com
Open Source Group             -  Samsung Research America



More information about the cairo mailing list