Browse Source

Fix issues with OS X 10.9 compilation, fix issues uncovered by clang

rdb 11 years ago
parent
commit
31a71c990d

+ 2 - 2
dtool/src/cppparser/cppManifest.cxx

@@ -263,7 +263,7 @@ output(ostream &out) const {
     }
     }
 
 
     if ((*ei)._parm_number >= 0) {
     if ((*ei)._parm_number >= 0) {
-      if (stringify) {
+      if ((*ei)._stringify) {
         out << "#";
         out << "#";
       }
       }
       if ((*ei)._parm_number == _variadic_param) {
       if ((*ei)._parm_number == _variadic_param) {
@@ -345,7 +345,7 @@ save_expansion(const string &exp, const vector_string &parameter_names) {
       // Here's the start of an identifier.  Find the end of it.
       // Here's the start of an identifier.  Find the end of it.
       size_t q = p;
       size_t q = p;
       p++;
       p++;
-      while (p < exp.size() && isalnum(exp[p]) || exp[p] == '_') {
+      while (p < exp.size() && (isalnum(exp[p]) || exp[p] == '_')) {
         p++;
         p++;
       }
       }
 
 

+ 2 - 0
dtool/src/dtoolbase/dtoolbase_cc.h

@@ -123,6 +123,8 @@ typedef ios::seekdir ios_seekdir;
 #if defined(__has_extension) // Clang magic.
 #if defined(__has_extension) // Clang magic.
 #if __has_extension(cxx_constexpr)
 #if __has_extension(cxx_constexpr)
 #define CONSTEXPR constexpr
 #define CONSTEXPR constexpr
+#else
+#define CONSTEXPR INLINE
 #endif
 #endif
 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && (__cplusplus >= 201103L)
 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && (__cplusplus >= 201103L)
 #define CONSTEXPR constexpr
 #define CONSTEXPR constexpr

+ 1 - 1
dtool/src/dtoolbase/typeHandle.h

@@ -138,7 +138,7 @@ PUBLISHED:
   void inc_memory_usage(MemoryClass memory_class, int size);
   void inc_memory_usage(MemoryClass memory_class, int size);
   void dec_memory_usage(MemoryClass memory_class, int size);
   void dec_memory_usage(MemoryClass memory_class, int size);
 #else
 #else
-  CONSTEXPR int get_memory_usage(MemoryClass) const { return 0; }
+  static CONSTEXPR int get_memory_usage(MemoryClass) { return 0; }
   INLINE void inc_memory_usage(MemoryClass, int) { }
   INLINE void inc_memory_usage(MemoryClass, int) { }
   INLINE void dec_memory_usage(MemoryClass, int) { }
   INLINE void dec_memory_usage(MemoryClass, int) { }
 #endif  // DO_MEMORY_USAGE
 #endif  // DO_MEMORY_USAGE

+ 2 - 2
dtool/src/dtoolutil/filename.cxx

@@ -3055,7 +3055,7 @@ atomic_compare_and_exchange_contents(string &orig_contents,
     return false;
     return false;
   }
   }
     
     
-  size_t bytes_read = read(fd, buf, buf_size);
+  ssize_t bytes_read = read(fd, buf, buf_size);
   while (bytes_read > 0) {
   while (bytes_read > 0) {
     orig_contents += string(buf, bytes_read);
     orig_contents += string(buf, bytes_read);
     bytes_read = read(fd, buf, buf_size);
     bytes_read = read(fd, buf, buf_size);
@@ -3176,7 +3176,7 @@ atomic_read_contents(string &contents) const {
     return false;
     return false;
   }
   }
     
     
-  size_t bytes_read = read(fd, buf, buf_size);
+  ssize_t bytes_read = read(fd, buf, buf_size);
   while (bytes_read > 0) {
   while (bytes_read > 0) {
     contents += string(buf, bytes_read);
     contents += string(buf, bytes_read);
     bytes_read = read(fd, buf, buf_size);
     bytes_read = read(fd, buf, buf_size);

+ 1 - 1
dtool/src/dtoolutil/globPattern.cxx

@@ -366,7 +366,7 @@ matches_set(string::const_iterator &pi, string::const_iterator pend,
         char end = (*pi);
         char end = (*pi);
         ++pi;
         ++pi;
 
 
-        if (ch >= start && ch <= end || 
+        if ((ch >= start && ch <= end) || 
             (!_case_sensitive && 
             (!_case_sensitive && 
              ((tolower(ch) >= start && tolower(ch) <= end) ||
              ((tolower(ch) >= start && tolower(ch) <= end) ||
               (toupper(ch) >= start && toupper(ch) <= end)))) {
               (toupper(ch) >= start && toupper(ch) <= end)))) {

+ 6 - 0
dtool/src/interrogate/interfaceMakerPythonNative.cxx

@@ -2451,6 +2451,9 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker
   case AT_single_arg:
   case AT_single_arg:
     fname += ", PyObject *arg";
     fname += ", PyObject *arg";
     break;
     break;
+
+  default:
+    break;
   }
   }
   fname += ")";
   fname += ")";
 
 
@@ -3498,6 +3501,9 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj,
         ++open_scopes;
         ++open_scopes;
         indent_level += 2;
         indent_level += 2;
       }
       }
+
+    default:
+      break;
     }
     }
   }
   }
 
 

+ 3 - 0
dtool/src/interrogate/typeManager.cxx

@@ -1644,6 +1644,9 @@ get_template_parameter_type(CPPType *source_type, int i) {
 
 
   case CPPDeclaration::ST_reference:
   case CPPDeclaration::ST_reference:
     return get_template_parameter_type(source_type->as_reference_type()->_pointing_at, i);
     return get_template_parameter_type(source_type->as_reference_type()->_pointing_at, i);
+
+  default:
+    break;
   }
   }
 
 
   CPPStructType *type = source_type->as_struct_type();
   CPPStructType *type = source_type->as_struct_type();

+ 10 - 9
makepanda/makepanda.py

@@ -3835,15 +3835,16 @@ if (PkgSkip("OPENSSL")==0 and not RTDIST and not RUNTIME and PkgSkip("DEPLOYTOOL
   TargetAdd('build_patch.exe', input=COMMON_PANDA_LIBS_PYSTUB)
   TargetAdd('build_patch.exe', input=COMMON_PANDA_LIBS_PYSTUB)
   TargetAdd('build_patch.exe', opts=OPTS)
   TargetAdd('build_patch.exe', opts=OPTS)
 
 
-  TargetAdd('check_adler_check_adler.obj', opts=OPTS, input='check_adler.cxx')
-  TargetAdd('check_adler.exe', input=['check_adler_check_adler.obj'])
-  TargetAdd('check_adler.exe', input=COMMON_PANDA_LIBS_PYSTUB)
-  TargetAdd('check_adler.exe', opts=OPTS)
-
-  TargetAdd('check_crc_check_crc.obj', opts=OPTS, input='check_crc.cxx')
-  TargetAdd('check_crc.exe', input=['check_crc_check_crc.obj'])
-  TargetAdd('check_crc.exe', input=COMMON_PANDA_LIBS_PYSTUB)
-  TargetAdd('check_crc.exe', opts=OPTS)
+  if not PkgSkip("ZLIB"):
+    TargetAdd('check_adler_check_adler.obj', opts=OPTS, input='check_adler.cxx')
+    TargetAdd('check_adler.exe', input=['check_adler_check_adler.obj'])
+    TargetAdd('check_adler.exe', input=COMMON_PANDA_LIBS_PYSTUB)
+    TargetAdd('check_adler.exe', opts=OPTS)
+
+    TargetAdd('check_crc_check_crc.obj', opts=OPTS, input='check_crc.cxx')
+    TargetAdd('check_crc.exe', input=['check_crc_check_crc.obj'])
+    TargetAdd('check_crc.exe', input=COMMON_PANDA_LIBS_PYSTUB)
+    TargetAdd('check_crc.exe', opts=OPTS)
 
 
   TargetAdd('check_md5_check_md5.obj', opts=OPTS, input='check_md5.cxx')
   TargetAdd('check_md5_check_md5.obj', opts=OPTS, input='check_md5.cxx')
   TargetAdd('check_md5.exe', input=['check_md5_check_md5.obj'])
   TargetAdd('check_md5.exe', input=['check_md5_check_md5.obj'])

+ 18 - 15
makepanda/makepandacore.py

@@ -1536,20 +1536,18 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None,
         return
         return
 
 
     elif (GetHost() == "darwin" and framework != None):
     elif (GetHost() == "darwin" and framework != None):
-        if (os.path.isdir("/Library/Frameworks/%s.framework" % framework) or
-            os.path.isdir("/System/Library/Frameworks/%s.framework" % framework) or
-            os.path.isdir("/Developer/Library/Frameworks/%s.framework" % framework) or
-            os.path.isdir("/Users/%s/System/Library/Frameworks/%s.framework" % (getpass.getuser(), framework))):
+        prefix = SDK["MACOSX"]
+        if (os.path.isdir(prefix + "/Library/Frameworks/%s.framework" % framework) or
+            os.path.isdir(prefix + "/System/Library/Frameworks/%s.framework" % framework) or
+            os.path.isdir(prefix + "/Developer/Library/Frameworks/%s.framework" % framework) or
+            os.path.isdir(prefix + "/Users/%s/System/Library/Frameworks/%s.framework" % (getpass.getuser(), framework))):
             LibName(target_pkg, "-framework " + framework)
             LibName(target_pkg, "-framework " + framework)
             for d, v in defs.values():
             for d, v in defs.values():
                 DefSymbol(target_pkg, d, v)
                 DefSymbol(target_pkg, d, v)
-        elif (pkg in PkgListGet()):
-            print("%sWARNING:%s Could not locate framework %s, excluding from build" % (GetColor("red"), GetColor(), framework))
-            PkgDisable(pkg)
-        else:
-            print("%sERROR:%s Could not locate framework %s, aborting build" % (GetColor("red"), GetColor(), framework))
-            exit()
-        return
+            return
+
+        elif VERBOSE:
+            print(ColorText("cyan", "Couldn't find the framework %s" % (framework)))
 
 
     elif (LocateBinary(tool) != None and (tool != "pkg-config" or pkgconfig != None)):
     elif (LocateBinary(tool) != None and (tool != "pkg-config" or pkgconfig != None)):
         if (isinstance(pkgconfig, str) or tool != "pkg-config"):
         if (isinstance(pkgconfig, str) or tool != "pkg-config"):
@@ -2280,10 +2278,15 @@ def SetupBuildEnvironment(compiler):
         # Invoke gcc to determine the system library directories.
         # Invoke gcc to determine the system library directories.
         global SYS_LIB_DIRS
         global SYS_LIB_DIRS
 
 
-        # gcc doesn't add this one, but we do want it:
-        local_lib = SDK.get("SYSROOT", "") + "/usr/local/lib"
-        if os.path.isdir(local_lib):
-            SYS_LIB_DIRS.append(local_lib)
+        if sys.platform == "darwin":
+            # We need to add this one explicitly.
+            SYS_LIB_DIRS.append(SDK["MACOSX"] + "/usr/lib")
+
+        elif not SDK["MACOSX"]:
+            # gcc doesn't add this one, but we do want it:
+            local_lib = SDK.get("SYSROOT", "") + "/usr/local/lib"
+            if os.path.isdir(local_lib):
+                SYS_LIB_DIRS.append(local_lib)
 
 
         cmd = GetCXX() + " -print-search-dirs"
         cmd = GetCXX() + " -print-search-dirs"
 
 

+ 1 - 1
panda/src/collide/collisionPolygon.cxx

@@ -473,7 +473,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const {
 
 
   LVector3 normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal();
   LVector3 normal = (has_effective_normal() && sphere->get_respect_effective_normal()) ? get_effective_normal() : get_normal();
 #ifndef NDEBUG
 #ifndef NDEBUG
-  if (!IS_THRESHOLD_EQUAL(normal.length_squared(), 1.0f, 0.001), NULL) {
+  if (!IS_THRESHOLD_EQUAL(normal.length_squared(), 1.0f, 0.001)) {
     collide_cat.info()
     collide_cat.info()
       << "polygon within " << entry.get_into_node_path()
       << "polygon within " << entry.get_into_node_path()
       << " has normal " << normal << " of length " << normal.length()
       << " has normal " << normal << " of length " << normal.length()

+ 1 - 1
panda/src/display/subprocessWindow.cxx

@@ -574,7 +574,7 @@ translate_key(int &keycode, int os_code, unsigned int flags) const {
     keycode = os_code & 0xff;
     keycode = os_code & 0xff;
   }
   }
   
   
-#endif __APPLE__
+#endif  // __APPLE__
 
 
   return nk;
   return nk;
 }
 }

+ 1 - 1
panda/src/downloader/bioStreamBuf.cxx

@@ -198,7 +198,7 @@ underflow() {
 #ifdef IS_OSX
 #ifdef IS_OSX
         // occassionally we get -1 on read_open on the mac
         // occassionally we get -1 on read_open on the mac
         // the os_error is 35 which means "Resource temporarily unavailable".
         // the os_error is 35 which means "Resource temporarily unavailable".
-        if ( (_read_open == -1) && (os_error == 35)) {
+        if (!_read_open && os_error == 35) {
           downloader_cat.warning() << "forcing retry to true again and _read_open to true\n";
           downloader_cat.warning() << "forcing retry to true again and _read_open to true\n";
           BIO_set_retry_read(*_source);
           BIO_set_retry_read(*_source);
           _read_open = true;
           _read_open = true;

+ 4 - 0
panda/src/event/buttonEvent.cxx

@@ -79,6 +79,8 @@ write_datagram(Datagram &dg) const {
   case T_resume_down:
   case T_resume_down:
   case T_up:
   case T_up:
   case T_repeat:
   case T_repeat:
+  case T_raw_down:
+  case T_raw_up:
     // We write the button name.  This is not particularly compact, but
     // We write the button name.  This is not particularly compact, but
     // presumably we don't get thousands of button events per frame, and
     // presumably we don't get thousands of button events per frame, and
     // it is robust as the button index may change between sessions but
     // it is robust as the button index may change between sessions but
@@ -118,6 +120,8 @@ read_datagram(DatagramIterator &scan) {
   case T_resume_down:
   case T_resume_down:
   case T_up:
   case T_up:
   case T_repeat:
   case T_repeat:
+  case T_raw_down:
+  case T_raw_up:
     _button = ButtonRegistry::ptr()->get_button(scan.get_string());
     _button = ButtonRegistry::ptr()->get_button(scan.get_string());
     break;
     break;
 
 

+ 5 - 3
panda/src/glstuff/glCgShaderContext_src.cxx

@@ -262,19 +262,20 @@ issue_parameters(int altered) {
         switch(_ptr._info._class) {
         switch(_ptr._info._class) {
         case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_vector:
         case Shader::SAC_vector:
-          switch(_ptr._info._type) {
+          switch (_ptr._info._type) {
           case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec1: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec2: cgSetParameter2fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4fv(p,(float*)ptr_data->_ptr); continue;
+          default: nassertd(false) continue;
           }
           }
         case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue;
         case Shader::SAC_array: {
         case Shader::SAC_array: {
-          switch(_ptr._info._subclass) {
+          switch (_ptr._info._subclass) {
           case Shader::SAC_scalar:
           case Shader::SAC_scalar:
             cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
           case Shader::SAC_vector:
           case Shader::SAC_vector:
-            switch(_ptr._dim[2]) {
+            switch (_ptr._dim[2]) {
             case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 1: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 2: cgGLSetParameterArray2f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
             case 3: cgGLSetParameterArray3f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue;
@@ -294,6 +295,7 @@ issue_parameters(int altered) {
           case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec2: cgSetParameter2dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec3: cgSetParameter3dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)ptr_data->_ptr); continue;
           case Shader::SAT_vec4: cgSetParameter4dv(p,(double*)ptr_data->_ptr); continue;
+          default: nassertd(false) continue;
           }
           }
         case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)ptr_data->_ptr); continue;
         case Shader::SAC_matrix: cgGLSetMatrixParameterdc(p,(double*)ptr_data->_ptr); continue;
         case Shader::SAC_array: {
         case Shader::SAC_array: {

+ 7 - 1
panda/src/glstuff/glGraphicsBuffer_src.cxx

@@ -1003,6 +1003,9 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot,
           case Texture::F_depth_component32:
           case Texture::F_depth_component32:
             format = GL_DEPTH_COMPONENT32;
             format = GL_DEPTH_COMPONENT32;
             break;
             break;
+          default:
+            format = GL_DEPTH_COMPONENT;
+            break;
         }
         }
       }
       }
       if (_requested_coverage_samples) {
       if (_requested_coverage_samples) {
@@ -1046,7 +1049,10 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot,
       case RTP_aux_float_3:
       case RTP_aux_float_3:
         gl_format = GL_RGBA32F_ARB;
         gl_format = GL_RGBA32F_ARB;
         break;
         break;
-    };
+      default:
+        gl_format = GL_RGBA;
+        break;
+    }
 #endif
 #endif
     glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
     glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]);
     if (_requested_coverage_samples) {
     if (_requested_coverage_samples) {

+ 17 - 2
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -4892,6 +4892,9 @@ issue_timer_query(int pstats_index) {
   _pending_timer_queries.push_back(DCAST(TimerQueryContext, query));
   _pending_timer_queries.push_back(DCAST(TimerQueryContext, query));
 
 
   return DCAST(TimerQueryContext, query);
   return DCAST(TimerQueryContext, query);
+
+#else
+  return NULL;
 #endif
 #endif
 }
 }
 
 
@@ -6838,6 +6841,10 @@ get_numeric_type(Geom::NumericType numeric_type) {
   case Geom::NT_float64:
   case Geom::NT_float64:
     return GL_DOUBLE;
     return GL_DOUBLE;
 #endif
 #endif
+
+  case Geom::NT_stdfloat:
+    // Shouldn't happen, display error.
+    break;
   }
   }
 
 
   GLCAT.error()
   GLCAT.error()
@@ -7123,6 +7130,7 @@ get_external_image_format(Texture *tex) const {
       case Texture::F_blue:
       case Texture::F_blue:
       case Texture::F_r16:
       case Texture::F_r16:
       case Texture::F_r32:
       case Texture::F_r32:
+      case Texture::F_r32i:
         return GL_COMPRESSED_RED;
         return GL_COMPRESSED_RED;
 
 
       case Texture::F_rg16:
       case Texture::F_rg16:
@@ -7336,7 +7344,11 @@ get_internal_image_format(Texture *tex) const {
       switch (format) {
       switch (format) {
       case Texture::F_color_index:
       case Texture::F_color_index:
       case Texture::F_depth_component:
       case Texture::F_depth_component:
+      case Texture::F_depth_component16:
+      case Texture::F_depth_component24:
+      case Texture::F_depth_component32:
       case Texture::F_depth_stencil:
       case Texture::F_depth_stencil:
+      case Texture::F_r32i:
         // Unsupported; fall through to below.
         // Unsupported; fall through to below.
         break;
         break;
 
 
@@ -7428,8 +7440,6 @@ get_internal_image_format(Texture *tex) const {
           return GL_COMPRESSED_RGBA_FXT1_3DFX;
           return GL_COMPRESSED_RGBA_FXT1_3DFX;
         }
         }
         return GL_COMPRESSED_LUMINANCE_ALPHA;
         return GL_COMPRESSED_LUMINANCE_ALPHA;
-      }
-      break;
 
 
       case Texture::F_srgb:
       case Texture::F_srgb:
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
         if (get_supports_compressed_texture_format(Texture::CM_dxt1) && !is_3d) {
@@ -7448,6 +7458,8 @@ get_internal_image_format(Texture *tex) const {
 
 
       case Texture::F_sluminance_alpha:
       case Texture::F_sluminance_alpha:
         return GL_COMPRESSED_SLUMINANCE_ALPHA;
         return GL_COMPRESSED_SLUMINANCE_ALPHA;
+      }
+      break;
 #endif
 #endif
 
 
     case Texture::CM_dxt1:
     case Texture::CM_dxt1:
@@ -7802,6 +7814,9 @@ get_texture_apply_mode_type(TextureStage::Mode am) {
   case TextureStage::M_blend_color_scale: return GL_BLEND;
   case TextureStage::M_blend_color_scale: return GL_BLEND;
   case TextureStage::M_modulate_glow: return GL_MODULATE;
   case TextureStage::M_modulate_glow: return GL_MODULATE;
   case TextureStage::M_modulate_gloss: return GL_MODULATE;
   case TextureStage::M_modulate_gloss: return GL_MODULATE;
+  default:
+    // Other modes shouldn't get here.  Fall through and error.
+    break;
   }
   }
 
 
   GLCAT.error()
   GLCAT.error()

+ 3 - 0
panda/src/glstuff/glShaderContext_src.cxx

@@ -928,6 +928,7 @@ issue_parameters(int altered) {
         }
         }
       case Shader::SPT_double:
       case Shader::SPT_double:
         GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n";
         GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n";
+      default:
         continue;
         continue;
       }
       }
     }
     }
@@ -1441,6 +1442,8 @@ glsl_compile_shader(Shader::ShaderType type) {
       }
       }
       break;
       break;
 #endif
 #endif
+    default:
+      break;
   }
   }
   if (!handle) {
   if (!handle) {
     GLCAT.error()
     GLCAT.error()

+ 1 - 1
panda/src/glstuff/glTextureContext_src.h

@@ -37,7 +37,7 @@ public:
   GLuint64 get_handle();
   GLuint64 get_handle();
 
 
 #ifdef OPENGLES
 #ifdef OPENGLES
-  CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; };
+  static CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; };
 #else
 #else
   bool needs_barrier(GLbitfield barrier);
   bool needs_barrier(GLbitfield barrier);
   void mark_incoherent(bool wrote);
   void mark_incoherent(bool wrote);

+ 2 - 2
panda/src/grutil/geoMipTerrain.cxx

@@ -273,10 +273,10 @@ generate_block(unsigned short mx,
 double GeoMipTerrain::
 double GeoMipTerrain::
 get_elevation(double x, double y) {
 get_elevation(double x, double y) {
   y = (_ysize - 1) - y;
   y = (_ysize - 1) - y;
+  if (x < 0.0) x = 0.0;
+  if (y < 0.0) y = 0.0;
   unsigned int xlo = (unsigned int) x;
   unsigned int xlo = (unsigned int) x;
   unsigned int ylo = (unsigned int) y;
   unsigned int ylo = (unsigned int) y;
-  if (xlo < 0) xlo = 0;
-  if (ylo < 0) ylo = 0;
   if (xlo > _xsize - 2)
   if (xlo > _xsize - 2)
     xlo = _xsize - 2;
     xlo = _xsize - 2;
   if (ylo > _ysize - 2)
   if (ylo > _ysize - 2)

+ 2 - 2
panda/src/grutil/rigidBodyCombiner.cxx

@@ -192,8 +192,8 @@ r_collect(PandaNode *node, const RenderState *state,
   CPT(RenderState) next_state = state->compose(node->get_state());
   CPT(RenderState) next_state = state->compose(node->get_state());
   CPT(VertexTransform) next_transform = transform;
   CPT(VertexTransform) next_transform = transform;
   if (!node->get_transform()->is_identity() ||
   if (!node->get_transform()->is_identity() ||
-      node->is_of_type(ModelNode::get_class_type()) &&
-      DCAST(ModelNode, node)->get_preserve_transform() != ModelNode::PT_none) {
+      (node->is_of_type(ModelNode::get_class_type()) &&
+       DCAST(ModelNode, node)->get_preserve_transform() != ModelNode::PT_none)) {
     // This node has a transform we need to keep.
     // This node has a transform we need to keep.
     PT(NodeVertexTransform) new_transform = new NodeVertexTransform(node, transform);
     PT(NodeVertexTransform) new_transform = new NodeVertexTransform(node, transform);
     _internal_transforms.push_back(new_transform);
     _internal_transforms.push_back(new_transform);

+ 10 - 6
panda/src/mathutil/triangulator.cxx

@@ -854,17 +854,21 @@ merge_trapezoids(int segnum, int tfirst, int tlast, int side) {
 
 
               /* Change the upper neighbours of the lower trapezoids */
               /* Change the upper neighbours of the lower trapezoids */
 
 
-              if ((tr[t].d0 = tr[tnext].d0) > 0)
-                if (tr[tr[t].d0].u0 == tnext)
+              if ((tr[t].d0 = tr[tnext].d0) > 0) {
+                if (tr[tr[t].d0].u0 == tnext) {
                   tr[tr[t].d0].u0 = t;
                   tr[tr[t].d0].u0 = t;
-                else if (tr[tr[t].d0].u1 == tnext)
+                } else if (tr[tr[t].d0].u1 == tnext) {
                   tr[tr[t].d0].u1 = t;
                   tr[tr[t].d0].u1 = t;
+                }
+              }
 
 
-              if ((tr[t].d1 = tr[tnext].d1) > 0)
-                if (tr[tr[t].d1].u0 == tnext)
+              if ((tr[t].d1 = tr[tnext].d1) > 0) {
+                if (tr[tr[t].d1].u0 == tnext) {
                   tr[tr[t].d1].u0 = t;
                   tr[tr[t].d1].u0 = t;
-                else if (tr[tr[t].d1].u1 == tnext)
+                } else if (tr[tr[t].d1].u1 == tnext) {
                   tr[tr[t].d1].u1 = t;
                   tr[tr[t].d1].u1 = t;
+                }
+              }
 
 
               tr[t].lo = tr[tnext].lo;
               tr[t].lo = tr[tnext].lo;
               tr[tnext].state = ST_INVALID; /* invalidate the lower */
               tr[tnext].state = ST_INVALID; /* invalidate the lower */

+ 17 - 9
panda/src/nativenet/buffered_datagramconnection.h

@@ -34,21 +34,28 @@ private:
   struct AddressQueue : private pvector<Socket_Address> // this is used to do a round robin for addres to connect to ..
   struct AddressQueue : private pvector<Socket_Address> // this is used to do a round robin for addres to connect to ..
   {   
   {   
     size_t _active_index;   
     size_t _active_index;   
-    bool GetNext(Socket_Address &out) 
-    {
+
+    INLINE AddressQueue() : _active_index(0) {}
+
+    bool GetNext(Socket_Address &out) {
       size_t the_size = size();
       size_t the_size = size();
-      if(the_size == 0)
+      if (the_size == 0) {
         return false;
         return false;
-      
-      if(_active_index >= the_size || _active_index < 0)
+      }
+
+      if (_active_index >= the_size) {
         _active_index = 0;
         _active_index = 0;
+      }
+
       out = (*this)[_active_index++];   
       out = (*this)[_active_index++];   
       return true;
       return true;
     }            
     }            
 
 
-    void clear() { pvector<Socket_Address>::clear(); };
-    void push_back(Socket_Address &address)
-    {
+    INLINE void clear() {
+      pvector<Socket_Address>::clear();
+    }
+
+    void push_back(Socket_Address &address) {
       iterator ii;
       iterator ii;
       for(ii = begin(); ii != end(); ii++)
       for(ii = begin(); ii != end(); ii++)
         if(*ii == address)
         if(*ii == address)
@@ -58,8 +65,9 @@ private:
 
 
     size_t size() { return pvector<Socket_Address>::size(); };
     size_t size() { return pvector<Socket_Address>::size(); };
   };
   };
+
 protected:
 protected:
-  // c++ upcals for 
+  // c++ upcalls for 
   virtual void PostConnect(void) { };
   virtual void PostConnect(void) { };
   virtual void NewWriteBuffer(void) { };
   virtual void NewWriteBuffer(void) { };
   ///////////////////////////////////////////
   ///////////////////////////////////////////

+ 7 - 4
panda/src/pgraph/loader.cxx

@@ -396,12 +396,13 @@ save_file(const Filename &filename, const LoaderOptions &options,
         << "Cannot save " << this_filename
         << "Cannot save " << this_filename
         << " without filename extension.\n";
         << " without filename extension.\n";
     }
     }
-    return NULL;
+    return false;
   }
   }
 
 
   LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
   LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr();
   LoaderFileType *requested_type =
   LoaderFileType *requested_type =
     reg->get_type_from_extension(extension);
     reg->get_type_from_extension(extension);
+
   if (requested_type == (LoaderFileType *)NULL) {
   if (requested_type == (LoaderFileType *)NULL) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
@@ -411,21 +412,23 @@ save_file(const Filename &filename, const LoaderOptions &options,
         << "Currently known scene file types are:\n";
         << "Currently known scene file types are:\n";
       reg->write(loader_cat.error(false), 2);
       reg->write(loader_cat.error(false), 2);
     }
     }
-    return NULL;
+    return false;
+
   } else if (!requested_type->supports_save()) {
   } else if (!requested_type->supports_save()) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
         << requested_type->get_name() << " file type (."
         << requested_type->get_name() << " file type (."
         << extension << ") does not support saving.\n";
         << extension << ") does not support saving.\n";
     }
     }
-    return NULL;
+    return false;
+
   } else if (pz_file && !requested_type->supports_compressed()) {
   } else if (pz_file && !requested_type->supports_compressed()) {
     if (report_errors) {
     if (report_errors) {
       loader_cat.error()
       loader_cat.error()
         << requested_type->get_name() << " file type (."
         << requested_type->get_name() << " file type (."
         << extension << ") does not support in-line compression.\n";
         << extension << ") does not support in-line compression.\n";
     }
     }
-    return NULL;
+    return false;
   }
   }
 
 
   VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
   VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();

+ 1 - 1
panda/src/pgraph/loaderFileType.cxx

@@ -138,5 +138,5 @@ save_file(const Filename &path, const LoaderOptions &options,
           PandaNode *node) const {
           PandaNode *node) const {
   loader_cat.error()
   loader_cat.error()
     << get_type() << " cannot save PandaNode objects.\n";
     << get_type() << " cannot save PandaNode objects.\n";
-  return NULL;
+  return false;
 }
 }

+ 1 - 1
panda/src/pgraph/modelSaveRequest.I

@@ -77,6 +77,6 @@ is_ready() const {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 INLINE bool ModelSaveRequest::
 INLINE bool ModelSaveRequest::
 get_success() const {
 get_success() const {
-  nassertr(_is_ready, NULL);
+  nassertr(_is_ready, false);
   return _success;
   return _success;
 }
 }

+ 3 - 0
panda/src/pnmimage/pfmFile.cxx

@@ -1811,6 +1811,9 @@ compute_planar_bounds(const LPoint2f &center, PN_float32 point_dist, PN_float32
        LPoint3(max_x, min_y, min_z), LPoint3(min_x, min_y, min_z),
        LPoint3(max_x, min_y, min_z), LPoint3(min_x, min_y, min_z),
        LPoint3(max_x, min_y, max_z), LPoint3(min_x, min_y, max_z));
        LPoint3(max_x, min_y, max_z), LPoint3(min_x, min_y, max_z));
     break;
     break;
+
+  default:
+    nassertr(false, NULL);
   }
   }
 
 
   // Rotate the bounding volume back into the original space of the
   // Rotate the bounding volume back into the original space of the

+ 4 - 4
panda/src/pnmimagetypes/pnmFileTypePNM.cxx

@@ -556,7 +556,7 @@ pgm_writepgminit(ostream * const fileP,
 
 
   (*fileP) 
   (*fileP) 
     << (char)PGM_MAGIC1
     << (char)PGM_MAGIC1
-    << (char)(plainFormat || maxval >= 1<<16 ? PGM_MAGIC2 : RPGM_MAGIC2)
+    << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PGM_MAGIC2 : RPGM_MAGIC2)
     << '\n'
     << '\n'
     << cols << ' ' << rows << '\n' << maxval << '\n';
     << cols << ' ' << rows << '\n' << maxval << '\n';
 }
 }
@@ -577,7 +577,7 @@ ppm_writeppminit(ostream*  const fileP,
 
 
   (*fileP) 
   (*fileP) 
     << (char)PPM_MAGIC1
     << (char)PPM_MAGIC1
-    << (char)(plainFormat || maxval >= 1<<16 ? PPM_MAGIC2 : RPPM_MAGIC2)
+    << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PPM_MAGIC2 : RPPM_MAGIC2)
     << '\n'
     << '\n'
     << cols << ' ' << rows << '\n' << maxval << '\n';
     << cols << ' ' << rows << '\n' << maxval << '\n';
 }
 }
