[osg-submissions] fix some warning

David Callu ledocc at gmail.com
Tue Sep 4 16:27:49 PDT 2007


Hi Robert,

   I just fix some warning like :

     warning : extra ';'
     warning : unused variable
     warning : comparison between signed and unsigned

    This could be a big update and take a while to revue and apply all
change.
    So I separate warning fix by Node Kit

     Several warning are not fixed like the unused variable warning in
      osgPlugin/osgShadow and osgPlugin/osgViewer because implementation is
not finish.
    Or the "warning: ISO C++ forbids casting between pointer-to-function and
pointer-to-object"
    when mapping GL Extension pointer function on class member.


    All build fine for me with the AGGRESSIVE WARNING flag set.
    I add the OpenSceneGraph/CMakeLists.txt where I remove the -Wnewline-eof
flag only available on APPLE
    change :
-    SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2
-Wno-long-long -Wno-import -pedantic -Wnewline-eof -Wreturn-type
-Wmissing-braces -Wunknown-pragmas -Wunused -fpermissive")
+    SET(OSG_AGGRESSIVE_WARNING_FLAGS "-Wall -Wparentheses -Wformat=2
-Wno-long-long -Wno-import -pedantic -Wreturn-type -Wmissing-braces
-Wunknown-pragmas -Wunused -fpermissive")
+    IF (APPLE)
+        SET(OSG_AGGRESSIVE_WARNING_FLAGS
${OSG_AGGRESSIVE_WARNING_FLAGS}"-Wnewline")
+    ENDIF (APPLE)








detail of all action:


  genwrapper.conf
      remove extra ";" after STD_VECTOR_REFLECTOR macro



*** OSG ***

  src/osg/BufferObject.cpp
      comment unused variable "unsigned int numModified = 0;"
      comment unused variable "unsigned int numNotModified = 0;"

  src/osg/Geometry.cpp
      comment unused variable "unsigned int contextID = state.getContextID
();"

  src/osg/GraphicsContext.cpp
      comment unused variable "GraphicsContext* gc = _compileContext.get();"

  src/osg/GraphicsThread.cpp
      comment unused variable "GraphicsContext* context =
dynamic_cast<GraphicsContext*>(object);"

  src/osg/Camera.cpp
      reorder variable in the Camera constructor and copy constructor




*** OSG DB ***

  src/osgDB/Registry.cpp
      remove extra ";"

  src/osgDB/DatabasePager.cpp
      add base class constructor in copy constructor




*** OSG GA ***

  src/osgGA/EventQueue.cpp
      remove extra ";"




*** OSG Viewer ***

  src/osgViewer/Renderer.cpp
      comment unused variable "osg::Timer_t startDrawTick =
osg::Timer::instance()->tick();"

  src/osgViewer/GraphicsWindowX11.cpp
      comment unused variable "WindowData* inheritedWindowData =
dynamic_cast<WindowData*>(_traits->inheritedWindowData.get());"

  src/osgViewer/CompositeViewer.cpp
      comment unused variable "Scene* scene = view->getScene();"

  src/osgViewer/ViewerEventHandlers.cpp
      cast "unsigned int" to "int"
      reorder variable in the RecordCameraPathHandler constructor




*** OSG Terrain ***

  src/osgTerrain/GeometryTechnique.cpp
      comment unused variable "Scene* scene = view->getScene();"

  src/osgTerrain/Locator.cpp
      reorder variable in the Locator copy constructor




*** OSG Util ***

  include/osgUtil/StateGraph
      reorder variable in the StateGraph copy constructor

  src/osgUtil/CullVisitor.cpp
      comment unused variable "osg::Timer_t start_t =
osg::Timer::instance()->tick();"
      comment unused variable "osg::Timer_t end_t =
osg::Timer::instance()->tick();"

  src/osgUtil/SceneView.cpp
      comment unused variable "osg::State* state = _renderInfo.getState();"




*** OSG Sim ***

  include/osgSim/OverlayNode :
      remove a "," after the last enum
VIEW_DEPENDENT_WITH_PERSPECTIVE_OVERLAY

  src/osgSim/OverlayNode.cpp
      comment unused variable "OverlayData& overlayData" but keep original
action
      change

-    OverlayData& overlayData = getOverlayData(0);
+
+    // force initialization of _overlayDataMap for the key 0 (or NULL)
+    getOverlayData(0);

      comment unused variable "double original_width = max_side-min_side;"

      comment unused variable "double side_over_up = delta_side / delta_up;"

      comment unused variable "double new_width = max_side-min_side;"




*** OSG Manipulator ***

  include/osgManipulator/Dragger
      reorder variable in the PointerInfo copy constructor




*** OSG Plugin ***

*** JPEG

  src/osgPlugins/jpeg/ReaderWriterJPEG.cpp
      remove extra ";"


*** OPENFLIGHT

  src/osgPlugins/OpenFlight/LightPointRecords.cpp
      comment unused variable int32 drawOrder but keep original action
      change
-        int32 drawOrder = in.readInt32();           // for calligraphic
lights
+//        int32 drawOrder =
+        in.readInt32();           // for calligraphic lights



*** LOGO

  src/osgPlugins/logo/ReaderWriterLOGO.cpp
      more complicate : warning is using %d with "unsigned int *" instead of
"int *"
      change
--- src/osgPlugins/logo/ReaderWriterLOGO.cpp    (révision 7360)
+++ src/osgPlugins/logo/ReaderWriterLOGO.cpp    (copie de travail)
@@ -248,12 +248,20 @@
                     pos = Logos::LowerCenter;
                 else if( str == "Camera" )
                 {
-                    unsigned int n;
-                    if( (fscanf( fp, "%d", &n )) != 1 )
+                    int tn;
+                    if( (fscanf( fp, "%d", &tn )) != 1 )
                     {
                         osg::notify(osg::WARN) << "Error... Camera requires
an integer argument\n";
                         break;
                     }
+
+                    if (tn < 0)
+                    {
+                        osg::notify(osg::WARN) << "Error... Camera requires
an positive or null value argument\n";
+                        break;
+                    }
+
+                    unsigned int n = static_cast<unsigned int>(tn);
                     if( screen != n )
                     {
                         screen = n;



*** INVENTOR

  src/osgPlugins/Inventor/ConvertToInventor.cpp
      add default case in switch scope to avoid the warning : enum ... not
handled in switch

      comment unused variable "InventorState *ivGeodeState" but keep
original action
      change :

// Create SoSeparator and convert StateSet for Geode
-  InventorState *ivGeodeState = createInventorState(node.getStateSet());
+//  InventorState *ivGeodeState =
+  createInventorState(node.getStateSet());


      comment unused variable "InventorState *ivState" but keep original
action
      change :

   // Create SoSeparator and convert StateSet
-  InventorState *ivState = createInventorState(node.getStateSet());
+//  InventorState *ivState =
+  createInventorState(node.getStateSet());


  src/osgPlugins/Inventor/GroupSoLOD.cpp
      remove extra ";"

  src/osgPlugins/Inventor/ConvertToInventor.h
      remove extra ";"



*** GIF

  src/osgPlugins/gif/ReaderWriterGIF.cpp
      remove extra ";"



*** TXP

  src/osgPlugins/txp/trpage_print.cpp
  =====
  =====   NEED TO BE CHECKED ON ALL PLATFORM CURRENTLY SUPPORTED =====
  =====
      replace all "%.2lf" by "%.2f"
      the "l" modifier is for long and "f" for double
      but the ISO C++ don't support "%lf" directive
      moreover, all variable fill by this process are double
      change example :
-    sprintf(ls,"front color (RGB) = %.2lf, %.2lf, %.2lf",
+    sprintf(ls,"front color (RGB) = %.2f, %.2f, %.2f",

  src/osgPlugins/txp/ReaderWriterTXP.cpp
      replace "%d" directive for "%u" directive when use with unsigned int
variable
      change :
-        sscanf(name.c_str(),"tile%d_%dx%d_%d",&lod,&x,&y,&id);
+        sscanf(name.c_str(),"tile%d_%dx%d_%u",&lod,&x,&y,&id);


*** NET

  src/osgPlugins/net/sockinet.cpp
  =====
  =====   NEED TO BE CHECKED ON ALL PLATFORM CURRENTLY SUPPORTED =====
  =====
      add the throw() qualifier after the declaration of void
herror(const char*)
      change
-void    herror(const char*);
+// need add throw() under Linux when compile with aggressive warning
+void    herror(const char*) throw();




*** LWO

  src/osgPlugins/lwo/old_Lwo2.cpp
      remove extra ";"




*** DDS

  src/osgPlugins/dds/ReaderWriterDDS.cpp
      replace UNSUPPORTED variable from "int" type to "unsigned int"
      this caused a warning comparison between signed and unsigned type




*** OSG Example ***

  examples/osgdepthpeeling/osgdepthpeeling.cpp
      remove the type of variable osg::Timer_t current_tick =
osg::Timer::instance()->tick();
      It shadowed the current_tick variable define 4 line before

  examples/osgdepthpeeling/Utility.h
      remove extra ";"

  examples/osgdepthpeeling/DePee.cpp
      replace "int" by "unsigned int" for variable i in loop for
      this avoid signed-unsigned comparison warning

      remove extra "+". no warning associated with but most correct
      change

@@ -659,9 +659,9 @@
   _hudText->setText(Utility::toString(_dePeePasses.size())
                    + " Depth Peeling Pass" + (_dePeePasses.size() == 1 ? "
" : "es ")
                    + "((a)dd; (r)emove) "
-                   + (_isEdgy ? "+" : "-") + "(E)dgy " +
-                   + (_isSketchy ? "+" : "-") + "(S)ketchy " +
-                   + (_isColored ? "+" : "-") + "(C)olored " +
+                   + (_isEdgy ? "+" : "-") + "(E)dgy "
+                   + (_isSketchy ? "+" : "-") + "(S)ketchy "
+                   + (_isColored ? "+" : "-") + "(C)olored "
                    + "-> "+Utility::toString(getNumberOfRenderPasses())+ "
Rendering Passes "
                    + "@ "
                    + tmp + " fps");


  examples/osgmovie/osgmovie.cpp
      comment unused variable "bool centerProjection = false;"
      comment unused variable "double rotation = osg::DegreesToRadians(
domeModel.rotationDegrees);"

  examples/osgtext/osgtext.cpp
      reorder variable in the UpdateTextOperation constructor


Cheers
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.openscenegraph.org/pipermail/osg-submissions-openscenegraph.org/attachments/20070905/9326ee00/attachment.htm 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: warning_fix.tgz
Type: application/x-gzip
Size: 188220 bytes
Desc: not available
Url : http://lists.openscenegraph.org/pipermail/osg-submissions-openscenegraph.org/attachments/20070905/9326ee00/attachment-0001.bin 


More information about the osg-submissions mailing list