Ver código fonte

HPCC-13496 Fix compilation Error: 'this' pointer and references cannot be null

- getNamePtr() in IIdAtom and IAtom class renamed to queryStr()
- directly call queryStr() member function  of IIdAtom and IAtom
instead of using str when object known to be non-null
- fix where *str() used when str() should have been fixed
- use lower(id) instead of "id ? id->queryLower() : NULL; "
- Replace tabs with spaces
Shamser Ahmed 10 anos atrás
pai
commit
a6a5b448c4

+ 1 - 1
common/thorhelper/thorrparse.cpp

@@ -2022,7 +2022,7 @@ void RegexNamedPattern::toXMLattr(StringBuffer & out, RegexXmlState & state)
 {
     RegexPattern::toXMLattr(out, state);
     if (def->queryName())
-        out.appendf(" name=\"%s\"", str(def->queryName()));
+        out.appendf(" name=\"%s\"", def->queryName()->queryStr());
     out.appendf(" body=\"%d\"", state.named.find(*def));
 }
 

+ 1 - 1
ecl/hql/hqlatoms.hpp

@@ -448,7 +448,7 @@ extern HQL_API IAtom * xmlnsAtom;
 extern HQL_API IAtom * _xmlParse_Atom;
 extern HQL_API IAtom * xpathAtom;
 
