printf: use compiler __attribute__((format (printf,fff,aaa)))

This commit is contained in:
Darryl Miles 2024-10-03 22:35:26 +01:00 committed by Darryl L. Miles
parent f80540af46
commit 94ec5cf98f
8 changed files with 22 additions and 14 deletions

View File

@ -65,7 +65,7 @@ extern bool CalmaWrite(CellDef *rootDef, FILE *f);
extern void CalmaReadFile(FILETYPE file, char *filename);
extern void CalmaTechInit(void);
extern bool CalmaGenerateArray(FILE *f, TileType type, int llx, int lly, int pitch, int cols, int rows);
extern void CalmaReadError(char *format, ...);
extern void CalmaReadError(char *format, ...) ATTR_FORMAT_PRINTF_1;
/* C99 compat */
extern void calmaDelContacts(void);

View File

@ -188,8 +188,8 @@ extern int CIFEdgeDirection(CIFPath *first, CIFPath *last);
/* Variable argument procedures require complete prototype */
extern void CIFReadError(char *format, ...);
extern void CIFReadWarning(char *format, ...);
extern void CIFReadError(char *format, ...) ATTR_FORMAT_PRINTF_1;
extern void CIFReadWarning(char *format, ...) ATTR_FORMAT_PRINTF_1;
/* Variables shared by the CIF-reading modules, see CIFreadutils.c
* for more details:

View File

@ -162,8 +162,8 @@ void LefReadLayerSection();
LefMapping *defMakeInverseLayerMap();
void LefError(int, char *, ...); /* Variable argument procedure requires */
/* parameter list. */
/* Variable argument procedure requires parameter list. */
void LefError(int, char *, ...) ATTR_FORMAT_PRINTF_2;
/* C99 compat */
extern void LefRead();

View File

@ -68,10 +68,10 @@ extern void TxUseMore();
extern void TxStopMore();
/* printing procedures with variable arguments lists */
extern void TxError(char *, ...);
extern void TxError(char *, ...) ATTR_FORMAT_PRINTF_1;
extern void TxErrorV(char *, va_list args);
extern void TxPrintf(char *, ...);
extern char *TxPrintString(char *, ...);
extern void TxPrintf(char *, ...) ATTR_FORMAT_PRINTF_1;
extern char *TxPrintString(char *, ...) ATTR_FORMAT_PRINTF_1;
/* input procedures */
extern char *TxGetLinePrompt();

View File

@ -52,7 +52,7 @@ extern bool TxGetInputEvent();
/* Routines with variable argument lists */
extern void txFprintfBasic(FILE *, ...);
extern void txFprintfBasic(FILE *, const char *fmt, ...) ATTR_FORMAT_PRINTF_2;
/* C99 compat */
void txCommandsInit();

View File

@ -76,13 +76,11 @@ static bool txPrintFlag = TRUE;
*/
void
txFprintfBasic(FILE *f, ...)
txFprintfBasic(FILE *f, const char *fmt, ...)
{
va_list args;
char *fmt;
va_start(args, f);
fmt = va_arg(args, char *);
va_start(args, fmt);
Vfprintf(f, fmt, args);
va_end(args);
}

View File

@ -168,6 +168,16 @@ extern char AbortMessage[];
#define PaLockZOpen PaLockOpen
#endif
/* ------------ modern compiler support -------------------------------- */
#if defined(__GNUC__) || defined(__clang__)
#define ATTR_FORMAT_PRINTF_1 __attribute__((format (printf,1,2)))
#define ATTR_FORMAT_PRINTF_2 __attribute__((format (printf,2,3)))
#else
#define ATTR_FORMAT_PRINTF_1 /* */
#define ATTR_FORMAT_PRINTF_2 /* */
#endif
/* ---------------- Start of Machine Configuration Section ----------------- */
/* ------- Configuration: Handle Missing Routines/Definitions ------- */

View File

@ -51,7 +51,7 @@ extern bool TechOverridesDefault; /* Set TRUE if technology was specified on
/* ----------------- Exported procedures ---------------- */
extern void TechError(char *, ...);
extern void TechError(char *, ...) ATTR_FORMAT_PRINTF_1;
extern void TechAddClient();
extern void TechAddAlias();