[Bf-blender-cvs] [e9c19b28202] master: Cleanup: avoid boolean literals for functions that return int

Campbell Barton noreply at git.blender.org
Wed Nov 11 06:14:47 CET 2020


Commit: e9c19b28202eb1fdc774d62f23896bf9fafb0fb8
Author: Campbell Barton
Date:   Wed Nov 11 16:14:05 2020 +1100
Branches: master
https://developer.blender.org/rBe9c19b28202eb1fdc774d62f23896bf9fafb0fb8

Cleanup: avoid boolean literals for functions that return int

===================================================================

M	source/blender/imbuf/intern/util.c

===================================================================

diff --git a/source/blender/imbuf/intern/util.c b/source/blender/imbuf/intern/util.c
index 37a1afb5dd7..ae904c5d133 100644
--- a/source/blender/imbuf/intern/util.c
+++ b/source/blender/imbuf/intern/util.c
@@ -167,7 +167,7 @@ int IMB_ispic_type_from_memory(const unsigned char *mem, const size_t mem_size)
   }
 
   for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
-    if (type->is_a) {
+    if (type->is_a != NULL) {
       if (type->is_a(buf)) {
         return type->filetype;
       }
@@ -181,7 +181,7 @@ int IMB_ispic_type(const char *name)
 {
   unsigned char buf[HEADER_SIZE];
   if (!imb_ispic_read_header_from_filename(name, buf)) {
-    return false;
+    return 0;
   }
   return IMB_ispic_type_from_memory(buf, HEADER_SIZE);
 }
@@ -190,7 +190,7 @@ bool IMB_ispic_type_matches(const char *name, int filetype)
 {
   unsigned char buf[HEADER_SIZE];
   if (!imb_ispic_read_header_from_filename(name, buf)) {
-    return false;
+    return 0;
   }
 
   for (const ImFileType *type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) {
@@ -198,10 +198,12 @@ bool IMB_ispic_type_matches(const char *name, int filetype)
       /* Requesting to load a type that can't check it's own header doesn't make sense.
        * Keep the check for developers. */
       BLI_assert(type->is_a != NULL);
-      return type->is_a ? type->is_a(buf) : false;
+      if (type->is_a != NULL) {
+        return type->is_a(buf);
+      }
     }
   }
-  return false;
+  return 0;
 }
 
 #undef HEADER_SIZE
@@ -211,7 +213,7 @@ bool IMB_ispic(const char *name)
   return (IMB_ispic_type(name) != 0);
 }
 
-static int isavi(const char *name)
+static bool isavi(const char *name)
 {
 #ifdef WITH_AVI
   return AVI_is_avi(name);



More information about the Bf-blender-cvs mailing list