mesa: split out errorstring switch from _mesa_error
authorKeith Whitwell <keithw@vmware.com>
Tue, 14 Jul 2009 15:28:08 +0000 (16:28 +0100)
committerKeith Whitwell <keithw@vmware.com>
Wed, 15 Jul 2009 12:31:51 +0000 (13:31 +0100)
Move a chunk of code out of _mesa_error()

src/mesa/main/imports.c

index c35dcf5bd2424a0839c6b9ff18a053acbca76013..3916c62eda35d73560181831096538261bb50d6d 100644 (file)
@@ -1065,6 +1065,31 @@ _mesa_problem( const GLcontext *ctx, const char *fmtString, ... )
    fprintf(stderr, "Please report at bugzilla.freedesktop.org\n");
 }
 
+static const char *error_string( GLenum error )
+{
+   switch (error) {
+   case GL_NO_ERROR:
+      return "GL_NO_ERROR";
+   case GL_INVALID_VALUE:
+      return "GL_INVALID_VALUE";
+   case GL_INVALID_ENUM:
+      return "GL_INVALID_ENUM";
+   case GL_INVALID_OPERATION:
+      return "GL_INVALID_OPERATION";
+   case GL_STACK_OVERFLOW:
+      return "GL_STACK_OVERFLOW";
+   case GL_STACK_UNDERFLOW:
+      return "GL_STACK_UNDERFLOW";
+   case GL_OUT_OF_MEMORY:
+      return "GL_OUT_OF_MEMORY";
+   case GL_TABLE_TOO_LARGE:
+      return "GL_TABLE_TOO_LARGE";
+   case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
+      return "GL_INVALID_FRAMEBUFFER_OPERATION";
+   default:
+      return "unknown";
+   }
+}
 
 /**
  * Record an OpenGL state error.  These usually occur when the user
@@ -1102,41 +1127,6 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
    }
 
    if (debug) {
-      const char *errstr;
-
-      switch (error) {
-        case GL_NO_ERROR:
-           errstr = "GL_NO_ERROR";
-           break;
-        case GL_INVALID_VALUE:
-           errstr = "GL_INVALID_VALUE";
-           break;
-        case GL_INVALID_ENUM:
-           errstr = "GL_INVALID_ENUM";
-           break;
-        case GL_INVALID_OPERATION:
-           errstr = "GL_INVALID_OPERATION";
-           break;
-        case GL_STACK_OVERFLOW:
-           errstr = "GL_STACK_OVERFLOW";
-           break;
-        case GL_STACK_UNDERFLOW:
-           errstr = "GL_STACK_UNDERFLOW";
-           break;
-        case GL_OUT_OF_MEMORY:
-           errstr = "GL_OUT_OF_MEMORY";
-           break;
-         case GL_TABLE_TOO_LARGE:
-            errstr = "GL_TABLE_TOO_LARGE";
-            break;
-         case GL_INVALID_FRAMEBUFFER_OPERATION_EXT:
-            errstr = "GL_INVALID_FRAMEBUFFER_OPERATION";
-            break;
-        default:
-           errstr = "unknown";
-           break;
-      }
-
       {
          char s[MAXSTRING], s2[MAXSTRING];
          va_list args;
@@ -1144,7 +1134,7 @@ _mesa_error( GLcontext *ctx, GLenum error, const char *fmtString, ... )
          vsnprintf(s, MAXSTRING, fmtString, args);
          va_end(args);
 
-         _mesa_snprintf(s2, MAXSTRING, "%s in %s", errstr, s);
+         _mesa_snprintf(s2, MAXSTRING, "%s in %s", error_string(error), s);
          output_if_debug("Mesa: User error", s2, GL_TRUE);
       }
    }