Revision: 48411
          http://brlcad.svn.sourceforge.net/brlcad/?rev=48411&view=rev
Author:   indianlarry
Date:     2012-01-11 17:44:49 +0000 (Wed, 11 Jan 2012)
Log Message:
-----------
Added checks on known NULL returning functions to quell NULL_RETURNS issues 
from coverity. Relates to coverity CIDs Run 5 :1853-9

Modified Paths:
--------------
    brlcad/trunk/src/conv/step/CompositeCurveSegment.cpp
    brlcad/trunk/src/conv/step/CurveReplica.cpp
    brlcad/trunk/src/conv/step/DerivedUnitElement.cpp
    brlcad/trunk/src/conv/step/EdgeCurve.cpp
    brlcad/trunk/src/conv/step/Line.cpp
    brlcad/trunk/src/conv/step/Representation.cpp
    brlcad/trunk/src/conv/step/SurfacePatch.cpp

Modified: brlcad/trunk/src/conv/step/CompositeCurveSegment.cpp
===================================================================
--- brlcad/trunk/src/conv/step/CompositeCurveSegment.cpp        2012-01-11 
17:41:34 UTC (rev 48410)
+++ brlcad/trunk/src/conv/step/CompositeCurveSegment.cpp        2012-01-11 
17:44:49 UTC (rev 48411)
@@ -78,7 +78,12 @@
 
     if (parent_curve == NULL) {
        SCLP23(Application_instance) *entity = 
step->getEntityAttribute(sse,"parent_curve");
-       parent_curve = dynamic_cast<Curve *>(Factory::CreateObject(sw,entity)); 
//CreateCurveObject(sw,entity));
+       if (entity != NULL) {
+           parent_curve = dynamic_cast<Curve 
*>(Factory::CreateObject(sw,entity));
+       } else {
+           std::cout << CLASSNAME << ":Error loading member entity 
\"parent_curve\"." << std::endl;
+           return false;
+       }
     }
 
     transition = (Transition_code)step->getEnumAttribute(sse,"transition");

Modified: brlcad/trunk/src/conv/step/CurveReplica.cpp
===================================================================
--- brlcad/trunk/src/conv/step/CurveReplica.cpp 2012-01-11 17:41:34 UTC (rev 
48410)
+++ brlcad/trunk/src/conv/step/CurveReplica.cpp 2012-01-11 17:44:49 UTC (rev 
48411)
@@ -69,12 +69,22 @@
 
     if (parent_curve == NULL) {
        SCLP23(Application_instance) *entity = 
step->getEntityAttribute(sse,"parent_curve");
-       parent_curve = dynamic_cast<Curve *>(Factory::CreateObject(sw,entity)); 
//CreateCurveObject(sw,entity));
+       if (entity != NULL) {
+           parent_curve = dynamic_cast<Curve 
*>(Factory::CreateObject(sw,entity)); //CreateCurveObject(sw,entity));
+       } else {
+           std::cout << CLASSNAME << ":Error loading member field 
\"parent_curve\"." << std::endl;
+           return false;
+       }
     }
 
     if (transformation == NULL) {
        SCLP23(Application_instance) *entity = 
step->getEntityAttribute(sse,"transformation");
-       transformation = dynamic_cast<CartesianTransformationOperator 
*>(Factory::CreateObject(sw,entity));
+       if (entity != NULL) {
+           transformation = dynamic_cast<CartesianTransformationOperator 
*>(Factory::CreateObject(sw,entity));
+       } else {
+           std::cout << CLASSNAME << ":Error loading member field 
\"transformation\"." << std::endl;
+           return false;
+       }
     }
 
     return true;

Modified: brlcad/trunk/src/conv/step/DerivedUnitElement.cpp
===================================================================
--- brlcad/trunk/src/conv/step/DerivedUnitElement.cpp   2012-01-11 17:41:34 UTC 
(rev 48410)
+++ brlcad/trunk/src/conv/step/DerivedUnitElement.cpp   2012-01-11 17:44:49 UTC 
(rev 48411)
@@ -63,8 +63,13 @@
     if (unit == NULL) {
        SCLP23(Application_instance) *se = step->getEntityAttribute(sse,"unit");
 
-       //unit = 
dynamic_cast<NamedUnit*>(Factory::CreateNamedUnitObject(sw,se));
-       unit = (NamedUnit*)Factory::CreateObject(sw,se);
+       if (se != NULL) {
+           //unit = 
dynamic_cast<NamedUnit*>(Factory::CreateNamedUnitObject(sw,se));
+           unit = (NamedUnit*)Factory::CreateObject(sw,se);
+       } else {
+           std::cout << CLASSNAME << ":Error loading member field \"unit\"." 
<< std::endl;
+           return false;
+       }
     }
     exponent = step->getRealAttribute(sse,"exponent");
 

