Browse Source

Issue #135 - Add more printf style format checking

Some missed in last round

Signed-off-by: Jake Smith <jake.smith@lexisnexis.com>
Jake Smith 14 years ago
parent
commit
b4c990b79d

+ 3 - 3
deployment/deploy/DeploymentEngine.cpp

@@ -2145,7 +2145,7 @@ bool CInstallFileMap::resolveConflicts(IPropertyTree& processNode, const char* m
                     e->errorMessage(msg);
 
                     m_pDepEngine->getCallback().printStatus(STATUS_WARN, processNode.queryName(), 
-                                                                         processNode.queryProp("@name"), instanceName, msg.str());
+                                                                         processNode.queryProp("@name"), instanceName, "%s", msg.str());
                 }
             }
 
@@ -2163,7 +2163,7 @@ bool CInstallFileMap::resolveConflicts(IPropertyTree& processNode, const char* m
                     e->errorMessage(msg);
                     
                     m_pDepEngine->getCallback().printStatus(STATUS_WARN, processNode.queryName(), 
-                        processNode.queryProp("@name"), instanceName, msg.str());
+                        processNode.queryProp("@name"), instanceName, "%s", msg.str());
                 }
             }
 
@@ -2210,7 +2210,7 @@ bool CInstallFileMap::resolveConflicts(IPropertyTree& processNode, const char* m
 
                     m_pDepEngine->getCallback().printStatus(STATUS_WARN, processNode.queryName(), 
                                                                          processNode.queryProp("@name"), instanceName, 
-                                                                         msg.str());
+                                                                         "%s", msg.str());
                 }
                 break;
             }

+ 1 - 1
deployment/deploy/EspDeploymentEngine.cpp

@@ -120,7 +120,7 @@ int CEspDeploymentEngine::determineInstallFiles(IPropertyTree& node, CInstallFil
       CDeploymentEngine::determineInstallFiles(*pService, installFiles);
    }
     int rc = CDeploymentEngine::determineInstallFiles(node, installFiles);
-    m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, "");
+    m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, "determineInstallFiles complete");
    return rc;
 }
 

+ 5 - 6
deployment/deploy/deploy.cpp

@@ -309,12 +309,11 @@ public:
         if (!valid)
         {
             const char* errors = m_sValidationErrors.str();
-            const char* caption = "Preliminary validation failed!";
             if (!errors || !*errors)
                 errors = "Continue?";
 
-            m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, caption);
-            while ( !m_pCallback->processException(NULL, NULL, NULL, NULL, errors, caption, NULL) )
+            m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, "Preliminary validation failed!");
+            while ( !m_pCallback->processException(NULL, NULL, NULL, NULL, errors, "Preliminary validation failed!", NULL) )
                 ;
             valid = true; //ignore validation errors                
         }
@@ -540,7 +539,7 @@ public:
 
         if (sArray.ordinality() != 4)
         {
-            pCallback->printStatus(STATUS_ERROR, NULL, NULL, NULL, in);
+            pCallback->printStatus(STATUS_ERROR, NULL, NULL, NULL, "%s", in);
             return;
         }
         
@@ -579,7 +578,7 @@ public:
                 compType, 
                 compName, 
                 NULL, 
-                msg);
+                "%s", msg);
         }
         catch (IException* e)
         {
@@ -587,7 +586,7 @@ public:
             e->errorMessage(buf);
             e->Release();
 
-            pCallback->printStatus(STATUS_ERROR, NULL, NULL, NULL, buf.str());
+            pCallback->printStatus(STATUS_ERROR, NULL, NULL, NULL, "%s", buf.str());
         }
         catch(...)
         {

+ 1 - 1
deployment/deploy/espconfiggenengine.cpp

@@ -121,7 +121,7 @@ int CEspConfigGenEngine::determineInstallFiles(IPropertyTree& node, CInstallFile
       CConfigGenEngine::determineInstallFiles(*pService, installFiles);
    }
     int rc = CConfigGenEngine::determineInstallFiles(node, installFiles);
-    m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, "");
+    m_pCallback->printStatus(STATUS_NORMAL, NULL, NULL, NULL, "determineInstallFiles complete");
    return rc;
 }
 

