Fix for misc compiler warnings

David Brennan david@brennanhome.com
Thu Oct 14 03:40:00 GMT 2004



Andrew Lunn wrote:

>On Wed, Oct 13, 2004 at 05:51:06AM -0700, David Brennan wrote:
>  
>
>>    CYG_ASSERT(
>>-        (CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE <= (int)i82559_heap_free)
>>+        ((cyg_uint8 *)CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE <= 
>>i82559_heap_free)
>>        &&
>>-        ((CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE +
>>-          CYGHWR_INTEL_I82559_PCI_MEM_MAP_SIZE) > (int)i82559_heap_free)
>>-        &&
>>-        (0 < i82559_heap_size)
>>+        ((cyg_uint8 *)(CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE +
>>+          CYGHWR_INTEL_I82559_PCI_MEM_MAP_SIZE) > i82559_heap_free)
>>        &&
>>        (CYGHWR_INTEL_I82559_PCI_MEM_MAP_SIZE >= i82559_heap_size)
>>        &&
>>-        (CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE == (int)i82559_heap_base),
>>+        ((cyg_uint8 *)CYGHWR_INTEL_I82559_PCI_MEM_MAP_BASE == 
>>i82559_heap_base),
>>        "Heap variables corrupted" );
>>
>>    p_memory = (void *)0;
>>    size = (size + 3) & ~3;
>>    if ( (i82559_heap_free+size) < (i82559_heap_base+i82559_heap_size) ) {
>>    
>>
>
>What version of GCC are you using. I don't get warnings in the
>ethernet driver. The code looks OK to me
>too. CYGHWR_INTEL_I82559_PCI_MEM_MAP_* will be int so casting
>i82559_heap_free to int should be enough.
>  
>
Yes I agree that casting i82559_heap_free to an int should be enough. I 
am using gcc 3.2.3. And I guess it is possible that the gcc folks made a 
mistake with this warning. However, I submitted this to get rid of it. 

>  
>
>>Index: io/fileio/current/src/file.cxx
>>===================================================================
>>RCS file: /cvs/ecos/ecos/packages/io/fileio/current/src/file.cxx,v
>>retrieving revision 1.10
>>diff -U5 -r1.10 file.cxx
>>--- io/fileio/current/src/file.cxx    15 Mar 2004 15:41:36 -0000    1.10
>>+++ io/fileio/current/src/file.cxx    13 Oct 2004 05:06:45 -0000
>>@@ -570,10 +599,13 @@
>>    }
>>       
>>    info.buf = buf;
>>    info.size = size;
>>
>>+    CYG_CHECK_DATA_PTR(mte,"Invalid MTAB entry for current directory");
>>+    CYG_CHECK_DATA_PTR(mte->fs,"Invalid File System entry for current 
>>directory");
>>+
>>    LOCK_FS( mte );
>>   
>>    err = mte->fs->getinfo( mte, dir, "",
>>                            FS_INFO_GETCWD, (char *)&info, sizeof(info) );
>>    
>>
>
>This does not really fit. LOCK_FS already checks mte. I get the
>feeling this is just leftover from debugging a problem you had at some
>time.
>
>  
>
Ok, the whole point of the CYG_CHECK is to protect programmers from 
themselves. And I agree tat the first check might not be necessary. But 
I am trying to get my i386-pc ide driver working on a different machine 
than my usual target. I am testing it with fs/fat/fileio1.c. If the 
mount fails, (which it currently is on my hardware), and you try and 
getcwd, you will get a SIGILL because mte->fs is null. (I originally 
thought the roblem was that mte was NULL, that is the reason the first 
is in there.) So I think there is value in the second check, but if you 
insist on removing the first, I am ok with that.

>>Index: io/fileio/current/tests/select.c
>>===================================================================
>>RCS file: /cvs/ecos/ecos/packages/io/fileio/current/tests/select.c,v
>>retrieving revision 1.6
>>diff -U5 -r1.6 select.c
>>--- io/fileio/current/tests/select.c    11 Nov 2002 23:58:54 -0000    1.6
>>+++ io/fileio/current/tests/select.c    13 Oct 2004 05:06:46 -0000
>>@@ -81,10 +81,11 @@
>>#include <unistd.h>
>>#include <fcntl.h>
>>#include <sys/stat.h>
>>#include <errno.h>
>>#include <string.h>
>>+#include <sys/select.h>                // select()
>>
>>#ifdef CYGPKG_NET
>>#include <network.h>
>>#include <arpa/inet.h>
>>#define TEST_NET
>>    
>>
>
>Again, i don't get a warning. 
>  
>
I "think" I was only getting this warning on my "NoNet" configuration. 
It could be that either network.h or arpa/inet.h is including sys/select 
for you.

If you need me to, I will reverse the patch out and double check which 
configuration was causing this warning. Then I can post my exported ecm 
file for you to duplicate the problem.

Thanks
David Brennan



More information about the Ecos-patches mailing list