[cogl/wip/pbo-read-pixels: 2/18] Assert that we get a valid format in pixel_format_to_gl{, es}



commit 1a2c6e2360553c34e0b3e6b54948133aca3ecdf5
Author: Neil Roberts <neil linux intel com>
Date:   Wed Feb 29 13:42:44 2012 +0000

    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

 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 6cb0048..3c2296e 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 3c83a45..817ee93 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)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]