@@ -806,7 +806,7 @@ pgm_writepgmrow(ostream* const fileP,
                 gray  const maxval, 
                 gray  const maxval, 
                 int   const forceplain) {
                 int   const forceplain) {
 
 
-  if (forceplain || pm_plain_output || maxval >= 1<<16)
+  if (forceplain || pm_plain_output /*|| maxval >= 1<<16*/)
     pgm_writepgmrowplain(fileP, grayrow, cols, maxval);
     pgm_writepgmrowplain(fileP, grayrow, cols, maxval);
   else
   else
     pgm_writepgmrowraw(fileP, grayrow, cols, maxval);
     pgm_writepgmrowraw(fileP, grayrow, cols, maxval);
@@ -893,7 +893,7 @@ ppm_writeppmrow(ostream *  const fileP,
                 pixval  const maxval, 
                 pixval  const maxval, 
                 int     const forceplain) {
                 int     const forceplain) {
 
 
-  if (forceplain || pm_plain_output || maxval >= 1<<16) 
+  if (forceplain || pm_plain_output /*|| maxval >= 1<<16*/)
     ppm_writeppmrowplain(fileP, pixelrow, cols, maxval);
     ppm_writeppmrowplain(fileP, pixelrow, cols, maxval);
   else 
   else 
     ppm_writeppmrowraw(fileP, pixelrow, cols, maxval);
     ppm_writeppmrowraw(fileP, pixelrow, cols, maxval);

+ 20 - 3
panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx

@@ -1042,7 +1042,9 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) {
       break;
       break;
 
 
     default:
     default:
-      break;
+      tinydisplay_cat.error()
+        << "Invalid index type " << reader->get_index_type() << "!\n";
+      return false;
     }
     }
 
 
   } else {
   } else {
@@ -1161,6 +1163,11 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) {
           }
           }
         }
         }
         break;
         break;
+
+      default:
+        tinydisplay_cat.error()
+          << "Invalid index type " << reader->get_index_type() << "!\n";
+        return false;
       }
       }
 
 
       start = ends[i] + 2;
       start = ends[i] + 2;
@@ -1258,7 +1265,9 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) {
       break;
       break;
 
 
     default:
     default:
-      break;
+      tinydisplay_cat.error()
+        << "Invalid index type " << reader->get_index_type() << "!\n";
+      return false;
     }
     }
 
 
   } else {
   } else {
@@ -1332,7 +1341,9 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) {
       break;
       break;
 
 
     default:
     default:
-      break;
+      tinydisplay_cat.error()
+        << "Invalid index type " << reader->get_index_type() << "!\n";
+      return false;
     }
     }
 
 
   } else {
   } else {
@@ -2591,6 +2602,12 @@ upload_texture(TinyTextureContext *gtc, bool force) {
     case Texture::F_luminance_alpha:
     case Texture::F_luminance_alpha:
       copy_la_image(dest, xsize, ysize, gtc, level);
       copy_la_image(dest, xsize, ysize, gtc, level);
       break;
       break;
+
+    default:
+      tinydisplay_cat.error()
+        << "Unsupported texture format "
+        << tex->get_format() << "!\n";
+      return false;
     }
     }
 
 
     bytecount += xsize * ysize * 4;
     bytecount += xsize * ysize * 4;