-inline bool isInternalAttributeName(IAtom * name) { return (str(name)[0] == '$'); }
+inline bool isInternalAttributeName(IAtom * name) { return (name->queryStr()[0] == '$'); }
 
 /*
  * This is part of an experiment to make identifiers in the language case sensitive - at least optionally, possibly only for syntax checking.

+ 1 - 1
ecl/hql/hqlerror.cpp

@@ -206,7 +206,7 @@ public:
 
         StringBuffer msg;
         error->errorMessage(msg);
-        if (!filename) filename = isError(severity) ? "" : str(unknownAtom);
+        if (!filename) filename = isError(severity) ? "" : unknownAtom->queryStr();
         fprintf(f, "%s(%d,%d): %s C%04d: %s\n", filename, line, column, severityText, code, msg.str());
     }
 

+ 5 - 5
ecl/hql/hqlexpr.cpp

@@ -7948,10 +7948,10 @@ void CHqlScope::throwRecursiveError(IIdAtom * searchName)
     StringBuffer filename;
     if (fullName)
         filename.append(fullName).append('.');
-    filename.append(*str(searchName));
+    filename.append(str(searchName));
 
     StringBuffer msg("Definition of ");
-    msg.append(*str(searchName)).append(" contains a recursive dependency");
+    msg.append(str(searchName)).append(" contains a recursive dependency");
     throw createError(ERR_RECURSIVE_DEPENDENCY, msg.str(), filename, 0, 0, 1);
 }
 
@@ -8143,13 +8143,13 @@ IHqlExpression *CHqlRemoteScope::lookupSymbol(IIdAtom * searchName, unsigned loo
     StringBuffer filename;
     if (fullName)
         filename.append(fullName).append('.');
-    filename.append(*str(searchName));
+    filename.append(str(searchName));
 
     IFileContents * contents = ret->queryDefinitionText();
     if (!contents || (contents->length() == 0))
     {
         StringBuffer msg("Definition for ");
-        msg.append(*str(searchName)).append(" contains no text");
+        msg.append(str(searchName)).append(" contains no text");
         throw createError(ERR_EXPORT_OR_SHARE, msg.str(), filename, 0, 0, 1);
     }
 
@@ -8175,7 +8175,7 @@ IHqlExpression *CHqlRemoteScope::lookupSymbol(IIdAtom * searchName, unsigned loo
         if (newSymbol)
             resolved->removeSymbol(searchName);
         StringBuffer msg("Definition must contain EXPORT or SHARED value for ");
-        msg.append(*str(searchName));
+        msg.append(str(searchName));
         throw createError(ERR_EXPORT_OR_SHARE, msg.str(), filename, 0, 0, 1);
     }
 

+ 11 - 11
ecl/hql/hqlexpr.ipp

@@ -593,7 +593,7 @@ class HQL_API CHqlSymbolAnnotation : public CHqlAnnotation, public IHqlNamedAnno
 public:
     IMPLEMENT_IINTERFACE_USING(CHqlAnnotation)
 
-    virtual IAtom * queryName() const { return id ? id->queryLower() : NULL; }
+    virtual IAtom * queryName() const { return lower(id); }
     virtual IIdAtom * queryId() const { return id; }
     virtual IIdAtom * queryFullContainerId() const { return moduleId; }
     virtual IHqlExpression *queryFunctionDefinition() const;
@@ -799,7 +799,7 @@ public:
 //  virtual StringBuffer &toSQL(StringBuffer &, bool paren, IHqlDataset *scope, bool useAliases, node_operator op = no_none);
     virtual IHqlExpression *clone(HqlExprArray &newkids);
     virtual StringBuffer &printAliases(StringBuffer &s, unsigned, bool &) { return s; }
-    virtual IAtom * queryName() const { return id ? id->queryLower() : NULL; }
+    virtual IAtom * queryName() const { return lower(id); }
     virtual IIdAtom * queryId() const { return id; }
 };
 
@@ -826,7 +826,7 @@ class CHqlExternal: public CHqlExpressionWithType
     virtual bool equals(const IHqlExpression & other) const;
 public:
     static CHqlExternal *makeExternalReference(IIdAtom * id, ITypeInfo *, HqlExprArray &_ownedOperands);
-    virtual IAtom * queryName() const { return id ? id->queryLower() : NULL;  }
+    virtual IAtom * queryName() const { return lower(id);  }
     virtual IIdAtom * queryId() const { return id; }
 };
 
@@ -952,7 +952,7 @@ typedef HashIterator SymbolTableIterator;
 
 inline IHqlExpression * lookupSymbol(SymbolTable & symbols, IIdAtom * searchName, bool sharedOK)
 {
-    OwnedHqlExpr ret = symbols.getLinkedValue(searchName ? searchName->queryLower() : NULL );
+    OwnedHqlExpr ret = symbols.getLinkedValue(lower(searchName));
 
     if (!ret)
         return NULL; 
@@ -1078,7 +1078,7 @@ public:
 
     virtual IHqlExpression *lookupSymbol(IIdAtom * searchName, unsigned lookupFlags, HqlLookupContext & ctx);
 
-    virtual IAtom * queryName() const {return id ? id->queryLower() : NULL;}
+    virtual IAtom * queryName() const {return lower(id);}
     virtual IIdAtom * queryId() const { return id; }
     virtual const char * queryFullName() const  { return fullName; }
     virtual IIdAtom * queryFullContainerId() const { return containerId; }
@@ -1291,10 +1291,10 @@ public:
     CHqlContextScope(IHqlScope* scope);
 
     virtual void defineSymbol(IIdAtom * id, IIdAtom * moduleName, IHqlExpression *value,bool exported, bool shared, unsigned symbolFlags)
-    {  defined.setValue(id ? id->queryLower() : NULL,value);  }
+    {  defined.setValue(lower(id),value);  }
 
     virtual IHqlExpression *lookupSymbol(IIdAtom * searchName, unsigned lookupFlags, HqlLookupContext & ctx)
-{  return defined.getLinkedValue(searchName ? searchName->queryLower() : NULL ); }
+{  return defined.getLinkedValue(lower(searchName)); }
 
     virtual IHqlScope * queryConcreteScope()    { return this; }
     virtual bool allBasesFullyBound() const { return false; }
@@ -1366,7 +1366,7 @@ public:
     StringBuffer &toString(StringBuffer &ret);
     virtual IHqlExpression *clone(HqlExprArray &newkids);
     virtual IHqlSimpleScope *querySimpleScope();
-    virtual IAtom * queryName() const { return id ? id->queryLower() : NULL;  }
+    virtual IAtom * queryName() const { return lower(id);  }
     virtual IIdAtom * queryId() const { return id; }
     virtual unsigned __int64 querySequenceExtra() { return idx; }
 };
@@ -1630,7 +1630,7 @@ public:
     virtual IHqlExpression *addOperand(IHqlExpression *field);
     virtual IHqlExpression *clone(HqlExprArray &newkids);
     virtual bool equals(const IHqlExpression & other) const;
-virtual IAtom * queryName() const { return unnamedId ? unnamedId->queryLower() : NULL; }
+    virtual IAtom * queryName() const { return lower(unnamedId); }
     virtual void sethash();
     virtual ITypeInfo *queryType() const;
     virtual ITypeInfo *getType();
@@ -1776,7 +1776,7 @@ public:
     virtual IValue * castFrom(double value)  { return NULL; }
     virtual IValue * castFrom(size32_t len, const char * text)  { return NULL; }
     virtual IValue * castFrom(size32_t len, const UChar * text)  { return NULL; }
-    virtual StringBuffer &getECLType(StringBuffer & out)  { return out.append(id ? id->queryLower() : NULL); }
+    virtual StringBuffer &getECLType(StringBuffer & out)  { return out.append(lower(id)); }
     virtual StringBuffer &getDescriptiveType(StringBuffer & out)  { return getECLType(out); }
     virtual const char *queryTypeName()         { return id ? str(id->queryLower()) : NULL ; }
     virtual unsigned getCardinality();
@@ -1788,7 +1788,7 @@ public:
     virtual ICharsetInfo * queryCharset()       { return logical->queryCharset(); }
     virtual ICollationInfo * queryCollation()   { return logical->queryCollation(); }
     virtual IAtom * queryLocale()                 { return logical->queryLocale(); }
-    virtual IAtom * queryName() const { return id ? id->queryLower() : NULL;  }
+    virtual IAtom * queryName() const { return lower(id);  }
     virtual IIdAtom * queryId() const { return id; }
     virtual ITypeInfo * queryChildType() { return logical; }
     virtual ITypeInfo * queryPromotedType()     { return logical->queryPromotedType(); }

+ 1 - 1
ecl/hql/hqlgram.y

@@ -3931,7 +3931,7 @@ attrib
     : knownOrUnknownId EQ UNKNOWN_ID        
                         {
                             parser->reportWarning(CategoryDeprecated, SeverityError, WRN_OBSOLETED_SYNTAX,$1.pos,"Syntax obsoleted; use alternative: id = '<string constant>'");
-                            $$.setExpr(createAttribute(lower($1.getId()), createConstant(*str($3.getId()))));
+                            $$.setExpr(createAttribute(lower($1.getId()), createConstant(str($3.getId()))));
                         }
     | knownOrUnknownId EQ expr %prec reduceAttrib
                         {

+ 2 - 2
esp/platform/sechandler.cpp

@@ -95,8 +95,8 @@ bool SecHandler::authorizeSecFeature(const char * pszFeatureUrl, const char* Use
     if(pSecondaryUser.get()== NULL)
     {
         pSecondaryUser.setown(m_secmgr->createUser(UserID));
-	if (!pSecondaryUser.get())
-	    return false;
+        if (!pSecondaryUser)
+            return false;
         pSecondaryUser->setRealm(CompanyID);
         bool bSecondaryAccessAllowed = m_secmgr->initUser(*pSecondaryUser.get());
         if(bSecondaryAccessAllowed==false)

+ 1 - 1
esp/services/ws_access/ws_accessService.cpp

@@ -727,7 +727,7 @@ bool Cws_accessEx::onAddUser(IEspContext &context, IEspAddUserRequest &req, IEsp
             cred.setPassword(pass1);
         try
         {
-	    if (user.get())
+            if (user.get())
                 secmgr->addUser(*user.get());
         }
         catch(IException* e)

+ 4 - 4
system/jlib/jhash.hpp

@@ -48,9 +48,9 @@ interface jlib_decl IMapping : extends IObservable
 interface jlib_decl IAtom : extends IMapping
 {
  public:
-    virtual const char * getNamePtr() const = 0;
+    virtual const char * queryStr() const = 0;
 };
-inline jlib_decl const char * str(const IAtom * atom) { return atom ? atom->getNamePtr() : NULL; }
+inline jlib_decl const char * str(const IAtom * atom) { return atom ? atom->queryStr() : NULL; }
 
 //This interface represents an atom which preserves its case, but also stores a lower case representation
 //for efficient case insensitive comparison.
@@ -58,11 +58,11 @@ inline jlib_decl const char * str(const IAtom * atom) { return atom ? atom->getN
 interface jlib_decl IIdAtom : extends IMapping
 {
  public:
-    virtual const char * getNamePtr() const = 0;
+    virtual const char * queryStr() const = 0;
  public:
     virtual IAtom * queryLower() const = 0;
 };
-inline jlib_decl const char * str(const IIdAtom * atom) { return atom ? atom->getNamePtr() : NULL; }
+inline jlib_decl const char * str(const IIdAtom * atom) { return atom ? atom->queryStr() : NULL; }
 inline jlib_decl IAtom * lower(const IIdAtom * atom) { return atom ? atom->queryLower() : NULL; }
 
 #ifdef _MSC_VER

+ 2 - 2
system/jlib/jhash.ipp

@@ -79,7 +79,7 @@ public:
     ~AtomBase()               { free(key); }
 
 //interface:IMapping
-    virtual const char *        getNamePtr() const { return key; }
+    virtual const char *        queryStr() const { return key; }
     virtual const void *        getKey() const;
     virtual unsigned            getHash() const;
     virtual void                setHash(unsigned);
@@ -123,7 +123,7 @@ public:
     ~CaseAtom() { free(text); }
 
 //interface:IMapping
-    virtual const char *        getNamePtr() const { return text; }
+    virtual const char *        queryStr() const { return text; }
     virtual const void *        getKey() const { return text; }
     virtual unsigned            getHash() const { return hash; }
     virtual void                setHash(unsigned _hash) { hash = _hash; }

+ 1 - 1
system/jlib/jstring.cpp

@@ -236,7 +236,7 @@ StringBuffer & StringBuffer::append(const char * value, int offset, int len)
 StringBuffer & StringBuffer::append(const IAtom * value)
 {
     if (value)
-        append(value->getNamePtr());
+        append(value->queryStr());
     return *this;
 }