Added the new annotation EPICS_PRINTF_FMT
This commit is contained in:

committed by
Michael Davidsaver

parent
f41f11c7f6
commit
b878295d06
6
.github/workflows/ci-scripts-build.yml
vendored
6
.github/workflows/ci-scripts-build.yml
vendored
@ -133,13 +133,15 @@ jobs:
|
||||
|
||||
- os: windows-2019
|
||||
cmp: vs2019
|
||||
configuration: default
|
||||
configuration: debug
|
||||
name: "Win2019 MSC-19"
|
||||
extra: "CMD_CXXFLAGS=-analysis"
|
||||
|
||||
- os: windows-2019
|
||||
cmp: vs2019
|
||||
configuration: static
|
||||
configuration: static-debug
|
||||
name: "Win2019 MSC-19, static"
|
||||
extra: "CMD_CXXFLAGS=-analysis"
|
||||
|
||||
- os: windows-2019
|
||||
cmp: vs2019
|
||||
|
@ -75,7 +75,7 @@ DBCORE_API void recGblInheritSevr(int msMode, void *precord, epicsEnum16 stat,
|
||||
epicsEnum16 sevr);
|
||||
DBCORE_API int recGblSetSevrMsg(void *precord, epicsEnum16 new_stat,
|
||||
epicsEnum16 new_sevr,
|
||||
const char *msg, ...) EPICS_PRINTF_STYLE(4,5);
|
||||
EPICS_PRINTF_FMT(const char *msg), ...) EPICS_PRINTF_STYLE(4,5);
|
||||
DBCORE_API int recGblSetSevrVMsg(void *precord, epicsEnum16 new_stat,
|
||||
epicsEnum16 new_sevr,
|
||||
const char *msg, va_list args);
|
||||
|
@ -39,7 +39,9 @@ char *dbRecordName(DBENTRY *pdbentry);
|
||||
char *dbGetStringNum(DBENTRY *pdbentry);
|
||||
long dbPutStringNum(DBENTRY *pdbentry,const char *pstring);
|
||||
|
||||
void dbMsgPrint(DBENTRY *pdbentry, const char *fmt, ...) EPICS_PRINTF_STYLE(2,3);
|
||||
void dbMsgPrint(
|
||||
DBENTRY *pdbentry, EPICS_PRINTF_FMT(const char *fmt), ...
|
||||
) EPICS_PRINTF_STYLE(2,3);
|
||||
|
||||
void dbPutStringSuggest(DBENTRY *pdbentry, const char *pstring);
|
||||
|
||||
|
@ -97,7 +97,7 @@ LIBCOM_API extern int errVerbose;
|
||||
* that the output is sent to the errlog task. Unless configured not to, the output
|
||||
* will appear on the console as well.
|
||||
*/
|
||||
LIBCOM_API int errlogPrintf(const char *pformat, ...)
|
||||
LIBCOM_API int errlogPrintf(EPICS_PRINTF_FMT(const char *pformat), ...)
|
||||
EPICS_PRINTF_STYLE(1,2);
|
||||
|
||||
/**
|
||||
@ -118,7 +118,8 @@ LIBCOM_API int errlogVprintf(const char *pformat, va_list pvar);
|
||||
* \return int Consult printf documentation in C standard library
|
||||
*/
|
||||
LIBCOM_API int errlogSevPrintf(const errlogSevEnum severity,
|
||||
const char *pformat, ...) EPICS_PRINTF_STYLE(2,3);
|
||||
EPICS_PRINTF_FMT(const char *pformat), ...
|
||||
) EPICS_PRINTF_STYLE(2,3);
|
||||
|
||||
/**
|
||||
* This function is like ::errlogVprintf except that it adds the severity to the beginning
|
||||
@ -239,11 +240,14 @@ LIBCOM_API void errlogFlush(void);
|
||||
* The remaining arguments are just like the arguments to the C printf routine.
|
||||
* ::errVerbose determines if the filename and line number are shown.
|
||||
*/
|
||||
LIBCOM_API void errPrintf(long status, const char *pFileName, int lineno,
|
||||
const char *pformat, ...) EPICS_PRINTF_STYLE(4,5);
|
||||
LIBCOM_API void errPrintf(
|
||||
long status, const char *pFileName, int lineno,
|
||||
EPICS_PRINTF_FMT(const char *pformat), ...
|
||||
) EPICS_PRINTF_STYLE(4,5);
|
||||
|
||||
LIBCOM_API int errlogPrintfNoConsole(const char *pformat, ...)
|
||||
EPICS_PRINTF_STYLE(1,2);
|
||||
LIBCOM_API int errlogPrintfNoConsole(
|
||||
EPICS_PRINTF_FMT(const char *pformat), ...
|
||||
) EPICS_PRINTF_STYLE(1,2);
|
||||
LIBCOM_API int errlogVprintfNoConsole(const char *pformat,va_list pvar);
|
||||
|
||||
/**
|
||||
|
@ -43,8 +43,9 @@ extern "C" {
|
||||
* \param errorMessage A printf-style error message describing the error.
|
||||
* \param ... Any parameters required for the error message.
|
||||
*/
|
||||
LIBCOM_API void cantProceed(const char *errorMessage, ...)
|
||||
EPICS_PRINTF_STYLE(1,2);
|
||||
LIBCOM_API void cantProceed(
|
||||
EPICS_PRINTF_FMT(const char *errorMessage), ...
|
||||
) EPICS_PRINTF_STYLE(1,2);
|
||||
|
||||
/** \name Memory Allocation Functions
|
||||
* These versions of calloc() and malloc() never fail, they suspend the
|
||||
|
@ -174,7 +174,7 @@ LIBCOM_API void testPlan(int tests);
|
||||
* \param ... Any parameters required for the format string.
|
||||
* \return The value of \p pass.
|
||||
*/
|
||||
LIBCOM_API int testOk(int pass, const char *fmt, ...)
|
||||
LIBCOM_API int testOk(int pass, EPICS_PRINTF_FMT(const char *fmt), ...)
|
||||
EPICS_PRINTF_STYLE(2, 3);
|
||||
/** \brief Test result using expression as description
|
||||
* \param cond Expression to be evaluated and displayed.
|
||||
@ -192,13 +192,13 @@ LIBCOM_API int testOkV(int pass, const char *fmt, va_list pvar);
|
||||
* \param fmt A printf-style format string describing the test.
|
||||
* \param ... Any parameters required for the format string.
|
||||
*/
|
||||
LIBCOM_API void testPass(const char *fmt, ...)
|
||||
LIBCOM_API void testPass(EPICS_PRINTF_FMT(const char *fmt), ...)
|
||||
EPICS_PRINTF_STYLE(1, 2);
|
||||
/** \brief Failing test result with printf-style description.
|
||||
* \param fmt A printf-style format string describing the test.
|
||||
* \param ... Any parameters required for the format string.
|
||||
*/
|
||||
LIBCOM_API void testFail(const char *fmt, ...)
|
||||
LIBCOM_API void testFail(EPICS_PRINTF_FMT(const char *fmt), ...)
|
||||
EPICS_PRINTF_STYLE(1, 2);
|
||||
/** @} */
|
||||
|
||||
@ -223,7 +223,7 @@ LIBCOM_API void testTodoEnd(void);
|
||||
* \param fmt A printf-style format string giving the reason for stopping.
|
||||
* \param ... Any parameters required for the format string.
|
||||
*/
|
||||
LIBCOM_API void testAbort(const char *fmt, ...)
|
||||
LIBCOM_API void testAbort(EPICS_PRINTF_FMT(const char *fmt), ...)
|
||||
EPICS_PRINTF_STYLE(1, 2);
|
||||
/** @} */
|
||||
|
||||
@ -231,7 +231,7 @@ LIBCOM_API void testAbort(const char *fmt, ...)
|
||||
* \param fmt A printf-style format string containing diagnostic information.
|
||||
* \param ... Any parameters required for the format string.
|
||||
*/
|
||||
LIBCOM_API int testDiag(const char *fmt, ...)
|
||||
LIBCOM_API int testDiag(EPICS_PRINTF_FMT(const char *fmt), ...)
|
||||
EPICS_PRINTF_STYLE(1, 2);
|
||||
/** \brief Mark the end of testing.
|
||||
*/
|
||||
|
@ -44,5 +44,11 @@
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*
|
||||
* Enable format-string checking if compiler supports it (if msvc is 2015 or newer)
|
||||
*/
|
||||
#if _MSC_VER >= 1900
|
||||
# define EPICS_PRINTF_FMT(a) _Printf_format_string_ a
|
||||
#endif
|
||||
|
||||
#endif /* ifndef compilerSpecific_h */
|
||||
|
@ -61,4 +61,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef EPICS_PRINTF_FMT
|
||||
/*
|
||||
* No format-string checking annotation
|
||||
*/
|
||||
# define EPICS_PRINTF_FMT(a) a
|
||||
#endif
|
||||
|
||||
#endif /* ifndef compilerDependencies_h */
|
||||
|
@ -130,7 +130,8 @@ extern "C" {
|
||||
* output has been truncated if the return value is `size` or more.
|
||||
*/
|
||||
LIBCOM_API int epicsStdCall epicsSnprintf(
|
||||
char *str, size_t size, const char *format, ...) EPICS_PRINTF_STYLE(3,4);
|
||||
char *str, size_t size, EPICS_PRINTF_FMT(const char *format), ...
|
||||
) EPICS_PRINTF_STYLE(3,4);
|
||||
/**
|
||||
* \brief epicsVsnprintf() is meant to have the same semantics as the C99
|
||||
* function vsnprintf()
|
||||
|
Reference in New Issue
Block a user