Modified: brlcad/trunk/src/conv/step/EdgeCurve.cpp
===================================================================
--- brlcad/trunk/src/conv/step/EdgeCurve.cpp    2012-01-11 17:41:34 UTC (rev 
48410)
+++ brlcad/trunk/src/conv/step/EdgeCurve.cpp    2012-01-11 17:44:49 UTC (rev 
48411)
@@ -88,11 +88,11 @@
                    edge_geometry->End(edge_start);
                }
            } else {
-               std::cout << CLASSNAME << ":Error loading field 
\"edge_geometry\"." << std::endl;
+               std::cout << CLASSNAME << ":Error loading member field 
\"edge_geometry\"." << std::endl;
                return false;
            }
        } else {
-           std::cout << CLASSNAME << ":Error loading field \"edge_geometry\"." 
<< std::endl;
+           std::cout << CLASSNAME << ":Error loading member field 
\"edge_geometry\"." << std::endl;
            return false;
        }
     }

Modified: brlcad/trunk/src/conv/step/Line.cpp
===================================================================
--- brlcad/trunk/src/conv/step/Line.cpp 2012-01-11 17:41:34 UTC (rev 48410)
+++ brlcad/trunk/src/conv/step/Line.cpp 2012-01-11 17:44:49 UTC (rev 48411)
@@ -88,11 +88,21 @@
 
     if (pnt == NULL) {
        SCLP23(Application_instance) *entity = 
step->getEntityAttribute(sse,"pnt");
-       pnt = dynamic_cast<CartesianPoint *>(Factory::CreateObject(sw,entity));
+       if (entity != NULL) {
+           pnt = dynamic_cast<CartesianPoint 
*>(Factory::CreateObject(sw,entity));
+       } else {
+           std::cout << CLASSNAME << ":Error loading member field \"pnt\"." << 
std::endl;
+           return false;
+       }
     }
     if (dir == NULL) {
        SCLP23(Application_instance) *entity = 
step->getEntityAttribute(sse,"dir");
-       dir = dynamic_cast<Vector *>(Factory::CreateObject(sw,entity));
+       if (entity != NULL) {
+           dir = dynamic_cast<Vector *>(Factory::CreateObject(sw,entity));
+       } else {
+           std::cout << CLASSNAME << ":Error loading member field \"dir\"." << 
std::endl;
+           return false;
+       }
     }
     return true;
 }

Modified: brlcad/trunk/src/conv/step/Representation.cpp
===================================================================
--- brlcad/trunk/src/conv/step/Representation.cpp       2012-01-11 17:41:34 UTC 
(rev 48410)
+++ brlcad/trunk/src/conv/step/Representation.cpp       2012-01-11 17:44:49 UTC 
(rev 48411)
@@ -152,7 +152,7 @@
                RepresentationItem *aRI = dynamic_cast<RepresentationItem 
*>(Factory::CreateObject(sw, entity));
                items.push_back(aRI);
            } else {
-               std::cerr << CLASSNAME << ": Unhandled entity in attribute 
'items'." << std::endl;;
+               std::cerr << CLASSNAME << ": Unhandled entity in attribute 
'items'." << std::endl;
                return false;
            }
        }
