added -Wformat in Arduino.mk

when building with 'make' we get warnings related to printf() format
strings

git-svn-id: https://arducopter.googlecode.com/svn/trunk@1798 f9c3cf11-9bcb-44bc-f272-b75c42450872
This commit is contained in:
tridge60@gmail.com 2011-03-21 07:26:03 +00:00
parent 211de598c3
commit 776b9b6f7a
3 changed files with 8 additions and 3 deletions

View File

@ -84,6 +84,11 @@ typedef struct {
(prog_char_t *)&__c[0];})) (prog_char_t *)&__c[0];}))
#endif #endif
// a varient of PSTR() for progmem strings passed to %S in printf()
// this gets the gcc __format__ checking right
#define FPSTR(s) (wchar_t *)(s)
static inline int strcasecmp_P(const char *str1, const prog_char_t *pstr) static inline int strcasecmp_P(const char *str1, const prog_char_t *pstr)
{ {
return strcasecmp_P(str1, (const prog_char *)pstr); return strcasecmp_P(str1, (const prog_char *)pstr);

View File

@ -159,7 +159,7 @@ endif
# Tool options # Tool options
# #
DEFINES = -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERS) DEFINES = -DF_CPU=$(F_CPU) -DARDUINO=$(ARDUINO_VERS)
OPTFLAGS = -Os OPTFLAGS = -Os -Wformat
DEPFLAGS = -MD -MT $@ DEPFLAGS = -MD -MT $@
# XXX warning options TBD # XXX warning options TBD

View File

@ -44,7 +44,7 @@ Menu::run(void)
// loop reading characters from the input // loop reading characters from the input
len = 0; len = 0;
Serial.printf("%S] ", _prompt); Serial.printf("%S] ", FPSTR(_prompt));
for (;;) { for (;;) {
c = Serial.read(); c = Serial.read();
if (-1 == c) if (-1 == c)
@ -127,7 +127,7 @@ Menu::_help(void)
Serial.println("Commands:"); Serial.println("Commands:");
for (i = 0; i < _entries; i++) for (i = 0; i < _entries; i++)
Serial.printf(" %S\n", _commands[i].command); Serial.printf(" %S\n", FPSTR(_commands[i].command));
} }
// run the n'th command in the menu // run the n'th command in the menu