Enable GNU GCC type checking of format arguments for our functions

This commit is contained in:
Douglas Clowes
2014-02-18 11:27:53 +11:00
parent f7b7c27415
commit 2c25c64db3
4 changed files with 38 additions and 10 deletions

View File

@ -91,7 +91,14 @@ void SCSignalFunction(void *pCon, int iSignal, void *pSigData);
/* ***************************** I/O ************************************** */
void SCSetOutputClass(SConnection * self, int iClass);
int SCWrite(SConnection * self, char *pBuffer, int iOut);
int SCPrintf(SConnection * self, int iOut, char *fmt, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
int SCPrintf(SConnection * self, int iOut, char *fmt, ...) G_GNUC_PRINTF (3, 4);
#undef G_GNUC_PRINTF
int SCRead(SConnection * self, char *pBuffer, int iBufLen);
int SCPrompt(SConnection * pCon, char *pPrompt, char *pResult, int iLen);
int SCSendOK(SConnection * self);

View File

@ -35,7 +35,14 @@ typedef struct {
* \return the new error message list head
*/
void ErrPutMsg(ErrList *list, char *fmt, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
void ErrPutMsg(ErrList *list, char *fmt, ...) G_GNUC_PRINTF (2, 3);
#undef G_GNUC_PRINTF
/** \brief Get the most recent error message
* \param list the error list

View File

@ -20,9 +20,16 @@ void SICSLogWriteTime(char *ptext, OutCode eOut, struct timeval *tp);
void SICSLogWriteHex(const char *text, int count, OutCode eOut);
void SICSLogWriteHexTime(const char *text, int count, OutCode eOut,
struct timeval *tp);
void SICSLogPrintf(OutCode eOut, const char *fmt, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
void SICSLogPrintf(OutCode eOut, const char *fmt, ...) G_GNUC_PRINTF (2, 3);
void SICSLogTimePrintf(OutCode eOut, struct timeval *tp, const char *fmt,
...);
...) G_GNUC_PRINTF (3, 4);
#undef G_GNUC_PRINTF
void SICSLogEnable(int flag);
int KillCapture(SConnection * pCon);

19
trace.h
View File

@ -18,17 +18,24 @@
* the socket number, a host:port or something appropriate
* which tells us where the stuff is going to or coming from.
*/
void traceIO(char *id, char *format, ...);
void traceDevice(char *id, char *format, ...);
void traceCommand(char *id, char *format, ...);
void tracePar(char *id, char *format, ...);
void traceSys(char *id, char *format, ...);
#if __GNUC__ > 2
#define G_GNUC_PRINTF( format_idx, arg_idx ) \
__attribute__((__format__ (__printf__, format_idx, arg_idx)))
#else
#define G_GNUC_PRINTF( format_idx, arg_idx )
#endif
void traceIO(char *id, char *format, ...) G_GNUC_PRINTF (2, 3);
void traceDevice(char *id, char *format, ...) G_GNUC_PRINTF (2, 3);
void traceCommand(char *id, char *format, ...) G_GNUC_PRINTF (2, 3);
void tracePar(char *id, char *format, ...) G_GNUC_PRINTF (2, 3);
void traceSys(char *id, char *format, ...) G_GNUC_PRINTF (2, 3);
void traceprint(char *sub, char *id,char *data);
/**
* A debugging trace. This has to be switched on separately
*/
void traceDebug(char *id, char *format, ...);
void traceDebug(char *id, char *format, ...) G_GNUC_PRINTF (2, 3);
#undef G_GNUC_PRINTF
/*
* 1 when tracing active, 0 else