[babl] Change occurences of assert (0) into babl_fatal()



commit da4da8fbe0abfcb994a4d0fd2c93e6093daf457f
Author: Danny Robson <danny blubinc net>
Date:   Sun Jul 19 22:50:37 2009 +1000

    Change occurences of assert (0) into babl_fatal()
    
    babl_fatal() is the more appropriate method to die upon failure, so
    all instances of assert (0) have been changed into babl_fatal() with
    some attempt of an error message.
    
    In this process, the babl_fish_process() method was refactored into
    using the existing case statement.
    
    Bug #589027.

 babl/babl-fish-stats.c |    2 +-
 babl/babl-fish.c       |   44 ++++++++++++++++++++------------------------
 2 files changed, 21 insertions(+), 25 deletions(-)
---
diff --git a/babl/babl-fish-stats.c b/babl/babl-fish-stats.c
index 5348303..cb83b0e 100644
--- a/babl/babl-fish-stats.c
+++ b/babl/babl-fish-stats.c
@@ -132,7 +132,7 @@ table_destination_each (Babl *babl,
             break;
 
           default:
-            babl_assert (0);
+            babl_fatal ("Unknown fish type");
             break;
         }
     }
diff --git a/babl/babl-fish.c b/babl/babl-fish.c
index 622ca25..ae25bcb 100644
--- a/babl/babl-fish.c
+++ b/babl/babl-fish.c
@@ -291,37 +291,33 @@ babl_fish_process (Babl *babl,
   switch (babl->class_type)
     {
       case BABL_FISH_REFERENCE:
-      case BABL_FISH_SIMPLE:
-      case BABL_FISH_PATH:
-        if (babl->class_type == BABL_FISH_REFERENCE)
+        if (babl->fish.source == babl->fish.destination)
+          { /* XXX: we're assuming linear buffers */
+            memcpy (destination, source, n * babl->fish.source->format.bytes_per_pixel);
+            ret = n;
+          }
+        else
           {
-            if (babl->fish.source == babl->fish.destination)
-              { /* XXX: we're assuming linear buffers */
-                memcpy (destination, source, n * babl->fish.source->format.bytes_per_pixel);
-                ret = n;
-              }
-            else
-              {
-                ret = babl_fish_reference_process (babl, source, destination, n);
-              }
+            ret = babl_fish_reference_process (babl, source, destination, n);
           }
-        else if (babl->class_type == BABL_FISH_PATH)
+        break;
+
+      case BABL_FISH_SIMPLE:
+        if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
           {
-            ret = babl_fish_path_process (babl, source, destination, n);
+            ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
+                                           source, destination, n);
           }
-        else if (babl->class_type == BABL_FISH_SIMPLE)
+        else
           {
-            if (BABL (babl->fish_simple.conversion)->class_type == BABL_CONVERSION_LINEAR)
-              {
-                ret = babl_conversion_process (BABL (babl->fish_simple.conversion),
-                                               source, destination, n);
-              }
-            else
-              {
-                babl_assert (0);
-              }
+            babl_fatal ("Cannot use a simple fish to process without a linear conversion");
           }
         break;
+
+      case BABL_FISH_PATH:
+        ret = babl_fish_path_process (babl, source, destination, n);
+        break;
+
       default:
         babl_log ("NYI");
         ret = -1;



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