gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] [patch] Fix more compile warnings


From: Petter Reinholdtsen
Subject: [Gnash-dev] [patch] Fix more compile warnings
Date: Thu, 30 Mar 2006 10:12:29 +0200
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (usg-unix-v)

Here are a few more patches for gnash to get rid of compiler warnings
and fix bugs in the code.  First, a few leftover -Wall in Makefile.am:

Index: libamf/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/libamf/Makefile.am,v
retrieving revision 1.4
diff -u -3 -p -r1.4 Makefile.am
--- libamf/Makefile.am  9 Mar 2006 19:29:05 -0000       1.4
+++ libamf/Makefile.am  30 Mar 2006 07:39:54 -0000
@@ -40,7 +40,7 @@
 AUTOMAKE_OPTIONS =

 AM_CXXFLAGS =  $(CFLAGS) $(SDL_CFLAGS) $(INCLUDES)
-AM_CPPFLAGS = -Wall
+AM_CPPFLAGS =
 AM_LDFLAGS = \
        ../libbase/libgnashbase.la \
         $(OPENGL_LIBS)      \
Index: server/Makefile.am
===================================================================
RCS file: /sources/gnash/gnash/server/Makefile.am,v
retrieving revision 1.24
diff -u -3 -p -r1.24 Makefile.am
--- server/Makefile.am  11 Mar 2006 19:24:27 -0000      1.24
+++ server/Makefile.am  30 Mar 2006 07:39:54 -0000
@@ -39,7 +39,7 @@

 AUTOMAKE_OPTIONS =

-AM_CPPFLAGS = -Wall
+AM_CPPFLAGS =

 # noinst_LTLIBRARIES = libserver.la libasobjs.la
 lib_LTLIBRARIES = libgnashserver.la libgnashasobjs.la

Next, there are a few functions with non-void return type but without
return value.  I'm not sure if they should throw an error or return a
bogus value, but here is a draft patch returning a bogus value.

Index: server/xmlnode.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/xmlnode.cpp,v
retrieving revision 1.7
diff -u -3 -p -r1.7 xmlnode.cpp
--- server/xmlnode.cpp  9 Mar 2006 19:29:07 -0000       1.7
+++ server/xmlnode.cpp  30 Mar 2006 07:39:54 -0000
@@ -284,6 +284,7 @@ XMLNode::previousSibling(int x)
     if (_objects.size() > 0) {
        return _objects[x-1];
     }
+    return NULL;
 }

 as_object *
@@ -293,6 +294,7 @@ XMLNode::nextSibling(int x)
     if (x < (int) _objects.size()) {
        return _objects[x];
     }
+    return NULL;
 }

 void
Index: server/network.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/network.cpp,v
retrieving revision 1.5
diff -u -3 -p -r1.5 network.cpp
--- server/network.cpp  9 Mar 2006 19:29:06 -0000       1.5
+++ server/network.cpp  30 Mar 2006 08:02:05 -0000
@@ -305,6 +305,7 @@ Network::createClient(void)
 bool
 Network::createClient(short port)
 {
+    return false;
 }
 bool
 Network::createClient(const char *hostname)

There is also quite a few places where const values are converted to
non-const values before they are used.  This is a bad idea as linux
some times places const values in a read-only segment of memory.  This
patch solves a few of them:

