From 31a71c990d4bbdfb094348be6877143a785414c0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 12 Oct 2014 18:45:37 +0000 Subject: [PATCH] Fix issues with OS X 10.9 compilation, fix issues uncovered by clang --- dtool/src/cppparser/cppManifest.cxx | 4 +-- dtool/src/dtoolbase/dtoolbase_cc.h | 2 ++ dtool/src/dtoolbase/typeHandle.h | 2 +- dtool/src/dtoolutil/filename.cxx | 4 +-- dtool/src/dtoolutil/globPattern.cxx | 2 +- .../interfaceMakerPythonNative.cxx | 6 ++++ dtool/src/interrogate/typeManager.cxx | 3 ++ makepanda/makepanda.py | 17 +++++----- makepanda/makepandacore.py | 33 ++++++++++--------- panda/src/collide/collisionPolygon.cxx | 2 +- panda/src/display/subprocessWindow.cxx | 2 +- panda/src/downloader/bioStreamBuf.cxx | 2 +- panda/src/event/buttonEvent.cxx | 4 +++ panda/src/glstuff/glCgShaderContext_src.cxx | 8 +++-- panda/src/glstuff/glGraphicsBuffer_src.cxx | 8 ++++- .../glstuff/glGraphicsStateGuardian_src.cxx | 19 +++++++++-- panda/src/glstuff/glShaderContext_src.cxx | 3 ++ panda/src/glstuff/glTextureContext_src.h | 2 +- panda/src/grutil/geoMipTerrain.cxx | 4 +-- panda/src/grutil/rigidBodyCombiner.cxx | 4 +-- panda/src/mathutil/triangulator.cxx | 16 +++++---- .../nativenet/buffered_datagramconnection.h | 26 ++++++++++----- panda/src/pgraph/loader.cxx | 11 ++++--- panda/src/pgraph/loaderFileType.cxx | 2 +- panda/src/pgraph/modelSaveRequest.I | 2 +- panda/src/pnmimage/pfmFile.cxx | 3 ++ panda/src/pnmimagetypes/pnmFileTypePNM.cxx | 8 ++--- .../tinydisplay/tinyGraphicsStateGuardian.cxx | 23 +++++++++++-- pandatool/src/maya/maya_funcs.cxx | 3 +- pandatool/src/mayaegg/mayaEggLoader.cxx | 8 ++--- 30 files changed, 157 insertions(+), 76 deletions(-) diff --git a/dtool/src/cppparser/cppManifest.cxx b/dtool/src/cppparser/cppManifest.cxx index 1b4f2c845d..e8843147ac 100644 --- a/dtool/src/cppparser/cppManifest.cxx +++ b/dtool/src/cppparser/cppManifest.cxx @@ -263,7 +263,7 @@ output(ostream &out) const { } if ((*ei)._parm_number >= 0) { - if (stringify) { + if ((*ei)._stringify) { out << "#"; } if ((*ei)._parm_number == _variadic_param) { @@ -345,7 +345,7 @@ save_expansion(const string &exp, const vector_string ¶meter_names) { // Here's the start of an identifier. Find the end of it. size_t q = p; p++; - while (p < exp.size() && isalnum(exp[p]) || exp[p] == '_') { + while (p < exp.size() && (isalnum(exp[p]) || exp[p] == '_')) { p++; } diff --git a/dtool/src/dtoolbase/dtoolbase_cc.h b/dtool/src/dtoolbase/dtoolbase_cc.h index 06f7ede646..94891de299 100644 --- a/dtool/src/dtoolbase/dtoolbase_cc.h +++ b/dtool/src/dtoolbase/dtoolbase_cc.h @@ -123,6 +123,8 @@ typedef ios::seekdir ios_seekdir; #if defined(__has_extension) // Clang magic. #if __has_extension(cxx_constexpr) #define CONSTEXPR constexpr +#else +#define CONSTEXPR INLINE #endif #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) && (__cplusplus >= 201103L) #define CONSTEXPR constexpr diff --git a/dtool/src/dtoolbase/typeHandle.h b/dtool/src/dtoolbase/typeHandle.h index 2ca06169e3..8a92461177 100644 --- a/dtool/src/dtoolbase/typeHandle.h +++ b/dtool/src/dtoolbase/typeHandle.h @@ -138,7 +138,7 @@ PUBLISHED: void inc_memory_usage(MemoryClass memory_class, int size); void dec_memory_usage(MemoryClass memory_class, int size); #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 dec_memory_usage(MemoryClass, int) { } #endif // DO_MEMORY_USAGE diff --git a/dtool/src/dtoolutil/filename.cxx b/dtool/src/dtoolutil/filename.cxx index d2aed13b7e..d15dc738c3 100644 --- a/dtool/src/dtoolutil/filename.cxx +++ b/dtool/src/dtoolutil/filename.cxx @@ -3055,7 +3055,7 @@ atomic_compare_and_exchange_contents(string &orig_contents, return false; } - size_t bytes_read = read(fd, buf, buf_size); + ssize_t bytes_read = read(fd, buf, buf_size); while (bytes_read > 0) { orig_contents += string(buf, bytes_read); bytes_read = read(fd, buf, buf_size); @@ -3176,7 +3176,7 @@ atomic_read_contents(string &contents) const { return false; } - size_t bytes_read = read(fd, buf, buf_size); + ssize_t bytes_read = read(fd, buf, buf_size); while (bytes_read > 0) { contents += string(buf, bytes_read); bytes_read = read(fd, buf, buf_size); diff --git a/dtool/src/dtoolutil/globPattern.cxx b/dtool/src/dtoolutil/globPattern.cxx index 4260625139..a8cbf7552f 100644 --- a/dtool/src/dtoolutil/globPattern.cxx +++ b/dtool/src/dtoolutil/globPattern.cxx @@ -366,7 +366,7 @@ matches_set(string::const_iterator &pi, string::const_iterator pend, char end = (*pi); ++pi; - if (ch >= start && ch <= end || + if ((ch >= start && ch <= end) || (!_case_sensitive && ((tolower(ch) >= start && tolower(ch) <= end) || (toupper(ch) >= start && toupper(ch) <= end)))) { diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 6549bf70fc..ef114d6adf 100755 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -2451,6 +2451,9 @@ write_function_for_top(ostream &out, InterfaceMaker::Object *obj, InterfaceMaker case AT_single_arg: fname += ", PyObject *arg"; break; + + default: + break; } fname += ")"; @@ -3498,6 +3501,9 @@ write_function_instance(ostream &out, InterfaceMaker::Object *obj, ++open_scopes; indent_level += 2; } + + default: + break; } } diff --git a/dtool/src/interrogate/typeManager.cxx b/dtool/src/interrogate/typeManager.cxx index 4539ae9c0a..c13fca7496 100644 --- a/dtool/src/interrogate/typeManager.cxx +++ b/dtool/src/interrogate/typeManager.cxx @@ -1644,6 +1644,9 @@ get_template_parameter_type(CPPType *source_type, int i) { case CPPDeclaration::ST_reference: return get_template_parameter_type(source_type->as_reference_type()->_pointing_at, i); + + default: + break; } CPPStructType *type = source_type->as_struct_type(); diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index f729f0b355..92aa23a7c4 100755 --- a/makepanda/makepanda.py +++ b/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', 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) + 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_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.exe', input=['check_md5_check_md5.obj']) diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 102d2550ea..20ef395724 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1536,20 +1536,18 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None, return 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) for d, v in defs.values(): 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)): if (isinstance(pkgconfig, str) or tool != "pkg-config"): @@ -2280,10 +2278,15 @@ def SetupBuildEnvironment(compiler): # Invoke gcc to determine the system library directories. 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" diff --git a/panda/src/collide/collisionPolygon.cxx b/panda/src/collide/collisionPolygon.cxx index a193d5836c..ae4d74b126 100644 --- a/panda/src/collide/collisionPolygon.cxx +++ b/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(); #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() << "polygon within " << entry.get_into_node_path() << " has normal " << normal << " of length " << normal.length() diff --git a/panda/src/display/subprocessWindow.cxx b/panda/src/display/subprocessWindow.cxx index ebac3ca3c0..ee48608370 100644 --- a/panda/src/display/subprocessWindow.cxx +++ b/panda/src/display/subprocessWindow.cxx @@ -574,7 +574,7 @@ translate_key(int &keycode, int os_code, unsigned int flags) const { keycode = os_code & 0xff; } -#endif __APPLE__ +#endif // __APPLE__ return nk; } diff --git a/panda/src/downloader/bioStreamBuf.cxx b/panda/src/downloader/bioStreamBuf.cxx index 588593f50c..0c07acbab1 100644 --- a/panda/src/downloader/bioStreamBuf.cxx +++ b/panda/src/downloader/bioStreamBuf.cxx @@ -198,7 +198,7 @@ underflow() { #ifdef IS_OSX // occassionally we get -1 on read_open on the mac // 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"; BIO_set_retry_read(*_source); _read_open = true; diff --git a/panda/src/event/buttonEvent.cxx b/panda/src/event/buttonEvent.cxx index 774b5ec0a6..cc8654cf30 100644 --- a/panda/src/event/buttonEvent.cxx +++ b/panda/src/event/buttonEvent.cxx @@ -79,6 +79,8 @@ write_datagram(Datagram &dg) const { case T_resume_down: case T_up: case T_repeat: + case T_raw_down: + case T_raw_up: // We write the button name. This is not particularly compact, but // presumably we don't get thousands of button events per frame, and // 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_up: case T_repeat: + case T_raw_down: + case T_raw_up: _button = ButtonRegistry::ptr()->get_button(scan.get_string()); break; diff --git a/panda/src/glstuff/glCgShaderContext_src.cxx b/panda/src/glstuff/glCgShaderContext_src.cxx index 99a64092a5..581e857d18 100755 --- a/panda/src/glstuff/glCgShaderContext_src.cxx +++ b/panda/src/glstuff/glCgShaderContext_src.cxx @@ -262,19 +262,20 @@ issue_parameters(int altered) { switch(_ptr._info._class) { case Shader::SAC_scalar: cgSetParameter1fv(p,(float*)ptr_data->_ptr); continue; 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_vec2: cgSetParameter2fv(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; + default: nassertd(false) continue; } case Shader::SAC_matrix: cgGLSetMatrixParameterfc(p,(float*)ptr_data->_ptr); continue; case Shader::SAC_array: { - switch(_ptr._info._subclass) { + switch (_ptr._info._subclass) { case Shader::SAC_scalar: cgGLSetParameterArray1f(p,0,_ptr._dim[0],(float*)ptr_data->_ptr); continue; 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 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; @@ -294,6 +295,7 @@ issue_parameters(int altered) { 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_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_array: { diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 8050b7bc4c..ae5e228e9a 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/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: format = GL_DEPTH_COMPONENT32; break; + default: + format = GL_DEPTH_COMPONENT; + break; } } if (_requested_coverage_samples) { @@ -1046,7 +1049,10 @@ bind_slot_multisample(bool rb_resize, Texture **attach, RenderTexturePlane slot, case RTP_aux_float_3: gl_format = GL_RGBA32F_ARB; break; - }; + default: + gl_format = GL_RGBA; + break; + } #endif glgsg->_glBindRenderbuffer(GL_RENDERBUFFER_EXT, _rbm[slot]); if (_requested_coverage_samples) { diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index fda881333c..28caa59c24 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -4892,6 +4892,9 @@ issue_timer_query(int pstats_index) { _pending_timer_queries.push_back(DCAST(TimerQueryContext, query)); return DCAST(TimerQueryContext, query); + +#else + return NULL; #endif } @@ -6838,6 +6841,10 @@ get_numeric_type(Geom::NumericType numeric_type) { case Geom::NT_float64: return GL_DOUBLE; #endif + + case Geom::NT_stdfloat: + // Shouldn't happen, display error. + break; } GLCAT.error() @@ -7123,6 +7130,7 @@ get_external_image_format(Texture *tex) const { case Texture::F_blue: case Texture::F_r16: case Texture::F_r32: + case Texture::F_r32i: return GL_COMPRESSED_RED; case Texture::F_rg16: @@ -7336,7 +7344,11 @@ get_internal_image_format(Texture *tex) const { switch (format) { case Texture::F_color_index: 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_r32i: // Unsupported; fall through to below. break; @@ -7428,8 +7440,6 @@ get_internal_image_format(Texture *tex) const { return GL_COMPRESSED_RGBA_FXT1_3DFX; } return GL_COMPRESSED_LUMINANCE_ALPHA; - } - break; case Texture::F_srgb: 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: return GL_COMPRESSED_SLUMINANCE_ALPHA; + } + break; #endif 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_modulate_glow: 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() diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index d13da80863..386514517d 100755 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -928,6 +928,7 @@ issue_parameters(int altered) { } case Shader::SPT_double: GLCAT.error() << "Passing double-precision shader inputs to GLSL shaders is not currently supported\n"; + default: continue; } } @@ -1441,6 +1442,8 @@ glsl_compile_shader(Shader::ShaderType type) { } break; #endif + default: + break; } if (!handle) { GLCAT.error() diff --git a/panda/src/glstuff/glTextureContext_src.h b/panda/src/glstuff/glTextureContext_src.h index 3eb7515297..af0092dd3e 100644 --- a/panda/src/glstuff/glTextureContext_src.h +++ b/panda/src/glstuff/glTextureContext_src.h @@ -37,7 +37,7 @@ public: GLuint64 get_handle(); #ifdef OPENGLES - CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; }; + static CONSTEXPR bool needs_barrier(GLbitfield barrier) { return false; }; #else bool needs_barrier(GLbitfield barrier); void mark_incoherent(bool wrote); diff --git a/panda/src/grutil/geoMipTerrain.cxx b/panda/src/grutil/geoMipTerrain.cxx index 2398e56e4b..964d13e295 100644 --- a/panda/src/grutil/geoMipTerrain.cxx +++ b/panda/src/grutil/geoMipTerrain.cxx @@ -273,10 +273,10 @@ generate_block(unsigned short mx, double GeoMipTerrain:: get_elevation(double x, double 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 ylo = (unsigned int) y; - if (xlo < 0) xlo = 0; - if (ylo < 0) ylo = 0; if (xlo > _xsize - 2) xlo = _xsize - 2; if (ylo > _ysize - 2) diff --git a/panda/src/grutil/rigidBodyCombiner.cxx b/panda/src/grutil/rigidBodyCombiner.cxx index ef9584f5a1..9eba3b5912 100644 --- a/panda/src/grutil/rigidBodyCombiner.cxx +++ b/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(VertexTransform) next_transform = transform; 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. PT(NodeVertexTransform) new_transform = new NodeVertexTransform(node, transform); _internal_transforms.push_back(new_transform); diff --git a/panda/src/mathutil/triangulator.cxx b/panda/src/mathutil/triangulator.cxx index 1e7a477e44..d0a40ebc83 100644 --- a/panda/src/mathutil/triangulator.cxx +++ b/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 */ - 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; - else if (tr[tr[t].d0].u1 == tnext) + } else if (tr[tr[t].d0].u1 == tnext) { 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; - else if (tr[tr[t].d1].u1 == tnext) + } else if (tr[tr[t].d1].u1 == tnext) { tr[tr[t].d1].u1 = t; + } + } tr[t].lo = tr[tnext].lo; tr[tnext].state = ST_INVALID; /* invalidate the lower */ diff --git a/panda/src/nativenet/buffered_datagramconnection.h b/panda/src/nativenet/buffered_datagramconnection.h index 0935f03b78..2bc949cbcc 100755 --- a/panda/src/nativenet/buffered_datagramconnection.h +++ b/panda/src/nativenet/buffered_datagramconnection.h @@ -34,21 +34,28 @@ private: struct AddressQueue : private pvector // this is used to do a round robin for addres to connect to .. { size_t _active_index; - bool GetNext(Socket_Address &out) - { + + INLINE AddressQueue() : _active_index(0) {} + + bool GetNext(Socket_Address &out) { size_t the_size = size(); - if(the_size == 0) + if (the_size == 0) { return false; - - if(_active_index >= the_size || _active_index < 0) + } + + if (_active_index >= the_size) { _active_index = 0; + } + out = (*this)[_active_index++]; return true; } - void clear() { pvector::clear(); }; - void push_back(Socket_Address &address) - { + INLINE void clear() { + pvector::clear(); + } + + void push_back(Socket_Address &address) { iterator ii; for(ii = begin(); ii != end(); ii++) if(*ii == address) @@ -58,8 +65,9 @@ private: size_t size() { return pvector::size(); }; }; + protected: - // c++ upcals for + // c++ upcalls for virtual void PostConnect(void) { }; virtual void NewWriteBuffer(void) { }; /////////////////////////////////////////// diff --git a/panda/src/pgraph/loader.cxx b/panda/src/pgraph/loader.cxx index 9b1201cf0a..f791b3fc32 100644 --- a/panda/src/pgraph/loader.cxx +++ b/panda/src/pgraph/loader.cxx @@ -396,12 +396,13 @@ save_file(const Filename &filename, const LoaderOptions &options, << "Cannot save " << this_filename << " without filename extension.\n"; } - return NULL; + return false; } LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); LoaderFileType *requested_type = reg->get_type_from_extension(extension); + if (requested_type == (LoaderFileType *)NULL) { if (report_errors) { loader_cat.error() @@ -411,21 +412,23 @@ save_file(const Filename &filename, const LoaderOptions &options, << "Currently known scene file types are:\n"; reg->write(loader_cat.error(false), 2); } - return NULL; + return false; + } else if (!requested_type->supports_save()) { if (report_errors) { loader_cat.error() << requested_type->get_name() << " file type (." << extension << ") does not support saving.\n"; } - return NULL; + return false; + } else if (pz_file && !requested_type->supports_compressed()) { if (report_errors) { loader_cat.error() << requested_type->get_name() << " file type (." << extension << ") does not support in-line compression.\n"; } - return NULL; + return false; } VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr(); diff --git a/panda/src/pgraph/loaderFileType.cxx b/panda/src/pgraph/loaderFileType.cxx index 9c086f3b79..a6256559b6 100644 --- a/panda/src/pgraph/loaderFileType.cxx +++ b/panda/src/pgraph/loaderFileType.cxx @@ -138,5 +138,5 @@ save_file(const Filename &path, const LoaderOptions &options, PandaNode *node) const { loader_cat.error() << get_type() << " cannot save PandaNode objects.\n"; - return NULL; + return false; } diff --git a/panda/src/pgraph/modelSaveRequest.I b/panda/src/pgraph/modelSaveRequest.I index 57dacb18c2..ee02c4a5b1 100755 --- a/panda/src/pgraph/modelSaveRequest.I +++ b/panda/src/pgraph/modelSaveRequest.I @@ -77,6 +77,6 @@ is_ready() const { //////////////////////////////////////////////////////////////////// INLINE bool ModelSaveRequest:: get_success() const { - nassertr(_is_ready, NULL); + nassertr(_is_ready, false); return _success; } diff --git a/panda/src/pnmimage/pfmFile.cxx b/panda/src/pnmimage/pfmFile.cxx index b0a4ddd712..2787950827 100644 --- a/panda/src/pnmimage/pfmFile.cxx +++ b/panda/src/pnmimage/pfmFile.cxx @@ -1811,6 +1811,9 @@ compute_planar_bounds(const LPoint2f ¢er, 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, max_z), LPoint3(min_x, min_y, max_z)); break; + + default: + nassertr(false, NULL); } // Rotate the bounding volume back into the original space of the diff --git a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx index d5ca162efd..45f1888371 100644 --- a/panda/src/pnmimagetypes/pnmFileTypePNM.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypePNM.cxx @@ -556,7 +556,7 @@ pgm_writepgminit(ostream * const fileP, (*fileP) << (char)PGM_MAGIC1 - << (char)(plainFormat || maxval >= 1<<16 ? PGM_MAGIC2 : RPGM_MAGIC2) + << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PGM_MAGIC2 : RPGM_MAGIC2) << '\n' << cols << ' ' << rows << '\n' << maxval << '\n'; } @@ -577,7 +577,7 @@ ppm_writeppminit(ostream* const fileP, (*fileP) << (char)PPM_MAGIC1 - << (char)(plainFormat || maxval >= 1<<16 ? PPM_MAGIC2 : RPPM_MAGIC2) + << (char)(plainFormat /*|| maxval >= 1<<16*/ ? PPM_MAGIC2 : RPPM_MAGIC2) << '\n' << cols << ' ' << rows << '\n' << maxval << '\n'; } @@ -806,7 +806,7 @@ pgm_writepgmrow(ostream* const fileP, gray const maxval, 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); else pgm_writepgmrowraw(fileP, grayrow, cols, maxval); @@ -893,7 +893,7 @@ ppm_writeppmrow(ostream * const fileP, pixval const maxval, 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); else ppm_writeppmrowraw(fileP, pixelrow, cols, maxval); diff --git a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx index 66bc89cfab..79565d668a 100644 --- a/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx +++ b/panda/src/tinydisplay/tinyGraphicsStateGuardian.cxx @@ -1042,7 +1042,9 @@ draw_triangles(const GeomPrimitivePipelineReader *reader, bool force) { break; default: - break; + tinydisplay_cat.error() + << "Invalid index type " << reader->get_index_type() << "!\n"; + return false; } } else { @@ -1161,6 +1163,11 @@ draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force) { } } break; + + default: + tinydisplay_cat.error() + << "Invalid index type " << reader->get_index_type() << "!\n"; + return false; } start = ends[i] + 2; @@ -1258,7 +1265,9 @@ draw_lines(const GeomPrimitivePipelineReader *reader, bool force) { break; default: - break; + tinydisplay_cat.error() + << "Invalid index type " << reader->get_index_type() << "!\n"; + return false; } } else { @@ -1332,7 +1341,9 @@ draw_points(const GeomPrimitivePipelineReader *reader, bool force) { break; default: - break; + tinydisplay_cat.error() + << "Invalid index type " << reader->get_index_type() << "!\n"; + return false; } } else { @@ -2591,6 +2602,12 @@ upload_texture(TinyTextureContext *gtc, bool force) { case Texture::F_luminance_alpha: copy_la_image(dest, xsize, ysize, gtc, level); break; + + default: + tinydisplay_cat.error() + << "Unsupported texture format " + << tex->get_format() << "!\n"; + return false; } bytecount += xsize * ysize * 4; diff --git a/pandatool/src/maya/maya_funcs.cxx b/pandatool/src/maya/maya_funcs.cxx index 661ed10a28..856f3c3aef 100644 --- a/pandatool/src/maya/maya_funcs.cxx +++ b/pandatool/src/maya/maya_funcs.cxx @@ -676,7 +676,8 @@ string_mfndata_type(MFnData::Type type) { return "kSubdSurface"; case MFnData::kLast: - return "kLast"; + default: + break; } return "**invalid**"; diff --git a/pandatool/src/mayaegg/mayaEggLoader.cxx b/pandatool/src/mayaegg/mayaEggLoader.cxx index cb5d472e43..89ef439417 100755 --- a/pandatool/src/mayaegg/mayaEggLoader.cxx +++ b/pandatool/src/mayaegg/mayaEggLoader.cxx @@ -175,7 +175,7 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName 0, &stat ); if ( MS::kSuccess != stat ) { mayaloader_cat.error() - << "Could not create new enum attribute " << fullName << "\n"; + << "Could not create new enum attribute " << fullName.asChar() << "\n"; return stat; } 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); if ( MS::kSuccess != stat ) { mayaloader_cat.error() - << "Could not set value for enum attribute " << fullName << "\n"; + << "Could not set value for enum attribute " << fullName.asChar() << "\n"; return stat; } @@ -195,10 +195,10 @@ MStatus create_enum_attribute(MObject &node, MString fullName, MString briefName fnAttr.setStorable( true ); // 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 ) { mayaloader_cat.error() - << "Could not add new enum attribute " << fullName << "\n"; + << "Could not add new enum attribute " << fullName.asChar() << "\n"; return stat; }