[Mesa-dev] [PATCH] mesa: remove unrequired else

Timothy Arceri timothy.arceri at collabora.com
Sat Apr 2 10:07:50 UTC 2016


The if always returns so no need for an else.
---
 src/mesa/program/prog_parameter.c | 81 +++++++++++++++++++--------------------
 1 file changed, 39 insertions(+), 42 deletions(-)

diff --git a/src/mesa/program/prog_parameter.c b/src/mesa/program/prog_parameter.c
index 02d84f2..c294b00 100644
--- a/src/mesa/program/prog_parameter.c
+++ b/src/mesa/program/prog_parameter.c
@@ -248,54 +248,51 @@ _mesa_add_parameter(struct gl_program_parameter_list *paramList,
       paramList->Size = 0;
       return -1;
    }
-   else {
-      GLuint i, j;
-
-      paramList->NumParameters = oldNum + sz4;
-
-      memset(&paramList->Parameters[oldNum], 0,
-             sz4 * sizeof(struct gl_program_parameter));
-
-      for (i = 0; i < sz4; i++) {
-         struct gl_program_parameter *p = paramList->Parameters + oldNum + i;
-         p->Name = name ? strdup(name) : NULL;
-         p->Type = type;
-         p->Size = size;
-         p->DataType = datatype;
-         if (values) {
-            if (size >= 4) {
-               COPY_4V(paramList->ParameterValues[oldNum + i], values);
+
+   GLuint i, j;
+
+   paramList->NumParameters = oldNum + sz4;
+
+   memset(&paramList->Parameters[oldNum], 0,
+          sz4 * sizeof(struct gl_program_parameter));
+
+   for (i = 0; i < sz4; i++) {
+      struct gl_program_parameter *p = paramList->Parameters + oldNum + i;
+      p->Name = name ? strdup(name) : NULL;
+      p->Type = type;
+      p->Size = size;
+      p->DataType = datatype;
+      if (values) {
+         if (size >= 4) {
+            COPY_4V(paramList->ParameterValues[oldNum + i], values);
+         } else {
+            /* copy 1, 2 or 3 values */
+            GLuint remaining = size % 4;
+            assert(remaining < 4);
+            for (j = 0; j < remaining; j++) {
+               paramList->ParameterValues[oldNum + i][j].f = values[j].f;
             }
-            else {
-               /* copy 1, 2 or 3 values */
-               GLuint remaining = size % 4;
-               assert(remaining < 4);
-               for (j = 0; j < remaining; j++) {
-                  paramList->ParameterValues[oldNum + i][j].f = values[j].f;
-               }
-               /* fill in remaining positions with zeros */
-               for (; j < 4; j++) {
-                  paramList->ParameterValues[oldNum + i][j].f = 0.0f;
-               }
+            /* fill in remaining positions with zeros */
+            for (; j < 4; j++) {
+               paramList->ParameterValues[oldNum + i][j].f = 0.0f;
             }
-            values += 4;
-            p->Initialized = GL_TRUE;
          }
-         else {
-            /* silence valgrind */
-            for (j = 0; j < 4; j++)
-               paramList->ParameterValues[oldNum + i][j].f = 0;
-         }
-         size -= 4;
-      }
-
-      if (state) {
-         for (i = 0; i < STATE_LENGTH; i++)
-            paramList->Parameters[oldNum].StateIndexes[i] = state[i];
+         values += 4;
+         p->Initialized = GL_TRUE;
+      } else {
+         /* silence valgrind */
+         for (j = 0; j < 4; j++)
+            paramList->ParameterValues[oldNum + i][j].f = 0;
       }
+      size -= 4;
+   }
 
-      return (GLint) oldNum;
+   if (state) {
+      for (i = 0; i < STATE_LENGTH; i++)
+         paramList->Parameters[oldNum].StateIndexes[i] = state[i];
    }
+
+   return (GLint) oldNum;
 }
 
 
-- 
2.5.5



More information about the mesa-dev mailing list