This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fix compilation error in i2c.cxx


>>>>> "Ian" == Ian Campbell <icampbell@arcom.com> writes:

    Ian> Hi all,
    Ian> CVS 2005-06-16 had this problem, and I've not seen anything
    Ian> on this list which suggests i2c has changed.

    Ian> make[1]: Entering directory `/home/icampbell/devel/ecos/builds/viper/ram.tpm/io/i2c/current'
    Ian> arm-elf-gcc -c  -I/home/icampbell/devel/ecos/builds/viper/ram.tpm/install/include -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/tests -I. -I/home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/ -finline-limit=7000 -mcpu=xscale -Wall -Wpointer-arith  -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions   -mapcs-frame -Wp,-MD,src/i2c.tmp -o src/io_i2c_i2c.o /home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/i2c.cxx
    Ian> /home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/i2c.cxx: In constructor `cyg_i2c_init::cyg_i2c_init()':
    Ian> /home/icampbell/devel/ecos/ecos/packages/io/i2c/current/src/i2c.cxx:100: error: comparison between distinct pointer types `void (*)(const cyg_i2c_bus*)' and `void (*)(cyg_i2c_bus*)' lacks a cast
    Ian> make[1]: *** [src/i2c.o.d] Error 1
    Ian> make[1]: Leaving directory `/home/icampbell/devel/ecos/builds/viper/ram.tpm/io/i2c/current'

    Ian> Fix is to compare against NULL instead of constructing a type
    Ian> specific NULL explicitly. I guess the " != NULL" could even
    Ian> be dropped entirely if that is preferable.

No. The actual bug is that the const should not be present. The
cyg_i2c_bus* argument was originally const but this was later dropped,
allowing the init fn to tweak the bus structure if necessary. The
compiler version I was using at the time did not show this.

The proper fix (which I had not got around to checking in yet) is
below.

Bart

2005-06-30  Bart Veer  <bartv@ecoscentric.com>

	* src/i2c.cxx (cyg_i2c_init): remove incorrect const

Index: src/i2c.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/io/i2c/current/src/i2c.cxx,v
retrieving revision 1.2
diff -u -r1.2 i2c.cxx
--- src/i2c.cxx	14 May 2005 09:31:02 -0000	1.2
+++ src/i2c.cxx	15 Jul 2005 13:42:01 -0000
@@ -97,7 +97,7 @@
 #ifdef CYGDBG_USE_ASSERTS
         bus->i2c_current_device = (const cyg_i2c_device*) 0;
 #endif        
-        if ((void (*)(const cyg_i2c_bus*))0 != bus->i2c_init_fn) {
+        if ((void (*)(cyg_i2c_bus*))0 != bus->i2c_init_fn) {
             (*bus->i2c_init_fn)(bus);
         }
     }

-- 
Bart Veer                       eCos Configuration Architect
http://www.ecoscentric.com/     The eCos and RedBoot experts


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]