+ 2 - 1
pandatool/src/maya/maya_funcs.cxx

@@ -676,7 +676,8 @@ string_mfndata_type(MFnData::Type type) {
     return "kSubdSurface";
     return "kSubdSurface";
 
 
   case MFnData::kLast:
   case MFnData::kLast:
-    return "kLast";
+  default:
+    break;
   }
   }
 
 
   return "**invalid**";
   return "**invalid**";

+ 4 - 4
pandatool/src/mayaegg/mayaEggLoader.cxx

@@ -175,7 +175,7 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName
                                    0, &stat );
                                    0, &stat );
   if ( MS::kSuccess != stat ) {
   if ( MS::kSuccess != stat ) {
     mayaloader_cat.error()
     mayaloader_cat.error()
-      << "Could not create new enum attribute " << fullName << "\n";
+      << "Could not create new enum attribute " << fullName.asChar() << "\n";
     return stat;
     return stat;
   }
   }
   for (unsigned i = 0; i < fieldNames.length(); i++){
   for (unsigned i = 0; i < fieldNames.length(); i++){
@@ -185,7 +185,7 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName
   stat = fnAttr.setDefault(fieldIndex);
   stat = fnAttr.setDefault(fieldIndex);
   if ( MS::kSuccess != stat ) {
   if ( MS::kSuccess != stat ) {
     mayaloader_cat.error()
     mayaloader_cat.error()
-      << "Could not set value for enum attribute " << fullName << "\n";
+      << "Could not set value for enum attribute " << fullName.asChar() << "\n";
     return stat;
     return stat;
   }
   }
 
 
@@ -195,10 +195,10 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName
   fnAttr.setStorable( true ); 
   fnAttr.setStorable( true ); 
 
 
   // Now add the new attribute to this dependency node
   // Now add the new attribute to this dependency node
-  stat = fnDN.addAttribute(newAttr,MFnDependencyNode::kLocalDynamicAttr);
+  stat = fnDN.addAttribute(newAttr, MFnDependencyNode::kLocalDynamicAttr);
   if ( MS::kSuccess != stat ) {
   if ( MS::kSuccess != stat ) {
     mayaloader_cat.error()
     mayaloader_cat.error()
-      << "Could not add new enum attribute " << fullName << "\n";
+      << "Could not add new enum attribute " << fullName.asChar() << "\n";
     return stat;
     return stat;
   }
   }