← Back to team overview

kicad-developers team mailing list archive

Re: [PATCHES] misc minor fixes

 

1 more patch to the set.

vrml_v1 and _v2 model parsers were comparing allocated arrays agains't 0
which can never happen. Also kills gcc warnings.
From 77b84479e8342e4b6c1bda3d4c02a6dba686314f Mon Sep 17 00:00:00 2001
From: Mark Roszko <mark.roszko@xxxxxxxxx>
Date: Sat, 17 Jan 2015 15:45:10 -0500
Subject: [PATCH] An array will never ever be null unless it's a pointer to a
 dynamically allocated array, so don't waste time checking

---
 3d-viewer/vrml_v1_modelparser.cpp | 10 +++++-----
 3d-viewer/vrml_v2_modelparser.cpp | 20 ++++++++++----------
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/3d-viewer/vrml_v1_modelparser.cpp b/3d-viewer/vrml_v1_modelparser.cpp
index 5ada319..814daf3 100644
--- a/3d-viewer/vrml_v1_modelparser.cpp
+++ b/3d-viewer/vrml_v1_modelparser.cpp
@@ -2,7 +2,7 @@
  * This program source code file is part of KiCad, a free EDA CAD application.
  *
  * Copyright (C) 2014 Mario Luzeiro <mrluzeiro@xxxxxxxxx>
- * Copyright (C) 1992-2014 KiCad Developers, see AUTHORS.txt for contributors.
+ * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -93,7 +93,7 @@ void VRML1_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) )
+        if( ( *text == '}' ) || ( *text == ']' ) )
         {
             continue;
         }
@@ -187,7 +187,7 @@ int VRML1_MODEL_PARSER::readMaterial()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -235,7 +235,7 @@ int VRML1_MODEL_PARSER::readCoordinate3()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -263,7 +263,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
diff --git a/3d-viewer/vrml_v2_modelparser.cpp b/3d-viewer/vrml_v2_modelparser.cpp
index 2c21f9b..f1eb477 100644
--- a/3d-viewer/vrml_v2_modelparser.cpp
+++ b/3d-viewer/vrml_v2_modelparser.cpp
@@ -95,7 +95,7 @@ void VRML2_MODEL_PARSER::Load( const wxString& aFilename, double aVrmlunits_to_3
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) )
+        if( ( *text == '}' ) || ( *text == ']' ) )
         {
             continue;
         }
@@ -140,7 +140,7 @@ int VRML2_MODEL_PARSER::read_Transform()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -259,7 +259,7 @@ int VRML2_MODEL_PARSER::read_DEF()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             // DBG( printf( "  skiping %c\n", *text) );
             continue;
@@ -316,7 +316,7 @@ int VRML2_MODEL_PARSER::read_Shape()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -363,7 +363,7 @@ int VRML2_MODEL_PARSER::read_Appearance()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -468,7 +468,7 @@ int VRML2_MODEL_PARSER::read_Material()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -561,7 +561,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -744,7 +744,7 @@ int VRML2_MODEL_PARSER::read_Color()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -774,7 +774,7 @@ int VRML2_MODEL_PARSER::read_Normal()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
@@ -812,7 +812,7 @@ int VRML2_MODEL_PARSER::read_Coordinate()
 
     while( GetNextTag( m_file, text ) )
     {
-        if( ( text == NULL ) || ( *text == ']' ) )
+        if( *text == ']' )
         {
             continue;
         }
-- 
1.9.1


Follow ups

References