From 6655bedba735d2066877c938767b0d675b265923 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Tue, 15 Feb 2011 12:31:12 +0000 Subject: [PATCH] Fix ISO C90 compiler warnings in Cogl Mixing declarations and statements and unused variables. --- clutter/cogl/cogl/cogl-attribute.c | 14 +++++-- clutter/cogl/cogl/cogl-bitmap-pixbuf.c | 67 +++++++++++++++++++++++----------- clutter/cogl/cogl/cogl-blend-string.c | 4 +- 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/clutter/cogl/cogl/cogl-attribute.c b/clutter/cogl/cogl/cogl-attribute.c index 5872aa2..4be7e8d 100644 --- a/clutter/cogl/cogl/cogl-attribute.c +++ b/clutter/cogl/cogl/cogl-attribute.c @@ -882,7 +882,7 @@ get_wire_lines (CoglAttribute *attribute, CoglIndicesType indices_type; int i; int n_lines; - CoglVertexP3 *out; + CoglVertexP3 *out = NULL; vertices = cogl_buffer_map (COGL_BUFFER (vertex_array), COGL_BUFFER_ACCESS_READ, 0); @@ -894,7 +894,11 @@ get_wire_lines (CoglAttribute *attribute, indices_type = cogl_indices_get_type (_indices); } else - indices = NULL; + { + index_array = NULL; + indices = NULL; + indices_type = COGL_INDICES_TYPE_UNSIGNED_BYTE; + } *n_vertices_out = 0; @@ -977,10 +981,12 @@ get_wire_lines (CoglAttribute *attribute, } #endif - if (vertices) + if (vertices != NULL) cogl_buffer_unmap (COGL_BUFFER (vertex_array)); - if (indices) + + if (indices != NULL) cogl_buffer_unmap (COGL_BUFFER (index_array)); + return out; } diff --git a/clutter/cogl/cogl/cogl-bitmap-pixbuf.c b/clutter/cogl/cogl/cogl-bitmap-pixbuf.c index f0bd0ee..1a99f4b 100644 --- a/clutter/cogl/cogl/cogl-bitmap-pixbuf.c +++ b/clutter/cogl/cogl/cogl-bitmap-pixbuf.c @@ -95,63 +95,86 @@ CoglBitmap * _cogl_bitmap_from_file (const char *filename, GError **error) { + CFURLRef url; + CGImageSourceRef image_source; + CGImageRef image; + int save_errno; + CFStringRef type; + gsize width, height, rowstride; + guint8 *out_data; + CGColorSpaceRef color_space; + CGContextRef bitmap_context; + g_assert (filename != NULL); g_assert (error == NULL || *error == NULL); - CFURLRef url = CFURLCreateFromFileSystemRepresentation (NULL, (guchar*)filename, strlen(filename), false); - CGImageSourceRef image_source = CGImageSourceCreateWithURL (url, NULL); - int save_errno = errno; + url = CFURLCreateFromFileSystemRepresentation (NULL, + (guchar *) filename, + strlen (filename), + false); + image_source = CGImageSourceCreateWithURL (url, NULL); + save_errno = errno; CFRelease (url); + if (image_source == NULL) { /* doesn't exist, not readable, etc. */ - g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_FAILED, - "%s", g_strerror (save_errno)); + g_set_error_literal (error, + COGL_BITMAP_ERROR, + COGL_BITMAP_ERROR_FAILED, + g_strerror (save_errno)); return NULL; } /* Unknown images would be cleanly caught as zero width/height below, but try * to provide better error message */ - CFStringRef type = CGImageSourceGetType (image_source); + type = CGImageSourceGetType (image_source); if (type == NULL) { CFRelease (image_source); - g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_UNKNOWN_TYPE, - "Unknown image type"); + g_set_error_literal (error, + COGL_BITMAP_ERROR, + COGL_BITMAP_ERROR_UNKNOWN_TYPE, + "Unknown image type"); return NULL; } + CFRelease (type); - CGImageRef image = CGImageSourceCreateImageAtIndex (image_source, 0, NULL); + image = CGImageSourceCreateImageAtIndex (image_source, 0, NULL); CFRelease (image_source); - gsize width = CGImageGetWidth (image); - gsize height = CGImageGetHeight (image); + width = CGImageGetWidth (image); + height = CGImageGetHeight (image); if (width == 0 || height == 0) { /* incomplete or corrupt */ CFRelease (image); - g_set_error (error, COGL_BITMAP_ERROR, COGL_BITMAP_ERROR_CORRUPT_IMAGE, - "Image has zero width or height"); + g_set_error_literal (error, + COGL_BITMAP_ERROR, + COGL_BITMAP_ERROR_CORRUPT_IMAGE, + "Image has zero width or height"); return NULL; } /* allocate buffer big enough to hold pixel data */ - gsize rowstride; rowstride = 4 * width; - guint8 *out_data = g_malloc0 (height * rowstride); + out_data = g_malloc0 (height * rowstride); /* render to buffer */ - CGColorSpaceRef color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB); - CGContextRef bitmap_context = CGBitmapContextCreate (out_data, - width, height, 8, - rowstride, color_space, - kCGImageAlphaPremultipliedFirst); + color_space = CGColorSpaceCreateWithName (kCGColorSpaceGenericRGB); + bitmap_context = CGBitmapContextCreate (out_data, + width, height, 8, + rowstride, color_space, + kCGImageAlphaPremultipliedFirst); CGColorSpaceRelease (color_space); - const CGRect rect = {{0, 0}, {width, height}}; - CGContextDrawImage (bitmap_context, rect, image); + { + const CGRect rect = {{0, 0}, {width, height}}; + + CGContextDrawImage (bitmap_context, rect, image); + } CGImageRelease (image); CGContextRelease (bitmap_context); diff --git a/clutter/cogl/cogl/cogl-blend-string.c b/clutter/cogl/cogl/cogl-blend-string.c index 2e7dd5b..cd4443f 100644 --- a/clutter/cogl/cogl/cogl-blend-string.c +++ b/clutter/cogl/cogl/cogl-blend-string.c @@ -477,8 +477,8 @@ parse_argument (const char *string, /* original user string */ GError **error) { const char *p = *ret_p; - const char *mark; - const char *error_string; + const char *mark = NULL; + const char *error_string = NULL; ParserArgState state = PARSER_ARG_STATE_START; gboolean parsing_factor = FALSE; -- 2.7.4