+ 2 - 2
ecl/eclagent/eclagent.cpp

@@ -1016,11 +1016,11 @@ void EclAgent::getExternalResultRaw(unsigned & tlen, void * & tgt, const char *
         StringBuffer text; 
         e->errorMessage(text); 
         e->Release();
-        failv(0, "value %s:%d in workunit %s contains an invalid raw value [%s]", nullText(stepname), sequence, text.str());
+        failv(0, "value %s:%d in workunit %s contains an invalid raw value [%s]", nullText(stepname), sequence, wuid, text.str());
     }
     catch (...)
     {
-        failv(0, "value %s:%d in workunit %s contains an invalid raw value", nullText(stepname), sequence);
+        failv(0, "value %s:%d in workunit %s contains an invalid raw value", nullText(stepname), sequence, wuid);
     }
 }
 

+ 2 - 2
ecl/hql/hqlgram.hpp

@@ -37,8 +37,8 @@
 #define VIRTUAL_FLAG 2
 #define SHARED_FLAG 4
 
-const char REC_FLD_ERR_STR[] = "Need to supply a value for field '%s'";
-const char ERR_WRONGSCOPING_ERR_STR[] = "Value for field '%s' cannot be computed in this scope";
+#define REC_FLD_ERR_STR "Need to supply a value for field '%s'"
+#define ERR_WRONGSCOPING_ERR_STR "Value for field '%s' cannot be computed in this scope"
 
 struct DefineIdSt
 {

+ 4 - 4
ecl/hql/hqlvalid.cpp

@@ -188,12 +188,12 @@ IHqlExpression * checkCreateConcreteModule(IErrorReceiver * errors, IHqlExpressi
         }
     }
 
-    const char * msgText = "Cannot use an abstract MODULE in this context";
     if (fieldText.length())
-        msgText = "Cannot use an abstract MODULE in this context (%s undefined)";
+        reportError(errors, ERR_ABSTRACT_MODULE, errpos, "Cannot use an abstract MODULE in this context (%s undefined)", fieldText.str());
     else if (expr->hasProperty(interfaceAtom))
-        msgText = "Cannot use an abstract MODULE in this context (INTERFACE must be instantiated)";
-    reportError(errors, ERR_ABSTRACT_MODULE, errpos, msgText, fieldText.str());
+        reportError(errors, ERR_ABSTRACT_MODULE, errpos, "Cannot use an abstract MODULE in this context (INTERFACE must be instantiated)");
+    else
+        reportError(errors, ERR_ABSTRACT_MODULE, errpos, "Cannot use an abstract MODULE in this context");
     return LINK(expr);
 }
 

+ 2 - 2
ecl/hqlcpp/hqlcerrors.hpp

@@ -419,12 +419,12 @@
 #define HQLERR_RhsKeyedNotKey_Text              "JOIN%s marked as KEYED does not have a key as the second parameter"
 #define HQLERR_RemoteNoMeaning_Text             "ALLNODES(dataset) only legal in roxie and in thor child queries"
 #define HQLERR_RemoteGrouped_Text               "ALLNODES() is not currently supported on grouped datasets"
-#define HQLERR_LibraryCannotContainWorkflow_Text "Library %s cannot contain any workflow actions (%s)"
+#define HQLERR_LibraryCannotContainWorkflow_Text "Library %s cannot contain any workflow actions%s"
 #define HQLERR_LoopTooComplexForParallel_Text   "LOOP body too complicated to evaluate in parallel"
 #define HQLERR_BadDfaOperator_Text              "Operator %s not supported inside DFAs"
 #define HQLERR_MatchUtf8NotText_Text            "MATCHUTF8 found where MATCHUNICODE/MATCHTEXT was expected"
 #define HQLERR_ThisNodeNotInsideAllNodes_Text   "THISNODE() can only be used inside ALLNODES()"