@@ -162,53 +162,58 @@
 
     if (context_of_items.empty()) {
        SCLP23(Application_instance) *entity = step->getEntityAttribute(sse, 
"context_of_items");
-       if (entity->IsComplex()) {
-           SCLP23(Application_instance) *sub_entity = step->getEntity(entity, 
"Geometric_Representation_Context");
-           if (sub_entity) {
-               GeometricRepresentationContext *aGRC = new 
GeometricRepresentationContext();
+       if (entity) {
+           if (entity->IsComplex()) {
+               SCLP23(Application_instance) *sub_entity = 
step->getEntity(entity, "Geometric_Representation_Context");
+               if (sub_entity) {
+                   GeometricRepresentationContext *aGRC = new 
GeometricRepresentationContext();
 
-               context_of_items.push_back(aGRC);
-               if (!aGRC->Load(step, sub_entity)) {
-                   std::cout << CLASSNAME << ":Error loading 
GeometricRepresentationContext" << std::endl;;
-                   return false;
+                   context_of_items.push_back(aGRC);
+                   if (!aGRC->Load(step, sub_entity)) {
+                       std::cout << CLASSNAME << ":Error loading 
GeometricRepresentationContext" << std::endl;
+                       return false;
+                   }
                }
-           }
 
-           sub_entity = step->getEntity(entity, 
"Global_Uncertainty_Assigned_Context");
-           if (sub_entity) {
-               GlobalUncertaintyAssignedContext *aGUAC = new 
GlobalUncertaintyAssignedContext();
+               sub_entity = step->getEntity(entity, 
"Global_Uncertainty_Assigned_Context");
+               if (sub_entity) {
+                   GlobalUncertaintyAssignedContext *aGUAC = new 
GlobalUncertaintyAssignedContext();
 
-               context_of_items.push_back(aGUAC);
-               if (!aGUAC->Load(step, sub_entity)) {
-                   std::cout << CLASSNAME << ":Error loading 
GlobalUncertaintyAssignedContext" << std::endl;;
-                   return false;
+                   context_of_items.push_back(aGUAC);
+                   if (!aGUAC->Load(step, sub_entity)) {
+                       std::cout << CLASSNAME << ":Error loading 
GlobalUncertaintyAssignedContext" << std::endl;
+                       return false;
+                   }
                }
-           }
 
-           sub_entity = step->getEntity(entity, 
"Global_Unit_Assigned_Context");
-           if (sub_entity) {
-               GlobalUnitAssignedContext *aGUAC = new 
GlobalUnitAssignedContext();
+               sub_entity = step->getEntity(entity, 
"Global_Unit_Assigned_Context");
+               if (sub_entity) {
+                   GlobalUnitAssignedContext *aGUAC = new 
GlobalUnitAssignedContext();
 
-               context_of_items.push_back(aGUAC);
-               if (!aGUAC->Load(step, sub_entity)) {
-                   std::cout << CLASSNAME << ":Error loading 
GlobalUnitAssignedContext" << std::endl;;
-                   return false;
+                   context_of_items.push_back(aGUAC);
+                   if (!aGUAC->Load(step, sub_entity)) {
+                       std::cout << CLASSNAME << ":Error loading 
GlobalUnitAssignedContext" << std::endl;
+                       return false;
+                   }
                }
-           }
 
-           sub_entity = step->getEntity(entity, 
"Parametric_Representation_Context");
-           if (sub_entity) {
-               ParametricRepresentationContext *aPRC = new 
ParametricRepresentationContext();
+               sub_entity = step->getEntity(entity, 
"Parametric_Representation_Context");
+               if (sub_entity) {
+                   ParametricRepresentationContext *aPRC = new 
ParametricRepresentationContext();
 
-               context_of_items.push_back(aPRC);
-               if (!aPRC->Load(step, sub_entity)) {
-                   std::cout << CLASSNAME << ":Error loading 
ParametricRepresentationContext" << std::endl;;
-                   return false;
+                   context_of_items.push_back(aPRC);
+                   if (!aPRC->Load(step, sub_entity)) {
+                       std::cout << CLASSNAME << ":Error loading 
ParametricRepresentationContext" << std::endl;
+                       return false;
+                   }
                }
+           } else {
+               RepresentationContext *aRC = (RepresentationContext 
*)Factory::CreateObject(sw, entity);
+               context_of_items.push_back(aRC);
            }
        } else {
-           RepresentationContext *aRC = (RepresentationContext 
*)Factory::CreateObject(sw, entity);
-           context_of_items.push_back(aRC);
+           std::cout << CLASSNAME << ":Error loading \"context_of_items\"" << 
std::endl;
+           return false;
        }
     }
     /*
@@ -309,9 +314,9 @@
 void
 Representation::Print(int level) {
     TAB(level); std::cout << CLASSNAME << ":" << name << "(";
-    std::cout << "ID:" << STEPid() << ")" << std::endl;;
+    std::cout << "ID:" << STEPid() << ")" << std::endl;
 
-    TAB(level+1); std::cout << "items:" << std::endl;;
+    TAB(level+1); std::cout << "items:" << std::endl;
     LIST_OF_REPRESENTATION_ITEMS::iterator i;
     for (i=items.begin(); i != items.end(); ++i) {
        //ManifoldSolidBrep *msb = (ManifoldSolidBrep *)(*i);
@@ -320,7 +325,7 @@
        (*i)->Print(level+1);
     }
 
-    TAB(level+1); std::cout << "context_of_items:" << std::endl;;
+    TAB(level+1); std::cout << "context_of_items:" << std::endl;
     LIST_OF_REPRESENTATION_CONTEXT::iterator ic;
     for (ic=context_of_items.begin(); ic != context_of_items.end(); ++ic) {
        (*ic)->Print(level+1);
@@ -337,7 +342,7 @@
        Factory::AddObject(object);
 
        if (!object->Load(sw, sse)) {
-           std::cerr << CLASSNAME << ":Error loading class in ::Create() 
method." << std::endl;;
+           std::cerr << CLASSNAME << ":Error loading class in ::Create() 
method." << std::endl;
            delete object;
            return NULL;
        }

Modified: brlcad/trunk/src/conv/step/SurfacePatch.cpp
===================================================================
--- brlcad/trunk/src/conv/step/SurfacePatch.cpp 2012-01-11 17:41:34 UTC (rev 
48410)
+++ brlcad/trunk/src/conv/step/SurfacePatch.cpp 2012-01-11 17:44:49 UTC (rev 
48411)
@@ -82,7 +82,12 @@
 
     if (parent_surface == NULL) {
        SCLP23(Application_instance) *entity = 
step->getEntityAttribute(sse,"parent_surface");
-       parent_surface = dynamic_cast<BoundedSurface 
*>(Factory::CreateObject(sw,entity)); //CreateCurveObject(sw,entity));
+       if (entity != NULL) {
+           parent_surface = dynamic_cast<BoundedSurface 
*>(Factory::CreateObject(sw,entity));
+       } else {
+           std::cout << CLASSNAME << ":Error loading member field 
\"parent_surface\"." << std::endl;
+           return false;
+       }
     }
 
     u_transition = (Transition_code)step->getEnumAttribute(sse,"u_transition");

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual 
desktops for less than the cost of PCs and save 60% on VDI infrastructure 
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to