Here's a (nesC) function in which I forgot to initialize the "count"
variable to zero:
command uint16_t ChainRouting.countGoodNeighbours(uint8_t
destination) {
uint8_t count;
uint8_t i;
for (i=0; i<ROUTING_TABLE_SIZE; i++) {
routing_table_entry_t* entry = &routingTable[i];
uint16_t etx = (destination ==
DESTINATION_FIXED) ? entry->etxUp : entry->etxDown;
if (!entry->valid) continue;
if (entry->bidir && etx < MAX_ETX &&
decentSignal(entry) && isRecent(entry)) {
count++;
}
}
return count;
}
mspgcc 3.2.3 correctly warns:
../../routing/ChainRoutingP.nc:281: warning: `count' might be used
uninitialized in this function
but 4.5.3 doesn't complain at all. However, in a tiny test program both
produce the warning:
#include "io.h"
char foo[10];
int main() {
int count;
int i;
for (i=0 ; i<10; i++) {
if (foo[i] == 'a') count++;
}
return count;
}
It only warns if optimization is enabled (-Os in my case). Is that how
it's supposed to work? I've verified the -Os flag is present when
compiling the TinyOS program, with both compilers. Any ideas on why the
old version catches it and the new one doesn't? I can produce loads more
output and a copy of app.c if required.
Regards,
Michiel
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Mspgcc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mspgcc-users