-#define HQLERR_SteppedNoJoin_Text               "STEPPED() cannot be evaluated in this context"
+#define HQLERR_SteppedNoJoin_Text               "STEPPED(%s) cannot be evaluated in this context"
 #define HQLERR_UnsupportedRowsetRangeParam_Text "Parameter to RANGE() is too complex - not currently supported"
 #define HQLERR_CantProjectStepping_Text         "Project of stepping fields is too complex"
 #define HQLERR_SteppedVariableSize_Text         "Stepped field %s must have a fixed size"

+ 2 - 2
ecl/hqlcpp/hqlcpp.cpp

@@ -11014,7 +11014,7 @@ bool HqlCppTranslator::ensurePushed(BuildCtx & ctx, const CHqlBoundExpr & pure)
                 args.append(*pure.expr.getLink());
                 break;
             case type_enumerated:
-                throwError1(HQLERR_CastXNotImplemented, "map=>decimal");
+                throwError2(HQLERR_CastXNotImplemented, "map", "decimal");
                 break;
             case type_boolean:
                 funcName = DecPushLongAtom;
@@ -11025,7 +11025,7 @@ bool HqlCppTranslator::ensurePushed(BuildCtx & ctx, const CHqlBoundExpr & pure)
                 args.append(*pure.expr.getLink());
                 break;
             default:
-                throwError1(HQLERR_CastXNotImplemented, "unknown=>varstring");
+                throwError2(HQLERR_CastXNotImplemented, "unknown", "varstring");
                 break;
         }
         if (funcName)

+ 3 - 2
ecl/hqlcpp/hqlttcpp.cpp

@@ -5544,9 +5544,10 @@ IHqlExpression * WorkflowTransformer::createTransformed(IHqlExpression * expr)
         if (translator.insideLibrary())
         {
             SCMStringBuffer libraryName;
-            StringBuffer colonText;
+            StringBuffer colonText(" (");
             getOutputLibraryName(libraryName, wu);
             getExprECL(expr, colonText);
+            colonText.append(")");
             throwError2(HQLERR_LibraryCannotContainWorkflow, libraryName.str(), colonText.str());
         }
         transformed.setown(extractWorkflow(expr, transformed));
@@ -11785,7 +11786,7 @@ bool HqlCppTranslator::transformGraphForGeneration(IHqlExpression * query, Workf
     {
         SCMStringBuffer libraryName;
         getOutputLibraryName(libraryName, wu());
-        throwError1(HQLERR_LibraryCannotContainWorkflow, libraryName.str());
+        throwError2(HQLERR_LibraryCannotContainWorkflow, libraryName.str(), "");
     }
 
     {

+ 3 - 5
system/jlib/jlog.cpp

@@ -1259,16 +1259,14 @@ void LogMsgPrepender::report_va(const LogMsgCategory & cat, const LogMsgJobInfo
 
 void LogMsgPrepender::report(const LogMsgCategory & cat, const LogMsgJobInfo & job, const IException * exception, const char * prefix)
 {
-    StringBuffer buff;
-    buff.append(file).append("(").append(line).append(") : %s");
     StringBuffer txt;
     if (prefix) 
         txt.append(prefix).append(" : ");
     exception->errorMessage(txt);
-    if(reporter)
-        reporter->report(cat, job, exception->errorCode(), buff.str(), txt.str());
+    if (reporter)
+        reporter->report(cat, job, exception->errorCode(), "%s(%d) : %s", file, line, txt.str());
     else
-        queryLogMsgManager()->report(cat, job, exception->errorCode(), buff.str(), txt.str());
+        queryLogMsgManager()->report(cat, job, exception->errorCode(), "%s(%d) : %s", file, line, txt.str());
     crit.leave();
 }
 

+ 1 - 1
tools/backupnode/backupnode2.cpp

@@ -273,7 +273,7 @@ public:
                     }
                 }
                 else 
-                    parent.error("cannot create file descriptor",name.str());
+                    parent.error("cannot create file descriptor %s",name.str());
             }
         public: