GCC fixes for warnings

GCC was more picky about prototypes for inlines being required.

The generate_listener.py script used incorrect printf formats and
was casting %f params to float, but printf casts all %f params to
double per the spec.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
This commit is contained in:
Mark Charlebois 2015-05-06 11:45:23 -07:00
parent 5299f76706
commit 872e1ebda0
5 changed files with 18 additions and 13 deletions

View File

@ -127,17 +127,17 @@ for index,m in enumerate(messages[1:]):
print "\t\t\torb_copy(ID,sub,&container);"
for item in message_elements[index+1]:
if item[0] == "float":
print "\t\t\tprintf(\"%s: %%f\\n \",container.%s);" % (item[1], item[1])
print "\t\t\tprintf(\"%s: %%f\\n \",(double)container.%s);" % (item[1], item[1])
elif item[0] == "float_array":
print "\t\t\tprintf(\"%s:\");" % item[1]
print "\t\t\tfor (int j=0;j<%d;j++) {" % item[2]
print "\t\t\t\tprintf(\"%%f \",container.%s[j]);" % item[1]
print "\t\t\t\tprintf(\"%%f \",(double)container.%s[j]);" % item[1]
print "\t\t\t}"
print "\t\t\tprintf(\"\\n\");"
elif item[0] == "uint64":
print "\t\t\tprintf(\"%s: %%f\\n \",(float)container.%s);" % (item[1], item[1])
print "\t\t\tprintf(\"%s: %%lu\\n \",container.%s);" % (item[1], item[1])
elif item[0] == "uint8":
print "\t\t\tprintf(\"%s: %%f\\n \",(float)container.%s);" % (item[1], item[1])
print "\t\t\tprintf(\"%s: %%u\\n \",container.%s);" % (item[1], item[1])
elif item[0] == "bool":
print "\t\t\tprintf(\"%s: %%s\\n \",container.%s ? \"True\" : \"False\");" % (item[1], item[1])
print "\t\t\t}"

View File

@ -157,7 +157,6 @@ ARCHWARNINGS = -Wall \
-Wmissing-declarations \
-Wpacked \
-Wno-unused-parameter \
-Wno-gnu-array-member-paren-init \
-Wno-packed \
-Werror=format-security \
-Werror=array-bounds \
@ -176,6 +175,8 @@ ARCHWARNINGS += -Wdouble-promotion \
-Werror=unused-but-set-variable \
-Werror=double-promotion
ARCHOPTIMIZATION += -fno-strength-reduce
else
ARCHWARNINGS += -Wno-gnu-array-member-paren-init
endif
# -Werror=float-conversion - works, just needs to be phased in with some effort and needs GCC 4.9+

View File

@ -363,6 +363,14 @@ static void usage()
PX4_WARN("Publish sensors combined: simulator start -p");
}
__BEGIN_DECLS
extern int simulator_main(int argc, char *argv[]);
extern void led_init(void);
extern void led_on(int led);
extern void led_off(int led);
extern void led_toggle(int led);
__END_DECLS
extern "C" {
int simulator_main(int argc, char *argv[])
@ -418,13 +426,6 @@ int simulator_main(int argc, char *argv[])
}
__BEGIN_DECLS
extern void led_init(void);
extern void led_on(int led);
extern void led_off(int led);
extern void led_toggle(int led);
__END_DECLS
bool static _led_state[2] = { false , false };
__EXPORT void led_init()

View File

@ -788,7 +788,8 @@ tone_alarm_main(int argc, char *argv[])
PX4_WARN("not enough memory memory");
return 1;
}
fread(buffer, sz, 1, fd);
// FIXME - Make GCC happy
if (fread(buffer, sz, 1, fd)) { }
/* terminate the string */
buffer[sz] = 0;
ret = play_string(buffer, true);

View File

@ -37,12 +37,14 @@
#pragma once
extern sem_t _work_lock[];
inline void work_lock(int id);
inline void work_lock(int id)
{
//printf("work_lock %d\n", id);
sem_wait(&_work_lock[id]);
}
inline void work_unlock(int id);
inline void work_unlock(int id)
{
//printf("work_unlock %d\n", id);