Use G_GNUC_PRINTF instead of ATTRIBUTE_FMT_PRINTF

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Ján Tomko 2019-10-15 13:35:07 +02:00
parent d54153fde3
commit da367c0f9b
18 changed files with 41 additions and 61 deletions

View File

@ -629,7 +629,7 @@ sc_avoid_g_gnuc_unused_in_header:
$(_sc_search_regexp) $(_sc_search_regexp)
sc_prohibit_attribute_macros: sc_prohibit_attribute_macros:
@prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK|NOINLINE)' \ @prohibit='ATTRIBUTE_(UNUSED|NORETURN|SENTINEL|RETURN_CHECK|NOINLINE|FMT_PRINTF)' \
in_vc_files='\.[ch]$$' \ in_vc_files='\.[ch]$$' \
halt='use GLib macros: G_GNUC_<ATTRIBUTE_SUFFIX> for most' \ halt='use GLib macros: G_GNUC_<ATTRIBUTE_SUFFIX> for most' \
$(_sc_search_regexp) $(_sc_search_regexp)

View File

@ -105,26 +105,6 @@
# define G_GNUC_NO_INLINE __attribute__((__noinline__)) # define G_GNUC_NO_INLINE __attribute__((__noinline__))
#endif #endif
/**
* ATTRIBUTE_FMT_PRINTF
*
* Macro used to check printf like functions, if compiling
* with gcc.
*
* We use gnulib which guarantees we always have GNU style
* printf format specifiers even on broken Win32 platforms
* hence we have to force 'gnu_printf' for new GCC
*/
#ifndef ATTRIBUTE_FMT_PRINTF
# ifndef __clang__
# define ATTRIBUTE_FMT_PRINTF(fmtpos, argpos) \
__attribute__((__format__ (__gnu_printf__, fmtpos, argpos)))
# else
# define ATTRIBUTE_FMT_PRINTF(fmtpos, argpos) \
__attribute__((__format__ (__printf__, fmtpos, argpos)))
# endif
#endif
/** /**
* ATTRIBUTE_PACKED * ATTRIBUTE_PACKED
* *

View File

@ -54,7 +54,7 @@ libxlLoggerFileFree(void *payload, const void *key G_GNUC_UNUSED)
file = NULL; file = NULL;
} }
ATTRIBUTE_FMT_PRINTF(5, 0) static void G_GNUC_PRINTF(5, 0) static void
libvirt_vmessage(xentoollog_logger *logger_in, libvirt_vmessage(xentoollog_logger *logger_in,
xentoollog_level level, xentoollog_level level,
int errnoval, int errnoval,

View File

@ -739,7 +739,7 @@ qemuDomainLogContextPtr qemuDomainLogContextNew(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
qemuDomainLogContextMode mode); qemuDomainLogContextMode mode);
int qemuDomainLogContextWrite(qemuDomainLogContextPtr ctxt, int qemuDomainLogContextWrite(qemuDomainLogContextPtr ctxt,
const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(2, 3); const char *fmt, ...) G_GNUC_PRINTF(2, 3);
ssize_t qemuDomainLogContextRead(qemuDomainLogContextPtr ctxt, ssize_t qemuDomainLogContextRead(qemuDomainLogContextPtr ctxt,
char **msg); char **msg);
int qemuDomainLogContextGetWriteFD(qemuDomainLogContextPtr ctxt); int qemuDomainLogContextGetWriteFD(qemuDomainLogContextPtr ctxt);
@ -750,7 +750,7 @@ virLogManagerPtr qemuDomainLogContextGetManager(qemuDomainLogContextPtr ctxt);
int qemuDomainLogAppendMessage(virQEMUDriverPtr driver, int qemuDomainLogAppendMessage(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
const char *fmt, const char *fmt,
...) ATTRIBUTE_FMT_PRINTF(3, 4); ...) G_GNUC_PRINTF(3, 4);
const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver); const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver);

View File

@ -39,7 +39,7 @@ void virAuditSend(virLogSourcePtr source,
const char *clienttty, const char *clientaddr, const char *clienttty, const char *clientaddr,
virAuditRecordType type, bool success, virAuditRecordType type, bool success,
const char *fmt, ...) const char *fmt, ...)
ATTRIBUTE_FMT_PRINTF(9, 10); G_GNUC_PRINTF(9, 10);
char *virAuditEncode(const char *key, const char *value); char *virAuditEncode(const char *key, const char *value);

View File

@ -73,9 +73,9 @@ void virBufferAdd(virBufferPtr buf, const char *str, int len);
void virBufferAddBuffer(virBufferPtr buf, virBufferPtr toadd); void virBufferAddBuffer(virBufferPtr buf, virBufferPtr toadd);
void virBufferAddChar(virBufferPtr buf, char c); void virBufferAddChar(virBufferPtr buf, char c);
void virBufferAsprintf(virBufferPtr buf, const char *format, ...) void virBufferAsprintf(virBufferPtr buf, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap) void virBufferVasprintf(virBufferPtr buf, const char *format, va_list ap)
ATTRIBUTE_FMT_PRINTF(2, 0); G_GNUC_PRINTF(2, 0);
void virBufferStrcat(virBufferPtr buf, ...) void virBufferStrcat(virBufferPtr buf, ...)
G_GNUC_NULL_TERMINATED; G_GNUC_NULL_TERMINATED;
void virBufferStrcatVArgs(virBufferPtr buf, va_list ap); void virBufferStrcatVArgs(virBufferPtr buf, va_list ap);

View File

@ -98,7 +98,7 @@ void virCommandNonblockingFDs(virCommandPtr cmd);
void virCommandRawStatus(virCommandPtr cmd); void virCommandRawStatus(virCommandPtr cmd);
void virCommandAddEnvFormat(virCommandPtr cmd, const char *format, ...) void virCommandAddEnvFormat(virCommandPtr cmd, const char *format, ...)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 3); ATTRIBUTE_NONNULL(2) G_GNUC_PRINTF(2, 3);
void virCommandAddEnvPair(virCommandPtr cmd, void virCommandAddEnvPair(virCommandPtr cmd,
const char *name, const char *name,
@ -125,7 +125,7 @@ void virCommandAddArgBuffer(virCommandPtr cmd,
void virCommandAddArgFormat(virCommandPtr cmd, void virCommandAddArgFormat(virCommandPtr cmd,
const char *format, ...) const char *format, ...)
ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 3); ATTRIBUTE_NONNULL(2) G_GNUC_PRINTF(2, 3);
void virCommandAddArgPair(virCommandPtr cmd, void virCommandAddArgPair(virCommandPtr cmd,
const char *name, const char *name,

View File

@ -42,7 +42,7 @@ void virRaiseErrorFull(const char *filename,
int int1, int int1,
int int2, int int2,
const char *fmt, ...) const char *fmt, ...)
ATTRIBUTE_FMT_PRINTF(12, 13); G_GNUC_PRINTF(12, 13);
void virRaiseErrorObject(const char *filename, void virRaiseErrorObject(const char *filename,
const char *funcname, const char *funcname,
@ -54,7 +54,7 @@ void virReportErrorHelper(int domcode, int errcode,
const char *funcname, const char *funcname,
size_t linenr, size_t linenr,
const char *fmt, ...) const char *fmt, ...)
ATTRIBUTE_FMT_PRINTF(6, 7); G_GNUC_PRINTF(6, 7);
void virReportSystemErrorFull(int domcode, void virReportSystemErrorFull(int domcode,
int theerrno, int theerrno,
@ -62,7 +62,7 @@ void virReportSystemErrorFull(int domcode,
const char *funcname, const char *funcname,
size_t linenr, size_t linenr,
const char *fmt, ...) const char *fmt, ...)
ATTRIBUTE_FMT_PRINTF(6, 7); G_GNUC_PRINTF(6, 7);
#define virReportSystemError(theerrno, fmt,...) \ #define virReportSystemError(theerrno, fmt,...) \
virReportSystemErrorFull(VIR_FROM_THIS, \ virReportSystemErrorFull(VIR_FROM_THIS, \
@ -207,6 +207,6 @@ void virErrorPreserveLast(virErrorPtr *saveerr);
void virErrorRestore(virErrorPtr *savederr); void virErrorRestore(virErrorPtr *savederr);
void virLastErrorPrefixMessage(const char *fmt, ...) void virLastErrorPrefixMessage(const char *fmt, ...)
ATTRIBUTE_FMT_PRINTF(1, 2); G_GNUC_PRINTF(1, 2);
VIR_DEFINE_AUTOPTR_FUNC(virError, virFreeError); VIR_DEFINE_AUTOPTR_FUNC(virError, virFreeError);

View File

@ -320,7 +320,7 @@ char *virFileFindMountPoint(const char *type);
int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED; int virBuildPathInternal(char **path, ...) G_GNUC_NULL_TERMINATED;
int virFilePrintf(FILE *fp, const char *msg, ...) int virFilePrintf(FILE *fp, const char *msg, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
typedef struct _virHugeTLBFS virHugeTLBFS; typedef struct _virHugeTLBFS virHugeTLBFS;
typedef virHugeTLBFS *virHugeTLBFSPtr; typedef virHugeTLBFS *virHugeTLBFSPtr;
@ -361,15 +361,15 @@ int virFileCopyACLs(const char *src,
int virFileComparePaths(const char *p1, const char *p2); int virFileComparePaths(const char *p1, const char *p2);
int virFileReadValueInt(int *value, const char *format, ...) int virFileReadValueInt(int *value, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
int virFileReadValueUint(unsigned int *value, const char *format, ...) int virFileReadValueUint(unsigned int *value, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
int virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...) int virFileReadValueBitmap(virBitmapPtr *value, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
int virFileReadValueScaledInt(unsigned long long *value, const char *format, ...) int virFileReadValueScaledInt(unsigned long long *value, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
int virFileReadValueString(char **value, const char *format, ...) int virFileReadValueString(char **value, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
int virFileWaitForExists(const char *path, size_t ms, size_t tries); int virFileWaitForExists(const char *path, size_t ms, size_t tries);

View File

@ -78,7 +78,7 @@ void virFirewallRuleAddArg(virFirewallPtr firewall,
void virFirewallRuleAddArgFormat(virFirewallPtr firewall, void virFirewallRuleAddArgFormat(virFirewallPtr firewall,
virFirewallRulePtr rule, virFirewallRulePtr rule,
const char *fmt, ...) const char *fmt, ...)
ATTRIBUTE_NONNULL(3) ATTRIBUTE_FMT_PRINTF(3, 4); ATTRIBUTE_NONNULL(3) G_GNUC_PRINTF(3, 4);
void virFirewallRuleAddArgSet(virFirewallPtr firewall, void virFirewallRuleAddArgSet(virFirewallPtr firewall,
virFirewallRulePtr rule, virFirewallRulePtr rule,

View File

@ -206,7 +206,7 @@ void virLogMessage(virLogSourcePtr source,
int linenr, int linenr,
const char *funcname, const char *funcname,
virLogMetadataPtr metadata, virLogMetadataPtr metadata,
const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(7, 8); const char *fmt, ...) G_GNUC_PRINTF(7, 8);
void virLogVMessage(virLogSourcePtr source, void virLogVMessage(virLogSourcePtr source,
virLogPriority priority, virLogPriority priority,
const char *filename, const char *filename,
@ -214,7 +214,7 @@ void virLogVMessage(virLogSourcePtr source,
const char *funcname, const char *funcname,
virLogMetadataPtr metadata, virLogMetadataPtr metadata,
const char *fmt, const char *fmt,
va_list vargs) ATTRIBUTE_FMT_PRINTF(7, 0); va_list vargs) G_GNUC_PRINTF(7, 0);
bool virLogProbablyLogMessage(const char *str); bool virLogProbablyLogMessage(const char *str);
virLogOutputPtr virLogOutputNew(virLogOutputFunc f, virLogOutputPtr virLogOutputNew(virLogOutputFunc f,

View File

@ -134,10 +134,10 @@ int virStrdup(char **dest, const char *src)
int virStrndup(char **dest, const char *src, ssize_t n) int virStrndup(char **dest, const char *src, ssize_t n)
G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1); G_GNUC_WARN_UNUSED_RESULT ATTRIBUTE_NONNULL(1);
int virAsprintfInternal(char **strp, const char *fmt, ...) int virAsprintfInternal(char **strp, const char *fmt, ...)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 3) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_PRINTF(2, 3)
G_GNUC_WARN_UNUSED_RESULT; G_GNUC_WARN_UNUSED_RESULT;
int virVasprintfInternal(char **strp, const char *fmt, va_list list) int virVasprintfInternal(char **strp, const char *fmt, va_list list)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_FMT_PRINTF(2, 0) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_PRINTF(2, 0)
G_GNUC_WARN_UNUSED_RESULT; G_GNUC_WARN_UNUSED_RESULT;
/** /**

View File

@ -769,7 +769,7 @@ virTypedParamListStealParams(virTypedParamListPtr list,
} }
static int ATTRIBUTE_FMT_PRINTF(2, 0) static int G_GNUC_PRINTF(2, 0)
virTypedParamSetNameVPrintf(virTypedParameterPtr par, virTypedParamSetNameVPrintf(virTypedParameterPtr par,
const char *fmt, const char *fmt,
va_list ap) va_list ap)

View File

@ -149,34 +149,34 @@ int virTypedParamListAddInt(virTypedParamListPtr list,
int value, int value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;
int virTypedParamListAddUInt(virTypedParamListPtr list, int virTypedParamListAddUInt(virTypedParamListPtr list,
unsigned int value, unsigned int value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;
int virTypedParamListAddLLong(virTypedParamListPtr list, int virTypedParamListAddLLong(virTypedParamListPtr list,
long long value, long long value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;
int virTypedParamListAddULLong(virTypedParamListPtr list, int virTypedParamListAddULLong(virTypedParamListPtr list,
unsigned long long value, unsigned long long value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;
int virTypedParamListAddString(virTypedParamListPtr list, int virTypedParamListAddString(virTypedParamListPtr list,
const char *value, const char *value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;
int virTypedParamListAddBoolean(virTypedParamListPtr list, int virTypedParamListAddBoolean(virTypedParamListPtr list,
bool value, bool value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;
int virTypedParamListAddDouble(virTypedParamListPtr list, int virTypedParamListAddDouble(virTypedParamListPtr list,
double value, double value,
const char *namefmt, const char *namefmt,
...) ...)
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT; G_GNUC_PRINTF(3, 4) G_GNUC_WARN_UNUSED_RESULT;

View File

@ -81,7 +81,7 @@ testEventResultCallback(const void *opaque)
} }
static void static void
ATTRIBUTE_FMT_PRINTF(3, 4) G_GNUC_PRINTF(3, 4)
testEventReport(const char *name, bool failed, const char *msg, ...) testEventReport(const char *name, bool failed, const char *msg, ...)
{ {
va_list vargs; va_list vargs;

View File

@ -183,7 +183,7 @@ qemuMonitorTestAddInvalidCommandResponse(qemuMonitorTestPtr test,
} }
int ATTRIBUTE_FMT_PRINTF(2, 3) int G_GNUC_PRINTF(2, 3)
qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...) qemuMonitorReportError(qemuMonitorTestPtr test, const char *errmsg, ...)
{ {
va_list msgargs; va_list msgargs;

View File

@ -48,12 +48,12 @@ void virHostMsgSetQuiet(bool quietFlag);
void virHostMsgCheck(const char *prefix, void virHostMsgCheck(const char *prefix,
const char *format, const char *format,
...) ATTRIBUTE_FMT_PRINTF(2, 3); ...) G_GNUC_PRINTF(2, 3);
void virHostMsgPass(void); void virHostMsgPass(void);
void virHostMsgFail(virHostValidateLevel level, void virHostMsgFail(virHostValidateLevel level,
const char *format, const char *format,
...) ATTRIBUTE_FMT_PRINTF(2, 3); ...) G_GNUC_PRINTF(2, 3);
int virHostValidateDeviceExists(const char *hvname, int virHostValidateDeviceExists(const char *hvname,
const char *dev_name, const char *dev_name,

View File

@ -240,11 +240,11 @@ struct _vshCmdGrp {
}; };
void vshError(vshControl *ctl, const char *format, ...) void vshError(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
void vshOpenLogFile(vshControl *ctl); void vshOpenLogFile(vshControl *ctl);
void vshOutputLogFile(vshControl *ctl, int log_level, const char *format, void vshOutputLogFile(vshControl *ctl, int log_level, const char *format,
va_list ap) va_list ap)
ATTRIBUTE_FMT_PRINTF(3, 0); G_GNUC_PRINTF(3, 0);
void vshCloseLogFile(vshControl *ctl); void vshCloseLogFile(vshControl *ctl);
const char *vshCmddefGetInfo(const vshCmdDef *cmd, const char *info); const char *vshCmddefGetInfo(const vshCmdDef *cmd, const char *info);
@ -302,14 +302,14 @@ bool vshCommandArgvParse(vshControl *ctl, int nargs, char **argv);
int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout); int vshCommandOptTimeoutToMs(vshControl *ctl, const vshCmd *cmd, int *timeout);
void vshPrint(vshControl *ctl, const char *format, ...) void vshPrint(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
void vshPrintExtra(vshControl *ctl, const char *format, ...) void vshPrintExtra(vshControl *ctl, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(2, 3); G_GNUC_PRINTF(2, 3);
bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set); bool vshInit(vshControl *ctl, const vshCmdGrp *groups, const vshCmdDef *set);
bool vshInitReload(vshControl *ctl); bool vshInitReload(vshControl *ctl);
void vshDeinit(vshControl *ctl); void vshDeinit(vshControl *ctl);
void vshDebug(vshControl *ctl, int level, const char *format, ...) void vshDebug(vshControl *ctl, int level, const char *format, ...)
ATTRIBUTE_FMT_PRINTF(3, 4); G_GNUC_PRINTF(3, 4);
/* User visible sort, so we want locale-specific case comparison. */ /* User visible sort, so we want locale-specific case comparison. */
#define vshStrcasecmp(S1, S2) strcasecmp(S1, S2) #define vshStrcasecmp(S1, S2) strcasecmp(S1, S2)