Index: libbase/triangulate_impl.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/triangulate_impl.h,v
retrieving revision 1.7
diff -u -3 -p -r1.7 triangulate_impl.h
--- libbase/triangulate_impl.h  25 Feb 2006 03:54:03 -0000      1.7
+++ libbase/triangulate_impl.h  30 Mar 2006 08:02:54 -0000
@@ -612,8 +612,8 @@ void        poly<coord_t>::invalidate(const std
 template<class coord_t>
 int    compare_polys_by_leftmost_vert(const void* a, const void* b)
 {
-       const poly<coord_t>*    poly_a = * (const poly<coord_t>**) a;
-       const poly<coord_t>*    poly_b = * (const poly<coord_t>**) b;
+       const poly<coord_t>*    poly_a = * (const poly<coord_t>* const *) a;
+       const poly<coord_t>*    poly_b = * (const poly<coord_t>* const *) b;
 
        // Vert indices are sorted, so we just compare the indices,
        // not the actual vert coords.
@@ -705,7 +705,7 @@ int poly<coord_t>::find_valid_bridge_ver
        {
                const poly_vert<coord_t>*       pvi = &sorted_verts[vi];
 
-               assert(compare_vertices<coord_t>((void*) pvi, (void*) pv1) <= 
0);
+               assert(compare_vertices<coord_t>((const void*) pvi, (const 
void*) pv1) <= 0);
 
                if (pvi->m_poly_owner == this)
                {
Index: libbase/tu_file.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/tu_file.cpp,v
retrieving revision 1.4
diff -u -3 -p -r1.4 tu_file.cpp
--- libbase/tu_file.cpp 12 Mar 2006 00:35:15 -0000      1.4
+++ libbase/tu_file.cpp 30 Mar 2006 08:02:54 -0000
@@ -67,7 +67,7 @@ std_seek_to_end_func(void *appdata)
 }
 
 static int
-std_tell_func(const void *appdata)
+std_tell_func(void *appdata)
 // Return the file position, or -1 on failure.
 {
     assert(appdata);
@@ -244,7 +244,7 @@ mem_seek_to_end_func(void* appdata)
 }
 
 static int
-mem_tell_func(const void* appdata)
+mem_tell_func(void* appdata)
 // Return the file position, or -1 on failure.
 {
     assert(appdata);
Index: libbase/tu_file.h
===================================================================
RCS file: /sources/gnash/gnash/libbase/tu_file.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 tu_file.h
--- libbase/tu_file.h   11 Mar 2006 19:24:27 -0000      1.3
+++ libbase/tu_file.h   30 Mar 2006 08:02:55 -0000
@@ -41,7 +41,7 @@ public:
     typedef int (* write_func)(const void* src, int bytes, void* appdata);
     typedef int (* seek_func)(int pos, void* appdata);
     typedef int (* seek_to_end_func)(void* appdata);
-    typedef int (* tell_func)(const void* appdata);
+    typedef int (* tell_func)(void* appdata);
     typedef bool (* get_eof_func)(void* appdata);
     typedef int (* close_func)(void* appdata);
     
Index: libbase/tu_file_SDL.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/tu_file_SDL.cpp,v
retrieving revision 1.2
diff -u -3 -p -r1.2 tu_file_SDL.cpp
--- libbase/tu_file_SDL.cpp     26 Feb 2006 15:49:30 -0000      1.2
+++ libbase/tu_file_SDL.cpp     30 Mar 2006 08:02:55 -0000
@@ -55,7 +55,7 @@ static int sdl_seek_to_end_func(void *ap
        return SDL_RWseek((SDL_RWops*) appdata, 0, SEEK_END);
 }
 
-static int sdl_tell_func(const void *appdata)
+static int sdl_tell_func(void *appdata)
 {
        assert(appdata);
        return SDL_RWtell((SDL_RWops*) appdata);
Index: libbase/zlib_adapter.cpp
===================================================================
RCS file: /sources/gnash/gnash/libbase/zlib_adapter.cpp,v
retrieving revision 1.2
diff -u -3 -p -r1.2 zlib_adapter.cpp
--- libbase/zlib_adapter.cpp    26 Feb 2006 15:49:30 -0000      1.2
+++ libbase/zlib_adapter.cpp    30 Mar 2006 08:02:55 -0000
@@ -262,7 +262,7 @@ namespace zlib_adapter
                return inf->m_logical_stream_pos;
        }
 
-       int     inflate_tell(const void* appdata)
+       int     inflate_tell(void* appdata)
        {
                inflater_impl*  inf = (inflater_impl*) appdata;
 
Index: server/action.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/action.cpp,v
retrieving revision 1.57
diff -u -3 -p -r1.57 action.cpp
--- server/action.cpp   29 Mar 2006 05:42:41 -0000      1.57
+++ server/action.cpp   30 Mar 2006 08:02:55 -0000
@@ -168,7 +168,7 @@ namespace gnash {
       
                        save_extern_movie(extern_movie);
       
-                       character* tar = (character*)target;
+                       const character* tar = (const character*)target;
                        const char* name = tar->get_name().c_str();
                        Uint16 depth = tar->get_depth();
                        bool use_cxform = false;
Index: server/dlist.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/dlist.cpp,v
retrieving revision 1.7
diff -u -3 -p -r1.7 dlist.cpp
--- server/dlist.cpp    29 Mar 2006 05:42:41 -0000      1.7
+++ server/dlist.cpp    30 Mar 2006 08:02:55 -0000
@@ -14,8 +14,8 @@
 namespace gnash {
        /*static*/ int  display_object_info::compare(const void* _a, const 
void* _b)
        {
-               display_object_info*    a = (display_object_info*) _a;
-               display_object_info*    b = (display_object_info*) _b;
+               const display_object_info*      a = (const 
display_object_info*) _a;
+               const display_object_info*      b = (const 
display_object_info*) _b;
 
                if (a->m_character->get_depth() < b->m_character->get_depth())
                {

Next, there is a warning about a mis-placed 'static', fixed like this:

Index: libgeometry/geometry.h
===================================================================
RCS file: /sources/gnash/gnash/libgeometry/geometry.h,v
retrieving revision 1.3
diff -u -3 -p -r1.3 geometry.h
--- libgeometry/geometry.h      1 Feb 2006 23:58:32 -0000       1.3
+++ libgeometry/geometry.h      30 Mar 2006 08:02:55 -0000
@@ -69,7 +69,7 @@ public:
        bool    checknan() const;       // Returns true if any component is nan.
 
        // Some handy vector constants.
-       const static vec3       zero, x_axis, y_axis, z_axis, flt_max, 
minus_flt_max;
+       static const vec3       zero, x_axis, y_axis, z_axis, flt_max, 
minus_flt_max;
 };
 
 

Btw, if you are not comfortable with adding -W by default because of
the noise created, what about adding -W and disabling the warnings
about unused variables and parameters?  In other words, what about
using "-W -Wall -Wno-unused-variable -Wno-unused-parameter" by default
instead of only -Wall?

And at last, please consider making regularly tarball releases.  One a
week would be great while progress is good, and less often when things
have stabilized.

Friendly,
-- 
Petter Reinholdtsen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]