From 2b9aca20a8e3a15fd481b70bd150cf88a303bc2c Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 29 Feb 2012 13:42:44 +0000 Subject: [PATCH] Assert that we get a valid format in pixel_format_to_gl{,es} The assert could use a 'default:' label but that would stop GCC from giving a warning when a new enum value is added. https://bugzilla.gnome.org/show_bug.cgi?id=671016 Reviewed-by: Robert Bragg --- cogl/driver/gl/cogl-texture-driver-gl.c | 6 +++++- cogl/driver/gles/cogl-texture-driver-gles.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cogl/driver/gl/cogl-texture-driver-gl.c b/cogl/driver/gl/cogl-texture-driver-gl.c index 6cb004844..3c2296e69 100644 --- a/cogl/driver/gl/cogl-texture-driver-gl.c +++ b/cogl/driver/gl/cogl-texture-driver-gl.c @@ -400,7 +400,7 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format, { CoglPixelFormat required_format; GLenum glintformat; - GLenum glformat; + GLenum glformat = 0; GLenum gltype; required_format = format; @@ -522,6 +522,10 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format, break; } + /* All of the pixel formats are handled above so if this hits then + we've been given an invalid pixel format */ + g_assert (glformat != 0); + if (out_glintformat != NULL) *out_glintformat = glintformat; if (out_glformat != NULL) diff --git a/cogl/driver/gles/cogl-texture-driver-gles.c b/cogl/driver/gles/cogl-texture-driver-gles.c index 3c83a4558..817ee93f9 100644 --- a/cogl/driver/gles/cogl-texture-driver-gles.c +++ b/cogl/driver/gles/cogl-texture-driver-gles.c @@ -412,7 +412,7 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format, { CoglPixelFormat required_format; GLenum glintformat; - GLenum glformat; + GLenum glformat = 0; GLenum gltype; required_format = format; @@ -491,6 +491,10 @@ _cogl_texture_driver_pixel_format_to_gl (CoglPixelFormat format, break; } + /* All of the pixel formats are handled above so if this hits then + we've been given an invalid pixel format */ + g_assert (glformat != 0); + if (out_glintformat != NULL) *out_glintformat = glintformat; if (out_glformat != NULL)