Commit 866fc3b6 authored by David Kilzer's avatar David Kilzer Committed by Nick Wellnhofer

Fix libxslt format warnings

* config.h.in: Let autoconf have its way with the file.
* configure.in: Replace "-Wformat" with
"-Wformat=2 -Wmissing-format-attribute".  Add
"-Wformat=2 -Wmissing-format-attribute" to default CFLAGS.
* libxslt/transform.c:
(xsltDocumentElem): Fix missing placeholder in format string.
Make "unsupported method" format strings more consistent by
putting method name in parenthesis.
(xsltApplyStylesheetInternal): Ditto.
* libxslt/xsltconfig.h.in:
(LIBXSLT_ATTR_FORMAT): Add macro to decorate functions that
have format string arguments.
* libxslt/xsltutils.c:
(xsltGenericErrorDefaultFunc): Add macro to decorate functions
that have format string arguments.
(xsltGenericDebugDefaultFunc): Ditto.
* libxslt/xsltutils.h:
(xsltTransformError): Add LIBXSLT_ATTR_FORMAT macro.
* xsltproc/xsltproc.c:
(endTimer): Add predeclaration with LIBXSLT_ATTR_FORMAT macro.

Fixes bug #762006.

https://bugzilla.gnome.org/show_bug.cgi?id=762006
parent d182d8f6
......@@ -431,7 +431,7 @@ if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XSLT" ]] || \
then
with_mem_debug="yes"
fi
CFLAGS="-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline "
CFLAGS="-Wall -g -O -ansi -pedantic -W -Wunused -Wimplicit -Wreturn-type -Wswitch -Wcomment -Wtrigraphs -Wformat=2 -Wmissing-format-attribute -Wchar-subscripts -Wuninitialized -Wparentheses -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Winline "
fi
AC_ARG_WITH(debug, [ --with-debug Add the debugging code (on)])
......@@ -525,7 +525,7 @@ if test "${GCC}" != "yes" ; then
;;
esac
else
CFLAGS="${CFLAGS} -Wall"
CFLAGS="${CFLAGS} -Wall -Wformat=2 -Wmissing-format-attribute"
case "${host}" in
alpha*-*-linux* )
CFLAGS="${CFLAGS} -mieee"
......
......@@ -3714,7 +3714,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
xmlDictReference(res->dict);
} else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: unsupported method xhtml\n",
"xsltDocumentElem: unsupported method xhtml (%s)\n",
style->method);
ctxt->type = XSLT_OUTPUT_HTML;
res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
......@@ -3735,7 +3735,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
#endif
} else {
xsltTransformError(ctxt, NULL, inst,
"xsltDocumentElem: unsupported method %s\n",
"xsltDocumentElem: unsupported method (%s)\n",
style->method);
goto error;
}
......@@ -5973,7 +5973,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
#endif
} else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
"xsltApplyStylesheetInternal: unsupported method xhtml, using html\n",
"xsltApplyStylesheetInternal: unsupported method xhtml (%s), using html\n",
style->method);
ctxt->type = XSLT_OUTPUT_HTML;
res = htmlNewDoc(doctypeSystem, doctypePublic);
......@@ -6000,7 +6000,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
#endif
} else {
xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
"xsltApplyStylesheetInternal: unsupported method %s\n",
"xsltApplyStylesheetInternal: unsupported method (%s)\n",
style->method);
goto error;
}
......
......@@ -152,6 +152,17 @@ extern "C" {
#define ATTRIBUTE_UNUSED
#endif
/**
* LIBXSLT_ATTR_FORMAT:
*
* This macro is used to indicate to GCC the parameters are printf-like
*/
#ifdef __GNUC__
#define LIBXSLT_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
#else
#define LIBXSLT_ATTR_FORMAT(fmt,args)
#endif
/**
* LIBXSLT_PUBLIC:
*
......
......@@ -519,7 +519,7 @@ xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) {
*
* Default handler for out of context error messages.
*/
static void
static void LIBXSLT_ATTR_FORMAT(2,3)
xsltGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
va_list args;
......@@ -565,7 +565,7 @@ xsltSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
*
* Default handler for out of context error messages.
*/
static void
static void LIBXSLT_ATTR_FORMAT(2,3)
xsltGenericDebugDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
va_list args;
......
......@@ -165,7 +165,7 @@ XSLTPUBFUN void XSLTCALL
xsltStylesheetPtr style,
xmlNodePtr node,
const char *msg,
...);
...) LIBXSLT_ATTR_FORMAT(4,5);
XSLTPUBFUN int XSLTCALL
xsltSetCtxtParseOptions (xsltTransformContextPtr ctxt,
......
......@@ -7,6 +7,7 @@
*/
#include "libxslt/libxslt.h"
#include "libxslt/xsltconfig.h"
#include "libexslt/exslt.h"
#include <stdio.h>
#ifdef HAVE_STRING_H
......@@ -236,6 +237,8 @@ my_gettimeofday(struct timeval *tvp, void *tzp)
#endif /* HAVE_SYS_TIMEB_H */
#endif /* !HAVE_GETTIMEOFDAY */
static void endTimer(const char *format, ...) LIBXSLT_ATTR_FORMAT(1,2);
#if defined(HAVE_GETTIMEOFDAY)
static struct timeval begin, endtime;
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment