Browse Source

HPCC-14566 Fix "non-constant format string" warnings

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 9 years ago
parent
commit
7b7d443de9

+ 1 - 1
cmake_modules/commonSetup.cmake

@@ -251,7 +251,7 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
       if (CMAKE_COMPILER_IS_GNUCXX)
         SET (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -g -fno-default-inline")
         if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.2.4 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.2.4)
-          SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
+          SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -Werror=format-nonliteral")
         endif ()
         if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.4.0)
           SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-psabi")

+ 1 - 1
common/thorhelper/roxiehelper.cpp

@@ -2571,7 +2571,7 @@ class COrderedOutputSerializer : implements IOrderedOutputSerializer, public CIn
             }
             return closed;
         }
-        size32_t printf(const char *format, va_list args)
+        size32_t printf(const char *format, va_list args)  __attribute__((format(printf,2,0)))
         {
             if (closed)
                 throw MakeStringException(0, "Attempting to append to previously closed result in COrderedResult::printf");

+ 2 - 2
common/thorhelper/roxiehelper.ipp

@@ -76,14 +76,14 @@ interface IRoxieContextLogger : extends IContextLogger
 {
     // Override base interface with versions that add prefix
     // We could consider moving some or all of these down into IContextLogger
-    virtual void CTXLOGva(const char *format, va_list args) const
+    virtual void CTXLOGva(const char *format, va_list args) const  __attribute__((format(printf,2,0)))
     {
         StringBuffer text, prefix;
         getLogPrefix(prefix);
         text.valist_appendf(format, args);
         CTXLOGa(LOG_TRACING, prefix.str(), text.str());
     }
-    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const
+    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const  __attribute__((format(printf,5,0)))
     {
         StringBuffer prefix;
         getLogPrefix(prefix);

+ 1 - 1
dali/base/dasds.ipp

@@ -360,7 +360,7 @@ public:
     CSDSException(int _errCode) : errCode(_errCode)
     {
     }
-    CSDSException(int _errCode, const char *_errMsg, va_list &args) : errCode(_errCode)
+    CSDSException(int _errCode, const char *_errMsg, va_list &args) __attribute__((format(printf,3,0))) : errCode(_errCode)
     {
         if (_errMsg)
             errMsg.valist_appendf(_errMsg, args);

+ 2 - 2
dali/base/dautils.hpp

@@ -217,7 +217,7 @@ struct da_decl TransactionLog
         unsigned transCount = owner.getTransactionCount(cmd);
         PROGLOG(">>>[%d] %s", transCount, msg.str());
     }
-    inline void log(const char *formatMsg, ...)
+    inline void log(const char *formatMsg, ...) __attribute__((format(printf, 2, 3)))
     {
         va_list args;
         va_start(args, formatMsg);
@@ -231,7 +231,7 @@ struct da_decl TransactionLog
         if (!extraStartMs)
             extraStartMs = msTick();
     }
-    inline void extra(const char *formatMsg, ...)
+    inline void extra(const char *formatMsg, ...) __attribute__((format(printf, 2, 3)))
     {
         va_list args;
         va_start(args, formatMsg);

+ 1 - 1
deployment/configgen/configengcallback.hpp

@@ -80,7 +80,7 @@ class CConfigEngCallback: public CInterface, implements IDeploymentCallback
         fprintf(stdout, "%s", sb.str());
     }
     virtual void printStatus(StatusType type, const char* processType, const char* comp, 
-        const char* instance, const char* msg=NULL, ...)
+        const char* instance, const char* msg=NULL, ...)  __attribute__((format(printf,6,7)))
     {
       if (!m_verbose) return;
       char buf[1024];

+ 1 - 1
deployment/deploy/deploy.cpp

@@ -268,7 +268,7 @@ public:
             m_transform->transform( outputXml );
             m_transform->closeResultTarget();
             
-            m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, m_transform->getMessages());
+            m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, "%s", m_transform->getMessages());
 
             if (!m_nValidationErrors)//this may get filled in by the external function
                 valid = true;

+ 1 - 1
ecl/hql/hqlerror.hpp

@@ -123,7 +123,7 @@ inline IError * createError(int errNo, const char *msg, const char *filename, in
     return createError(CategoryError, SeverityFatal, errNo, msg, filename, lineno, column, pos);
 }
 extern HQL_API void reportErrors(IErrorReceiver & receiver, IErrorArray & errors);
-void HQL_API reportErrorVa(IErrorReceiver * errors, int errNo, const ECLlocation & loc, const char* format, va_list args);
+void HQL_API reportErrorVa(IErrorReceiver * errors, int errNo, const ECLlocation & loc, const char* format, va_list args) __attribute__((format(printf, 4, 0)));
 void HQL_API reportError(IErrorReceiver * errors, int errNo, const ECLlocation & loc, const char * format, ...) __attribute__((format(printf, 4, 5)));
 
 extern HQL_API IErrorReceiver * createFileErrorReceiver(FILE *f);

+ 2 - 2
ecl/hql/hqlgram.hpp

@@ -583,11 +583,11 @@ public:
     void reportErrorUnexpectedX(const attribute & errpos, IAtom * unexpected);
 
     // Don't use overloading: va_list is the same as char*!!
-    void reportErrorVa(int errNo, const ECLlocation & a, const char* format, va_list args);
+    void reportErrorVa(int errNo, const ECLlocation & a, const char* format, va_list args) __attribute__((format(printf,4,0)));
     void reportError(int errNo, const char *msg, int lineno, int column, int position=0);
     void reportWarning(WarnErrorCategory category, int warnNo, const ECLlocation & pos, const char* format, ...) __attribute__((format(printf, 5,6)));
     void reportWarning(WarnErrorCategory category, ErrorSeverity severity, int warnNo, const ECLlocation & pos, const char* format, ...) __attribute__((format(printf, 6, 7)));
-    void reportWarningVa(WarnErrorCategory category, int errNo, const attribute& a, const char* format, va_list args);
+    void reportWarningVa(WarnErrorCategory category, int errNo, const attribute& a, const char* format, va_list args) __attribute__((format(printf, 5,0)));
     void reportWarning(WarnErrorCategory category, int warnNo, const char *msg, int lineno, int column);
     void addResult(IHqlExpression *query, const attribute& errpos);
 

+ 1 - 0
ecl/hql/hqlgram2.cpp

@@ -264,6 +264,7 @@ bool HqlGramCtx::hasAnyActiveParameters()
 }
 
 
+static IError * createErrorVA(WarnErrorCategory category, ErrorSeverity severity, int errNo, const ECLlocation & pos, const char* format, va_list args) __attribute__((format(printf,5,0)));
 static IError * createErrorVA(WarnErrorCategory category, ErrorSeverity severity, int errNo, const ECLlocation & pos, const char* format, va_list args)
 {
     StringBuffer msg;

+ 2 - 2
ecl/hql/hqlparse.cpp

@@ -100,8 +100,8 @@ public:
     virtual StringBuffer& mangle(const char* src, StringBuffer& mangled) { return ::mangle(m_lookupContext.errs,src,mangled,false); }
     virtual StringBuffer& demangle(const char* mangled, StringBuffer& demangled) { return ::mangle(m_lookupContext.errs,mangled,demangled,true); }
 
-    virtual void reportError(int errNo,const char* format,...);
-    virtual void reportWarning(int warnNo,const char* format,...);
+    virtual void reportError(int errNo,const char* format,...)  __attribute__((format(printf,3,4)));
+    virtual void reportWarning(int warnNo,const char* format,...) __attribute__((format(printf,3,4)));;
 };
 
 void CTemplateContext::reportError(int errNo,const char* format,...)

+ 2 - 1
ecl/hthor/hthor.ipp

@@ -53,7 +53,8 @@ class CHThorException : public CInterface, implements IHThorException
 {
 public: 
     IMPLEMENT_IINTERFACE;
-    CHThorException(int _code, char const * format, va_list args, MessageAudience _audience, ThorActivityKind _kind, unsigned _activityId, unsigned _subgraphId) : code(_code), audience(_audience), kind(_kind), activityId(_activityId), subgraphId(_subgraphId)
+    CHThorException(int _code, char const * format, va_list args, MessageAudience _audience, ThorActivityKind _kind, unsigned _activityId, unsigned _subgraphId)  __attribute__((format(printf,3,0)))
+    : code(_code), audience(_audience), kind(_kind), activityId(_activityId), subgraphId(_subgraphId)
     {
         msg.valist_appendf(format, args);
     }

+ 4 - 6
esp/platform/espcontext.cpp

@@ -386,7 +386,7 @@ public:
         return m_SecurityHandler.validateSecFeatureAccess(pszFeatureUrl, required, throwExcpt);
     }
 
-    void AuditMessage(AuditType type, const char *filterType, const char *title, const char *parms, ...);
+    void AuditMessage(AuditType type, const char *filterType, const char *title, const char *parms, ...) __attribute__((format(printf, 5, 6)));
     void AuditMessage(AuditType type, const char *filterType, const char *title);
 
     IProperties * queryXslParameters()
@@ -484,12 +484,10 @@ void CEspContext::AuditMessage(AuditType type, const char *filterType, const cha
     va_list args;
     va_start(args, parms);
 
-    StringBuffer msg;
-    StringBuffer format(title);
-    format.appendf("\n\tProcess: esp\n\tService: %s\n\tUser: %s", m_servName.str(), queryUserId());
+    StringBuffer msg(title);
+    msg.appendf("\n\tProcess: esp\n\tService: %s\n\tUser: %s", m_servName.str(), queryUserId());
     if (parms)
-        format.append("\n\t").append(parms);
-    msg.valist_appendf(format.str(), args);
+        msg.append("\n\t").valist_appendf(parms, args);
     
     va_end(args);
     AUDIT(type, msg.str());

+ 3 - 5
esp/platform/sechandler.cpp

@@ -291,12 +291,10 @@ void SecHandler::AuditMessage(AuditType type, const char *filterType, const char
     va_list args;
     va_start(args, parms);
 
-    StringBuffer msg;
-    StringBuffer format(title);
-    format.appendf("\n\tProcess: esp\n\tUser: %s",  m_user->getName());
+    StringBuffer msg(title);
+    msg.appendf("\n\tProcess: esp\n\tUser: %s",  m_user->getName());
     if (parms)
-        format.append("\n\t").append(parms);
-    msg.valist_appendf(format.str(), args);
+        msg.append("\n\t").valist_appendf(parms, args);
     
     va_end(args);
     AUDIT(type, msg.str());

+ 2 - 2
esp/services/WsDeploy/WsDeployEngine.cpp

@@ -339,7 +339,7 @@ void CWsDeployEngine::deploy(CDeployOptions& pOptions)
         if (m_errorCount > 1)
           msg.append('s');
       }
-      printStatus(STATUS_NORMAL, NULL, NULL, NULL, msg.str());
+      printStatus(STATUS_NORMAL, NULL, NULL, NULL, "%s", msg.str());
     }
   }
   catch (IException* e)
@@ -488,7 +488,7 @@ void CWsDeployEngine::deploy()
         if (m_errorCount > 1)
           msg.append('s');
       }
-      printStatus(STATUS_NORMAL, NULL, NULL, NULL, msg.str());
+      printStatus(STATUS_NORMAL, NULL, NULL, NULL, "%s", msg.str());
     }
   }
   catch (IException* e)

+ 1 - 1
esp/services/WsDeploy/WsDeployEngine.hpp

@@ -46,7 +46,7 @@ public:
 
     virtual void printStatus(IDeployTask* task);
     virtual void printStatus(StatusType type, const char* processType, const char* process, 
-                                     const char* instance, const char* format=NULL, ...);
+                             const char* instance, const char* format=NULL, ...) __attribute((format(printf,6,7)));
    virtual bool onDisconnect(const char* target);
     bool getAbortStatus() const
     {

+ 1 - 1
esp/services/common/wsexcept.hpp

@@ -62,6 +62,6 @@ interface IWsException : extends IException
 IWsException esdl_decl *makeWsException(IMultiException& me, WsErrorType errorType);
 IWsException esdl_decl *makeWsException(const char *source, WsErrorType errorType);
 IWsException esdl_decl *makeWsException(IException& e, WsErrorType errorType, const char* source = NULL );
-IWsException esdl_decl *makeWsException(int errorCode, WsErrorType errorType, const char* source, const char *format, ...);
+IWsException esdl_decl *makeWsException(int errorCode, WsErrorType errorType, const char* source, const char *format, ...) __attribute__((format(printf,4,5)));
 
 #endif

+ 2 - 2
esp/services/esdl_svc_engine/esdl_binding.cpp

@@ -1426,7 +1426,7 @@ int EsdlBindingImpl::HandleSoapRequest(CHttpRequest* request,
         text.appendf("Parsing xml error: %s.", exml.getMessage().c_str());
         ESPLOG(LogMax, "%s\n", text.str());
 
-        throw makeWsException(  ERR_ESDL_BINDING_BADREQUEST, WSERR_SERVER, "Esp", text.str() );
+        throw makeWsException(  ERR_ESDL_BINDING_BADREQUEST, WSERR_SERVER, "Esp", "%s", text.str() );
     }
     catch (IException *e)
     {
@@ -1438,7 +1438,7 @@ int EsdlBindingImpl::HandleSoapRequest(CHttpRequest* request,
         StringBuffer text;
         text.append( "EsdlBindingImpl could not process SOAP request" );
         ESPLOG(LogMax,"%s", text.str());
-        throw makeWsException( ERR_ESDL_BINDING_INTERNERR, WSERR_SERVER, "ESP", text.str() );
+        throw makeWsException( ERR_ESDL_BINDING_INTERNERR, WSERR_SERVER, "ESP", "%s", text.str() );
     }
 
     return 0;

+ 1 - 1
esp/smc/SMCLib/LogicFileWrapper.hpp

@@ -57,7 +57,7 @@ struct ErrorReceiver: public CInterface, implements IErrorListener
 {
     IMPLEMENT_IINTERFACE;    
     
-    virtual void reportError(const char* err,...)
+    virtual void reportError(const char* err,...) __attribute__((format(printf,2,3)))
     {
         va_list args;
         va_start(args, err);

+ 1 - 1
plugins/cassandra/cassandraembed.hpp

@@ -295,7 +295,7 @@ public:
         check(cass_statement_bind_collection(statement, idx, value));
     }
 private:
-    void traceBind(unsigned idx, const char *format, ...)
+    void traceBind(unsigned idx, const char *format, ...) __attribute__((format(printf,3,4)))
     {
         assert(query.length());
         StringBuffer bound;

+ 1 - 1
roxie/ccd/ccd.hpp

@@ -601,7 +601,7 @@ public:
             log.append(* new LogItem(category, prefix, msTick() - start, channel, text));
         }
     }
-    virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const
+    virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const  __attribute__((format(printf,6,0)))
     {
         StringBuffer text;
         text.append("ERROR");

+ 4 - 4
roxie/ccd/ccdserver.cpp

@@ -207,7 +207,7 @@ public:
     {
         return ctx->queryStats();
     }
-    virtual void CTXLOGva(const char *format, va_list args) const
+    virtual void CTXLOGva(const char *format, va_list args) const __attribute__((format(printf,2,0)))
     {
         ctx->CTXLOGva(format, args);
     }
@@ -215,11 +215,11 @@ public:
     {
         ctx->CTXLOGa(category, prefix, text);
     }
-    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const
+    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0)))
     {
         ctx->logOperatorExceptionVA(E, file, line, format, args);
     }
-    virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const
+    virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const __attribute__((format(printf,6,0)))
     {
         ctx->CTXLOGaeva(E, file, line, prefix, format, args);
     }
@@ -971,7 +971,7 @@ public:
             DBGLOG("[%s] %s", prefix, text);
     }
 
-    virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const
+    virtual void CTXLOGaeva(IException *E, const char *file, unsigned line, const char *prefix, const char *format, va_list args) const __attribute((format(printf,6,0)))
     {
         if (ctx)
             ctx->CTXLOGaeva(E, file, line, prefix, format, args);

+ 1 - 1
system/jhtree/ctfile.cpp

@@ -1013,7 +1013,7 @@ class CKeyException : public CInterface, implements IKeyException
 public:
     IMPLEMENT_IINTERFACE;
 
-    CKeyException(int _errCode, const char *_errMsg, va_list &args) : errCode(_errCode)
+    CKeyException(int _errCode, const char *_errMsg, va_list &args) __attribute__((format(printf,3,0))) : errCode(_errCode)
     {
         if (_errMsg)
             errMsg.valist_appendf(_errMsg, args);

+ 2 - 2
system/jlib/jexcept.hpp

@@ -67,10 +67,10 @@ interface IExceptionHandler
 };
 
 IException jlib_decl *makeStringExceptionV(int code, const char *why, ...) __attribute__((format(printf, 2, 3)));
-IException jlib_decl *makeStringExceptionVA(int code, const char *why, va_list args);
+IException jlib_decl *makeStringExceptionVA(int code, const char *why, va_list args) __attribute__((format(printf, 2, 0)));
 IException jlib_decl *makeStringException(int code, const char *why);
 IException jlib_decl *makeStringExceptionV(MessageAudience aud, int code, const char *why, ...) __attribute__((format(printf, 3, 4)));
-IException jlib_decl *makeStringExceptionVA(MessageAudience aud, int code, const char *why, va_list args);
+IException jlib_decl *makeStringExceptionVA(MessageAudience aud, int code, const char *why, va_list args) __attribute__((format(printf, 3, 0)));
 IException jlib_decl *makeStringException(MessageAudience aud, int code, const char *why);
 __declspec(noreturn) void jlib_decl throwStringExceptionV(int code, const char *format, ...) __attribute__((format(printf, 2, 3), noreturn));
 

+ 2 - 2
system/jlib/jlog.cpp

@@ -2547,13 +2547,13 @@ public:
     virtual void Link() const {}
     virtual bool Release() const { return false; }
 
-    virtual void CTXLOGva(const char *format, va_list args) const
+    virtual void CTXLOGva(const char *format, va_list args) const __attribute__((format(printf,2,0)))
     {
         StringBuffer ss;
         ss.valist_appendf(format, args);
         DBGLOG("%s", ss.str());
     }
-    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const
+    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0)))
     {
         StringBuffer ss;
         ss.append("ERROR");

+ 5 - 3
system/jlib/jlog.hpp

@@ -431,7 +431,9 @@ class jlib_decl LogMsg : public CInterface
 public:
     LogMsg() : category(), sysInfo(), jobInfo(), remoteFlag(false) {}
     LogMsg(const LogMsgCategory & _cat, LogMsgId _id, const LogMsgJobInfo & _jobInfo, LogMsgCode _code, const char * _text, unsigned _compo, unsigned port, LogMsgSessionId session) : category(_cat), sysInfo(_id, port, session), jobInfo(_jobInfo), msgCode(_code), component(_compo), remoteFlag(false) { text.append(_text); }
-    LogMsg(const LogMsgCategory & _cat, LogMsgId _id, const LogMsgJobInfo & _jobInfo, LogMsgCode _code, const char * format, va_list args, unsigned _compo, unsigned port, LogMsgSessionId session) : category(_cat), sysInfo(_id, port, session), jobInfo(_jobInfo), msgCode(_code), component(_compo), remoteFlag(false) { text.valist_appendf(format, args); }
+    LogMsg(const LogMsgCategory & _cat, LogMsgId _id, const LogMsgJobInfo & _jobInfo, LogMsgCode _code, const char * format, va_list args,
+           unsigned _compo, unsigned port, LogMsgSessionId session)  __attribute__((format(printf,6, 0)))
+    : category(_cat), sysInfo(_id, port, session), jobInfo(_jobInfo), msgCode(_code), component(_compo), remoteFlag(false) { text.valist_appendf(format, args); }
     LogMsg(MemoryBuffer & in) { deserialize(in, false); }
     StringBuffer &            toStringPlain(StringBuffer & out, unsigned fields = MSGFIELD_all) const;
     StringBuffer &            toStringXML(StringBuffer & out, unsigned fields = MSGFIELD_all) const;
@@ -996,9 +998,9 @@ extern jlib_decl void AuditSystemAccess(const char *userid, bool success, char c
 interface jlib_decl IContextLogger : extends IInterface
 {
     void CTXLOG(const char *format, ...) const  __attribute__((format(printf, 2, 3)));
-    virtual void CTXLOGva(const char *format, va_list args) const = 0;
+    virtual void CTXLOGva(const char *format, va_list args) const __attribute__((format(printf,2,0))) = 0;
     void logOperatorException(IException *E, const char *file, unsigned line, const char *format, ...) const  __attribute__((format(printf, 5, 6)));
-    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const = 0;
+    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0))) = 0;
     virtual void noteStatistic(StatisticKind kind, unsigned __int64 value) const = 0;
     virtual void mergeStats(const CRuntimeStatisticCollection &from) const = 0;
     virtual unsigned queryTraceLevel() const = 0;

+ 16 - 16
system/jlib/jlog.ipp

@@ -735,25 +735,25 @@ public:
     void                      setQueueDroppingLimit(unsigned lim, unsigned numToDrop);
     void                      resetQueueLimit();
     bool                      flushQueue(unsigned timeout) { if(processor) return processor->flush(timeout); else return true; }
-    void                      report(const LogMsgCategory & cat, const char * format, ...);
-    void                      report_va(const LogMsgCategory & cat, const char * format, va_list args);
-    void                      report(const LogMsgCategory & cat, LogMsgCode code, const char * format, ...);
-    void                      report_va(const LogMsgCategory & cat, LogMsgCode code, const char * format, va_list args);
+    void                      report(const LogMsgCategory & cat, const char * format, ...) __attribute__((format(printf,3,4)));
+    void                      report_va(const LogMsgCategory & cat, const char * format, va_list args) __attribute__((format(printf,3,0)));
+    void                      report(const LogMsgCategory & cat, LogMsgCode code, const char * format, ...) __attribute__((format(printf,4,5)));
+    void                      report_va(const LogMsgCategory & cat, LogMsgCode code, const char * format, va_list args) __attribute__((format(printf,4,0)));
     void                      report(const LogMsgCategory & cat, const IException * e, const char * prefix = NULL);
-    void                      report(unsigned compo, const LogMsgCategory & cat, const char * format, ...);
-    void                      report_va(unsigned compo, const LogMsgCategory & cat, const char * format, va_list args);
-    void                      report(unsigned compo, const LogMsgCategory & cat, LogMsgCode code, const char * format, ...);
-    void                      report_va(unsigned compo, const LogMsgCategory & cat, LogMsgCode code, const char * format, va_list args);
+    void                      report(unsigned compo, const LogMsgCategory & cat, const char * format, ...) __attribute__((format(printf,4,5)));
+    void                      report_va(unsigned compo, const LogMsgCategory & cat, const char * format, va_list args) __attribute__((format(printf,4,0)));
+    void                      report(unsigned compo, const LogMsgCategory & cat, LogMsgCode code, const char * format, ...) __attribute__((format(printf,5,6)));
+    void                      report_va(unsigned compo, const LogMsgCategory & cat, LogMsgCode code, const char * format, va_list args) __attribute__((format(printf,5,0)));
     void                      report(unsigned compo, const LogMsgCategory & cat, const IException * e, const char * prefix = NULL);
-    void                      report(const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, ...);
-    void                      report_va(const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, va_list args);
-    void                      report(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, ...);
-    void                      report_va(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, va_list args);
+    void                      report(const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, ...) __attribute__((format(printf,4,5)));
+    void                      report_va(const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, va_list args) __attribute__((format(printf,4,0)));
+    void                      report(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, ...) __attribute__((format(printf,5,6)));
+    void                      report_va(const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, va_list args) __attribute__((format(printf,5,0)));
     void                      report(const LogMsgCategory & cat, const LogMsgJobInfo & job, const IException * e, const char * prefix = NULL);
-    void                      report(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, ...);
-    void                      report_va(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, va_list args);
-    void                      report(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, ...);
-    void                      report_va(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, va_list args);
+    void                      report(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, ...) __attribute__((format(printf,5,6)));
+    void                      report_va(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, const char * format, va_list args) __attribute__((format(printf,5,0)));
+    void                      report(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, ...) __attribute__((format(printf,6,7)));
+    void                      report_va(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, LogMsgCode code, const char * format, va_list args)__attribute__((format(printf,6,0)));
     void                      report(unsigned compo, const LogMsgCategory & cat, const LogMsgJobInfo & job, const IException * e, const char * prefix = NULL);
     void                      report(const LogMsg & msg) const { if(prefilter.includeCategory(msg.queryCategory())) doReport(msg); }
     bool                      addMonitor(ILogMsgHandler * handler, ILogMsgFilter * filter);

+ 6 - 3
system/jlib/jptree.cpp

@@ -48,7 +48,7 @@
 #undef UNIMPLEMENTED
 #define UNIMPLEMENTED throw MakeIPTException(-1, "UNIMPLEMENTED")
 #define CHECK_ATTRIBUTE(X) if (X && isAttribute(X)) throw MakeIPTException(PTreeExcpt_XPath_Unsupported, "Attribute usage invalid here");
-#define AMBIGUOUS_PATH(X,P) { StringBuffer buf; buf.append(X": ambiguous xpath \"").append(P).append("\"");  throw MakeIPTException(PTreeExcpt_XPath_Ambiguity,buf.str()); }
+#define AMBIGUOUS_PATH(X,P) { StringBuffer buf; buf.append(X": ambiguous xpath \"").append(P).append("\"");  throw MakeIPTException(PTreeExcpt_XPath_Ambiguity,"%s",buf.str()); }
 
 #define PTREE_COMPRESS_THRESHOLD (4*1024)    // i.e. only use compress if > threshold
 #define PTREE_COMPRESS_BOTHER_PECENTAGE (80) // i.e. if it doesn't compress to <80 % of original size don't bother
@@ -454,7 +454,7 @@ class jlib_thrown_decl CPTreeException : public CInterface, implements IPTreeExc
 public:
     IMPLEMENT_IINTERFACE;
 
-    CPTreeException(int _errCode, const char *_errMsg, va_list &args) : errCode(_errCode)
+    CPTreeException(int _errCode, const char *_errMsg, va_list &args) __attribute__((format(printf,3,0))) : errCode(_errCode)
     {
         if (_errMsg)
             errMsg.valist_appendf(_errMsg, args);
@@ -487,6 +487,9 @@ public:
     MessageAudience errorAudience() const { return MSGAUD_user; }
 };
 
+static IPTreeException *MakeIPTException(int code, const char *format, ...) __attribute__((format(printf,2,3)));
+static IPTreeException *MakeXPathException(const char *xpath, int code, size_t pos, const char *format, ...) __attribute__((format(printf,4,5)));
+
 IPTreeException *MakeIPTException(int code, const char *format, ...)
 {
     va_list args;
@@ -509,7 +512,7 @@ IPTreeException *MakeXPathException(const char *xpath, int code, size_t pos, con
     const char *msg = "in xpath = ";
     s.append("\n").append(msg).append(xpath);
     s.append("\n").appendN((size32_t)(strlen(msg)+pos), ' ').append("^");
-    return MakeIPTException(code, s.str());
+    return MakeIPTException(code, "%s", s.str());
 }
 
 inline static void readID(const char *&xxpath, bool started)

+ 1 - 1
system/jlib/jregexp.hpp

@@ -71,7 +71,7 @@ public:
   // can only be called after a successful find/findnext
   // maxlen is the maximum size of the result string after replacement
 
-  const char * substitute(StringBuffer &s,const char *mask,...);
+  const char * substitute(StringBuffer &s,const char *mask,...) __attribute__((format(printf,3,4)));;
   // (for DAB)
   // Creates a string from mask (and following parameters) where mask is
   // a 'sprintf' string with the addition that *after* the sprintf

+ 3 - 3
system/jlib/jstring.hpp

@@ -70,8 +70,8 @@ public:
     StringBuffer &  appendLower(unsigned len, const char * value);
 
     StringBuffer &  setf(const char* format, ...) __attribute__((format(printf,2,3)));
-    StringBuffer &  limited_valist_appendf(unsigned szLimit, const char *format, va_list args);
-    inline StringBuffer &valist_appendf(const char *format, va_list args) { return limited_valist_appendf(0, format, args); }
+    StringBuffer &  limited_valist_appendf(unsigned szLimit, const char *format, va_list args) __attribute__((format(printf,3,0)));
+    inline StringBuffer &valist_appendf(const char *format, va_list args) __attribute__((format(printf,2,0))) { return limited_valist_appendf(0, format, args); }
     StringBuffer &  appendhex(unsigned char value, char lower);
     inline char     charAt(size32_t pos) { return buffer[pos]; }
     inline StringBuffer & clear() { curLen = 0; return *this; }
@@ -461,7 +461,7 @@ jlib_decl StringBuffer &encodeJSON(StringBuffer &s, const char *value);
 jlib_decl StringBuffer &encodeJSON(StringBuffer &s, unsigned len, const char *value);
 
 jlib_decl StringBuffer &appendJSONName(StringBuffer &s, const char *name);
-jlib_decl StringBuffer &appendfJSONName(StringBuffer &s, const char *format, ...);
+jlib_decl StringBuffer &appendfJSONName(StringBuffer &s, const char *format, ...) __attribute__((format(printf, 2, 3)));
 jlib_decl StringBuffer &appendJSONDataValue(StringBuffer& s, const char *name, unsigned len, const void *_value);
 jlib_decl StringBuffer &appendJSONRealValue(StringBuffer& s, const char *name, double value);
 

+ 1 - 0
system/xmllib/libxml_validator.cpp

@@ -177,6 +177,7 @@ static xmlSAXHandler emptySAXHandlerStruct = {
 
 static xmlSAXHandlerPtr emptySAXHandler = &emptySAXHandlerStruct;
 
+static void libxmlXsdErrorMsgHandler(void *ctx, const char *format, ...) __attribute__((format(printf,2,3)));
 static void libxmlXsdErrorMsgHandler(void *ctx, const char *format, ...)
 {
     va_list args;

+ 1 - 0
system/xmllib/libxslt_processor.cpp

@@ -477,6 +477,7 @@ CLibXslTransform *getXsltTransformObject(xsltTransformContextPtr x)
 
 void globalLibXsltExtensionHandler(xmlXPathParserContextPtr ctxt, int nargs);
 
+static void libxsltErrorMsgHandler(void *ctx, const char *format, ...) __attribute__((format(printf,2,3)));
 static void libxsltErrorMsgHandler(void *ctx, const char *format, ...)
 {
     if (!ctx)

+ 8 - 20
thorlcr/activities/hashdistrib/thhashdistribslave.cpp

@@ -938,37 +938,25 @@ protected:
     }
     void ActPrintLog(const char *format, ...)  __attribute__((format(printf, 2, 3)))
     {
-        const char *pdFormat;
-        StringBuffer dFormat;
+        StringBuffer msg;
         if (id.get())
-        {
-            dFormat.appendf("[ %s ] : ", id.get());
-            dFormat.append(format);
-            pdFormat = dFormat.str();
-        }
-        else
-            pdFormat = format;
+            msg.appendf("[ %s ] : ", id.get());
         va_list args;
         va_start(args, format);
-        ::ActPrintLogArgs(&activity->queryContainer(), thorlog_null, MCdebugProgress, pdFormat, args);
+        msg.valist_appendf(format, args);
         va_end(args);
+        ::ActPrintLogEx(&activity->queryContainer(), thorlog_null, MCdebugProgress, "%s", msg.str());
     }
     void ActPrintLog(IException *e, const char *format, ...) __attribute__((format(printf, 3, 4)))
     {
-        const char *pdFormat;
-        StringBuffer dFormat;
+        StringBuffer msg;
         if (id.get())
-        {
-            dFormat.appendf("[ %s ] : ", id.get());
-            dFormat.append(format);
-            pdFormat = dFormat.str();
-        }
-        else
-            pdFormat = format;
+            msg.appendf("[ %s ] : ", id.get());
         va_list args;
         va_start(args, format);
-        ::ActPrintLogArgs(&activity->queryContainer(), e, thorlog_all, MCexception(e), format, args);
+        msg.valist_appendf(format, args);
         va_end(args);
+        ::ActPrintLogEx(&activity->queryContainer(), e, thorlog_all, MCexception(e), "%s", msg.str());
     }
 protected:
     CActivityBase *activity;

+ 2 - 2
thorlcr/graph/thgraph.cpp

@@ -2401,13 +2401,13 @@ public:
     {
         traceLevel = 1;
     }
-    virtual void CTXLOGva(const char *format, va_list args) const
+    virtual void CTXLOGva(const char *format, va_list args) const __attribute__((format(printf,2,0)))
     {
         StringBuffer ss;
         ss.valist_appendf(format, args);
         LOG(MCdebugProgress, thorJob, "%s", ss.str());
     }
-    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const
+    virtual void logOperatorExceptionVA(IException *E, const char *file, unsigned line, const char *format, va_list args) const __attribute__((format(printf,5,0)))
     {
         StringBuffer ss;
         ss.append("ERROR");

+ 8 - 5
thorlcr/thorutil/thormisc.cpp

@@ -310,6 +310,7 @@ public:
     MessageAudience errorAudience() const { return audience; }
 };
 
+CThorException *_MakeThorException(LogMsgAudience audience,int code, const char *format, va_list args) __attribute__((format(printf,3,0)));
 CThorException *_MakeThorException(LogMsgAudience audience,int code, const char *format, va_list args)
 {
     StringBuffer eStr;
@@ -317,6 +318,7 @@ CThorException *_MakeThorException(LogMsgAudience audience,int code, const char
     return new CThorException(audience, code, eStr.str());
 }
 
+CThorException *_ThorWrapException(IException *e, const char *format, va_list args) __attribute__((format(printf,2,0)));
 CThorException *_ThorWrapException(IException *e, const char *format, va_list args)
 {
     StringBuffer eStr;
@@ -370,6 +372,7 @@ void setExceptionActivityInfo(CGraphElementBase &container, IThorException *e)
     e->setGraphId(container.queryOwner().queryGraphId());
 }
 
+IThorException *_MakeActivityException(CGraphElementBase &container, int code, const char *format, va_list args) __attribute__((format(printf,3,0)));
 IThorException *_MakeActivityException(CGraphElementBase &container, int code, const char *format, va_list args)
 {
     IThorException *e = _MakeThorException(MSGAUD_user, code, format, args);
@@ -377,14 +380,14 @@ IThorException *_MakeActivityException(CGraphElementBase &container, int code, c
     return e;
 }
 
+IThorException *_MakeActivityException(CGraphElementBase &container, IException *e, const char *_format, va_list args) __attribute__((format(printf,3,0)));
 IThorException *_MakeActivityException(CGraphElementBase &container, IException *e, const char *_format, va_list args)
 {
-    StringBuffer format;
-    e->errorMessage(format);
+    StringBuffer msg;
+    e->errorMessage(msg);
     if (_format)
-        format.append(", ").append(_format);
-    _format = format.str();
-    IThorException *e2 = _MakeThorException(e->errorAudience(), e->errorCode(), format.str(), args);
+        msg.append(", ").limited_valist_appendf(1024, _format, args);
+    IThorException *e2 = new CThorException(e->errorAudience(), e->errorCode(), msg.str());
     setExceptionActivityInfo(container, e2);
     return e2;
 }

+ 7 - 7
thorlcr/thorutil/thormisc.hpp

@@ -330,10 +330,10 @@ class CGraphBase;
 interface IRemoteConnection;
 enum ActLogEnum { thorlog_null=0,thorlog_ecl=1,thorlog_all=2 };
 
-extern graph_decl StringBuffer &ActPrintLogArgsPrep(StringBuffer &res, const CGraphElementBase *container, const ActLogEnum flags, const char *format, va_list args);
+extern graph_decl StringBuffer &ActPrintLogArgsPrep(StringBuffer &res, const CGraphElementBase *container, const ActLogEnum flags, const char *format, va_list args) __attribute__((format(printf,4,0)));
 extern graph_decl void ActPrintLogEx(const CGraphElementBase *container, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, ...) __attribute__((format(printf, 4, 5)));
-extern graph_decl void ActPrintLogArgs(const CGraphElementBase *container, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args);
-extern graph_decl void ActPrintLogArgs(const CGraphElementBase *container, IException *e, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args);
+extern graph_decl void ActPrintLogArgs(const CGraphElementBase *container, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args) __attribute__((format(printf,4,0)));
+extern graph_decl void ActPrintLogArgs(const CGraphElementBase *container, IException *e, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args) __attribute__((format(printf,5,0)));
 extern graph_decl void ActPrintLog(const CActivityBase *activity, const char *format, ...) __attribute__((format(printf, 2, 3)));
 extern graph_decl void ActPrintLog(const CActivityBase *activity, IException *e, const char *format, ...) __attribute__((format(printf, 3, 4)));
 extern graph_decl void ActPrintLog(const CActivityBase *activity, IException *e);
@@ -366,9 +366,9 @@ inline void ActPrintLog(const CGraphElementBase *container, IException *e)
 {
     ActPrintLogEx(container, e, thorlog_null, MCexception(e, MSGCLS_error), "%s", "");
 }
-extern graph_decl void GraphPrintLogArgsPrep(StringBuffer &res, CGraphBase *graph, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args);
-extern graph_decl void GraphPrintLogArgs(CGraphBase *graph, IException *e, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args);
-extern graph_decl void GraphPrintLogArgs(CGraphBase *graph, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args);
+extern graph_decl void GraphPrintLogArgsPrep(StringBuffer &res, CGraphBase *graph, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args) __attribute__((format(printf,5,0)));
+extern graph_decl void GraphPrintLogArgs(CGraphBase *graph, IException *e, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args) __attribute__((format(printf,5,0)));
+extern graph_decl void GraphPrintLogArgs(CGraphBase *graph, const ActLogEnum flags, const LogMsgCategory &logCat, const char *format, va_list args) __attribute__((format(printf,4,0)));
 extern graph_decl void GraphPrintLog(CGraphBase *graph, IException *e, const char *format, ...) __attribute__((format(printf, 3, 4)));
 
 inline void GraphPrintLogEx(CGraphBase *graph, ActLogEnum flags, const LogMsgCategory &logCat, const char *format, ...) __attribute__((format(printf, 4, 5)));
@@ -405,7 +405,7 @@ extern graph_decl IThorException *MakeActivityException(CGraphElementBase *activ
 extern graph_decl IThorException *MakeActivityException(CGraphElementBase *activity, IException *e);
 extern graph_decl IThorException *MakeActivityWarning(CGraphElementBase *activity, int code, const char *_format, ...) __attribute__((format(printf, 3, 4)));
 extern graph_decl IThorException *MakeActivityWarning(CGraphElementBase *activity, IException *e, const char *format, ...) __attribute__((format(printf, 3, 4)));
-extern graph_decl IThorException *MakeGraphException(CGraphBase *graph, int code, const char *format, ...);
+extern graph_decl IThorException *MakeGraphException(CGraphBase *graph, int code, const char *format, ...) __attribute__((format(printf, 3, 4)));
 extern graph_decl IThorException *MakeThorException(int code, const char *format, ...) __attribute__((format(printf, 2, 3)));
 extern graph_decl IThorException *MakeThorException(IException *e);
 extern graph_decl IThorException *MakeThorAudienceException(LogMsgAudience audience, int code, const char *format, ...) __attribute__((format(printf, 3, 4)));

+ 5 - 0
tools/esdlcomp/esdlcomp.cpp

@@ -275,6 +275,8 @@ char *appendstr(char *text,const char *str)
     return text;
 }
 
+static void voutf(const char* fmt,va_list args) __attribute__((format(printf,1,0)));
+
 void voutf(const char* fmt,va_list args)
 {
     const int BUF_LEN = 0x4000;
@@ -333,6 +335,7 @@ void indentOuts1(int inc, const char* s)
     out(s,strlen(s));
 }
 
+static void indentOutf(const char* fmt, ...) __attribute__((format(printf,1,2)));
 void indentOutf(const char* fmt, ...)
 {
     indent(gIndent);
@@ -343,6 +346,7 @@ void indentOutf(const char* fmt, ...)
     va_end(args);
 }
 
+static void indentOutf(int inc, const char* fmt, ...) __attribute__((format(printf,2,3)));
 void indentOutf(int inc, const char* fmt, ...)
 {
     gIndent += inc;
@@ -354,6 +358,7 @@ void indentOutf(int inc, const char* fmt, ...)
     va_end(args);
 }
 
+static void indentOutf1(int inc, const char* fmt, ...) __attribute__((format(printf,2,3)));
 void indentOutf1(int inc, const char* fmt, ...)
 {
     indent(gIndent+inc);

+ 1 - 1
tools/hidl/hidl_utils.hpp

@@ -67,7 +67,7 @@ public:
     StrBuffer &  setf(const char* format, ...) __attribute__((format(printf, 2, 3)));
     StrBuffer &  set(const char* val) { return clear().append(val); }
     StrBuffer &  clear() { curLen = 0; return *this; }
-    StrBuffer & va_append(const char *format, va_list args);
+    StrBuffer & va_append(const char *format, va_list args)  __attribute__((format(printf,2,0)));
     
     const char * str() const;
     operator const char* () const { return str(); }

+ 4 - 0
tools/hidl/hidlcomp.cpp

@@ -299,6 +299,7 @@ void outs(int indents, const char *s)
     out(s,strlen(s));
 }
 
+static void voutf(const char* fmt,va_list args) __attribute__((format(printf,1,0)));
 void voutf(const char* fmt,va_list args)
 {
     const int BUF_LEN = 0x4000;
@@ -355,6 +356,7 @@ void indentOuts1(int inc, const char* s)
     out(s,strlen(s));
 }
 
+void indentOutf(const char* fmt,...) __attribute__((format(printf,1,2)));
 void indentOutf(const char* fmt, ...)
 {
     indent(gIndent);
@@ -364,6 +366,7 @@ void indentOutf(const char* fmt, ...)
     voutf(fmt,args);
 }
 
+void indentOutf(int inc, const char* fmt,...) __attribute__((format(printf,2,3)));
 void indentOutf(int inc, const char* fmt, ...)
 {
     gIndent += inc;
@@ -374,6 +377,7 @@ void indentOutf(int inc, const char* fmt, ...)
     voutf(fmt,args);
 }
 
+void indentOutf1(int inc, const char* fmt,...) __attribute__((format(printf,2,3)));
 void indentOutf1(int inc, const char* fmt, ...)
 {
     indent(gIndent+inc);