Mercurial > nand-ecoscentric
changeset 1931:ae242bae5abc
* include/diag.h: Added CYGBLD_ATTRIB_PRINTF_FORMAT where
appropriate to get the compiler to do more checking.
* src/diag.cxx (diag_dump_buf_with_offset_16bit): Fix compiler warning
caused by above change.
| author | asl |
|---|---|
| date | Sun, 27 Mar 2005 18:14:58 +0000 |
| parents | 4f6bcb240e17 |
| children | 508a2717c9f9 |
| files | packages/infra/current/ChangeLog packages/infra/current/include/cyg_type.h packages/infra/current/include/diag.h packages/infra/current/src/diag.cxx |
| diffstat | 4 files changed, 32 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/packages/infra/current/ChangeLog +++ b/packages/infra/current/ChangeLog @@ -1,3 +1,10 @@ +2005-03-27 Andrew Lunn <andrew.lunn@ascom.ch> + + * include/diag.h: Added CYGBLD_ATTRIB_PRINTF_FORMAT where + appropriate to get the compiler to do more checking. + * src/diag.cxx (diag_dump_buf_with_offset_16bit): Fix compiler warning + caused by above change. + 2005-02-08 Andrew Lunn <andrew.lunn@ascom.ch> * tests/diag_sprintf1.c
--- a/packages/infra/current/include/cyg_type.h +++ b/packages/infra/current/include/cyg_type.h @@ -375,6 +375,14 @@ typedef cyg_haladdrword CYG_ADDRWORD; # define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) \ __attribute__((format (printf, __format__, __args__))) +// Teach compiler how to check format of scanf-like functions +# define CYGBLD_ATTRIB_SCANF_FORMAT(__format__, __args__) \ + __attribute__((format (scanf, __format__, __args__))) + +// Teach compiler how to check format of strftime-like functions +# define CYGBLD_ATTRIB_STRFTIME_FORMAT(__format__, __args__) \ + __attribute__((format (strftime, __format__, __args__))) + #else // non-GNU # define CYGBLD_ATTRIB_CONSTRUCTOR @@ -400,6 +408,11 @@ typedef cyg_haladdrword CYG_ADDRWORD; # define CYGBLD_ATTRIB_PRINTF_FORMAT(__format__, __args__) +# define CYGBLD_ATTRIB_SCANF_FORMAT(__format__, __args__) + +# define CYGBLD_ATTRIB_STRFTIME_FORMAT(__format__, __args__) + + #endif // How to define weak aliases. Currently this is simply a mixture of the
--- a/packages/infra/current/include/diag.h +++ b/packages/infra/current/include/diag.h @@ -92,13 +92,18 @@ externC void diag_dump_buf_with_offset_1 CYG_ADDRWORD s, cyg_uint16 *base); -externC int diag_printf( const char *fmt, ... ); /* Formatted print */ +/* Formatted print */ +externC int diag_printf( const char *fmt, ... ) CYGBLD_ATTRIB_PRINTF_FORMAT(1,2); externC void diag_init_putc(void (*putc)(char c, void **param)); -externC int diag_sprintf(char *buf, const char *fmt, ...); -externC int diag_snprintf(char *buf, size_t len, const char *fmt, ...); -externC int diag_vsprintf(char *buf, const char *fmt, va_list ap); -externC int diag_vprintf(const char *fmt, va_list ap); +externC int diag_sprintf(char *buf, const char *fmt, ...) + CYGBLD_ATTRIB_PRINTF_FORMAT(2,3); +externC int diag_snprintf(char *buf, size_t len, const char *fmt, ...) + CYGBLD_ATTRIB_PRINTF_FORMAT(3,4); +externC int diag_vsprintf(char *buf, const char *fmt, va_list ap) + CYGBLD_ATTRIB_PRINTF_FORMAT(2,0); +externC int diag_vprintf(const char *fmt, va_list ap) + CYGBLD_ATTRIB_PRINTF_FORMAT(1,0); /*---------------------------------------------------------------------------*/
--- a/packages/infra/current/src/diag.cxx +++ b/packages/infra/current/src/diag.cxx @@ -654,7 +654,7 @@ diag_dump_buf_with_offset_32bit(cyg_uint if (base) { diag_printf("%08X: ", (CYG_ADDRWORD)p - (CYG_ADDRWORD)base); } else { - diag_printf("%08X: ", p); + diag_printf("%08X: ", (CYG_ADDRWORD)p); } for (i = 0; i < 4; i++) { if (i < (int)s/4) { @@ -688,7 +688,7 @@ diag_dump_buf_with_offset_16bit(cyg_uint if (base) { diag_printf("%08X: ", (CYG_ADDRWORD)p - (CYG_ADDRWORD)base); } else { - diag_printf("%08X: ", p); + diag_printf("%08X: ", (CYG_ADDRWORD)p); } for (i = 0; i < 8; i++) { if (i < (int)s/2) {
