Closed GoogleCodeExporter closed 8 years ago
which branch are you compiling ??
Your command line works perfectly on trunk branch with yagarto or similar arm
gcc toolchains
If you are compiling on other branches they are not expected to be in ready
state.
in any case the issue is invalid.
Original comment by romolo.m...@gmail.com
on 31 Jul 2013 at 2:22
It has been done this way since er9x to save flash. Sure it lacks a cast on gcc
4.8.1 which is not the compiler we officially use.
Would you tell-me if it remains a warning if you change these lines with
((int16_t *)g_eeGeneral.calibMid)[i]
Original comment by bson...@gmail.com
on 31 Jul 2013 at 2:29
I tried trunk and the lua branch, both get the warning. It has actually been
there for a long time so I imagine the warning shows up for almost any version
of the code. It is possible that my gcc and/or the gcc libraries/headers are
newer or compiled with different options than yagarto (is that a Windows
toolchain?). I'm compiling on Linux.
In any case the warning looks legitimate. For example if we look at
g_eeGeneral.calibMid it is defined as "calibMid[NUM_STICKS+NUM_POTS]" but the
for-loop is looping though "NUM_STICKS+NUM_POTS+5" entries (ie. larger than the
array). This may be intentional but it looks odd.
Original comment by coderi...@gmail.com
on 31 Jul 2013 at 2:32
The warning is still there with ((int16_t *)g_eeGeneral.calibMid)[i]. Smart
compiler. :)
Original comment by coderi...@gmail.com
on 31 Jul 2013 at 2:35
If it's intentional (and I see why now) then it's probably not a problem. The
only time it would be a problem is on a platform where the structure packing or
alignment was different than expected.
Original comment by coderi...@gmail.com
on 31 Jul 2013 at 2:38
Nope. Structure packing cannot be different than expected. Everything would be
broken.
Original comment by bson...@gmail.com
on 31 Jul 2013 at 2:41
Impossible to reproduce here, I don't use this compiler. The array is
3*(NUM_STICKS+NUM_POTS), we only sum the first 13 values (on Taranis) to have
the checksum. An intermediate pointer to squeeze the compiler will be ok,
provided it will be optimized away on 64A.
Original comment by bson...@gmail.com
on 31 Jul 2013 at 2:42
uint16_t evalChkSum()
{
uint16_t sum = 0;
const int16_t *calibValues = &g_eeGeneral.calibMid[0];
for (int i=0; i<NUM_STICKS+NUM_POTS+5; i++)
sum += calibValues[i];
return sum;
}
Original comment by bson...@gmail.com
on 31 Jul 2013 at 2:47
That removes the warning. Also saves 8 bytes of flash.
Original comment by coderi...@gmail.com
on 31 Jul 2013 at 2:53
Original issue reported on code.google.com by
coderi...@gmail.com
on 31 Jul 2013 at 2:17