2008/10/26

Fixing eCos warnings

If you build eCos with a GCC 4.x compiler, you'll see new warnings as GCC 4.x series are stricter about C syntax.

The following patch fixes up several warnings:

Index: trunk/ecos/packages/kernel/current/include/instrument_desc.h
===================================================================
--- trunk/ecos/packages/kernel/current/include/instrument_desc.h (revision 2)
+++ trunk/ecos/packages/kernel/current/include/instrument_desc.h (revision 4513)
@@ -3,7 +3,7 @@
 /* Install tree   : INSTALL/include/cyg/kernel/instrument_desc.h       */
 
 struct instrument_desc_s {                                
-    char *   msg;                                         
+    const char * msg;                                         
     CYG_WORD num;                                         
 };                                                        
 
Index: trunk/ecos/packages/kernel/current/include/instrmnt.h
===================================================================
--- trunk/ecos/packages/kernel/current/include/instrmnt.h (revision 4)
+++ trunk/ecos/packages/kernel/current/include/instrmnt.h (revision 4513)
@@ -87,7 +87,7 @@
 #endif
 
 #ifdef CYGDBG_KERNEL_INSTRUMENT_MSGS
-externC char * cyg_instrument_msg(CYG_WORD16 type);
+externC const char * cyg_instrument_msg(CYG_WORD16 type);
 #endif 
 
 // -------------------------------------------------------------------------
Index: trunk/ecos/packages/kernel/current/src/debug/dbg_gdb.cxx
===================================================================
--- trunk/ecos/packages/kernel/current/src/debug/dbg_gdb.cxx (revision 1926)
+++ trunk/ecos/packages/kernel/current/src/debug/dbg_gdb.cxx (revision 4513)
@@ -229,7 +229,7 @@
 //--------------------------------------------------------------------------
 // Some support routines for manufacturing thread info strings
 
-static char *dbg_addstr(char *s, char *t)
+static char *dbg_addstr(char *s, const char *t)
 {
     while( (*s++ = *t++) != 0 );
 
@@ -241,7 +241,7 @@
     char buf[16];
     char sign = '+';
     cyg_count8 bpos;
-    char *digits = "0123456789ABCDEF";
+    const char *digits = "0123456789ABCDEF";
 
     if( n < 0 ) n = -n, sign = '-';
     
@@ -292,7 +292,7 @@
     info->context_exists        = 1;
 
     char *sbp = statebuf;
-    char *s;
+    const char *s;
 
     if( thread->get_state() & Cyg_Thread::SUSPENDED )
     {
Index: trunk/ecos/packages/kernel/current/src/instrmnt/meminst.cxx
===================================================================
--- trunk/ecos/packages/kernel/current/src/instrmnt/meminst.cxx (revision 1926)
+++ trunk/ecos/packages/kernel/current/src/instrmnt/meminst.cxx (revision 4513)
@@ -227,7 +227,7 @@
 #define CYGDBG_KERNEL_INSTRUMENT_MSGS_DEFINE_TABLE
 #include 
 
-externC char * cyg_instrument_msg(CYG_WORD16 type) {
+externC const char * cyg_instrument_msg(CYG_WORD16 type) {
 
   struct instrument_desc_s *record;
   struct instrument_desc_s *end_record;
Index: trunk/ecos/packages/services/threadload/current/src/threadload.cxx
===================================================================
--- trunk/ecos/packages/services/threadload/current/src/threadload.cxx (revision 1926)
+++ trunk/ecos/packages/services/threadload/current/src/threadload.cxx (revision 4513)
@@ -125,10 +125,11 @@
  */
 static void cyg_threadload_startup(void)
 {
+    static const char * name = "THREADLOAD";
     cyg_thread_create( 30,					// Just before Idle task
                        cyg_threadload_init,
                        0,
-                       "THREADLOAD",
+                       (char *)name, // ugly? yes, eCos
                        &threadload_stack[0],
                        sizeof(threadload_stack),
                        &threadload_thread,
Index: trunk/ecos/packages/services/memalloc/common/current/include/dlmallocimpl.hxx
===================================================================
--- trunk/ecos/packages/services/memalloc/common/current/include/dlmallocimpl.hxx (revision 4)
+++ trunk/ecos/packages/services/memalloc/common/current/include/dlmallocimpl.hxx (revision 4513)
@@ -108,7 +108,7 @@
         Cyg_dlmalloc_size_t size;      /* Size in bytes, including overhead. */
         struct malloc_chunk* fd;   /* double links -- used only if free. */
         struct malloc_chunk* bk;
-    };
+    } malloc_chunk;
     
 protected:
     /* The first value returned from sbrk */
Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoll.cxx
===================================================================
--- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoll.cxx (revision 1926)
+++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoll.cxx (revision 4513)
@@ -175,7 +175,7 @@
             break;
         if (c >= base)
             break;
-        if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+        if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
             any = -1;
         else {
             any = 1;
Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtol.cxx
===================================================================
--- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtol.cxx (revision 1926)
+++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtol.cxx (revision 4513)
@@ -179,7 +179,7 @@
             break;
         if (c >= base)
             break;
-        if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+        if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
             any = -1;
         else {
             any = 1;
Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoull.cxx
===================================================================
--- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoull.cxx (revision 1926)
+++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoull.cxx (revision 4513)
@@ -151,7 +151,7 @@
             break;
         if (c >= base)
             break;
-        if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+        if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
             any = -1;
         else {
             any = 1;
Index: trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoul.cxx
===================================================================
--- trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoul.cxx (revision 1926)
+++ trunk/ecos/packages/language/c/libc/stdlib/current/src/strtoul.cxx (revision 4513)
@@ -155,7 +155,7 @@
             break;
         if (c >= base)
             break;
-        if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+        if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
             any = -1;
         else {
             any = 1;

No comments: