Browse Source

HPCC-11469 Add gcc -Wparentheses

And remove some harmless warnings, mostly to remove potential
confusion over nested if else's.

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

+ 3 - 1
cmake_modules/commonSetup.cmake

@@ -210,7 +210,9 @@ IF ("${COMMONSETUP_DONE}" STREQUAL "")
         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")
         endif ()
-
+        if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.95.3 OR CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 2.95.3)
+          SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wparentheses")
+        endif ()
       endif ()
       if (GENERATE_COVERAGE_INFO)
         message ("Build system with coverage.")

+ 1 - 1
common/remote/hooks/libarchive/archive.cpp

@@ -214,7 +214,7 @@ public:
             throw MakeStringException(0, "Only sequential access to contained file %s supported", fullName.get());
         byte *data = (byte *) _data;
         size32_t lenRequested = len;
-        while (len > 0 & pos < fileSize)
+        while (len > 0 && pos < fileSize)
         {
             if (pos >= curPos+curBuffSize)
             {

+ 2 - 0
common/remote/rmtsmtp.cpp

@@ -268,10 +268,12 @@ private:
             ++finger;
         }
         if(charcount == 0)
+        {
             if(subcount == 0)
                 fail("empty domain");
             else
                 fail("illegal . at end of domain");
+        }
         ++subcount;
         if(subcount < 2)
             fail("domain has only 1 subdomain");

+ 2 - 0
dali/base/dadfs.cpp

@@ -9353,10 +9353,12 @@ public:
                 const char *name = grp.queryProp("@name");
                 bool iscluster = NotFound != clusternames.find(name);
                 if (iscluster!=grp.getPropBool("@cluster"))
+                {
                     if (iscluster)
                         grp.setPropBool("@cluster", true);
                     else
                         grp.removeProp("@cluster");
+                }
             }
         }
     }

+ 2 - 0
dali/base/dasds.cpp

@@ -4656,8 +4656,10 @@ public:
                         Owned<IJlibDateTime> nowTime = createDateTimeNow();
                         nowTime->setGmtDate(1970, 1, 1);
                         if (within24)
+                        {
                             if (!(nowTime->compare(*quietStartTime) >= 0 && nowTime->compare(*quietEndTime) <= 0))
                                 continue; // if outside quiet period within 0-24
+                        }
                         else if (nowTime->compare(*quietEndTime) > 0 && nowTime->compare(*quietStartTime) < 0)
                             continue; // if inside period excluded by quiet period
                     }

+ 2 - 1
dali/daliadmin/daliadmin.cpp

@@ -1167,11 +1167,12 @@ static void checksuperfile(const char *lfn,bool fix=false)
             unsigned pn = sub->getPropInt("@num");
             if (pn>subnum) {
                 ERRLOG("SuperFile %s: corrupt, subfile file part %d spurious",lname.get(),pn);
-                if (fixstate==0)
+                if (fixstate==0) {
                     if (fix&&doFix())
                         fixstate = 1;
                     else
                         fixstate = 2;
+                }
                 if (fixstate==1) {
                     root->removeTree(sub);
                     fixed = true;

+ 2 - 0
dali/sasha/sacmd.cpp

@@ -234,10 +234,12 @@ public:
     void addDT(CDateTime &dt)
     {
         if ((numdts+16)/16!=(numdts+15)/16)
+        {
             if (dts)
                 dts = (CDateTime *)realloc(dts,(numdts+16)*sizeof(CDateTime));
             else
                 dts = (CDateTime *)malloc((numdts+16)*sizeof(CDateTime));
+        }
         memset(dts+numdts,0,sizeof(CDateTime));
         dts[numdts++].set(dt);
     }

+ 4 - 0
esp/services/ws_topology/ws_topologyService.cpp

@@ -1430,24 +1430,28 @@ bool CWsTopologyEx::onTpGetComponentFile(IEspContext &context,
             {
                 const unsigned int len = strlen(compType);
                 if (len>4)
+                {
                     if (!strnicmp(compType, "Roxie", 5))
                         compType = "RoxieCluster", fileName = "RoxieTopology.xml", bCluster = true;
                     else if (!strnicmp(compType, "Thor", 4))
                         compType = "ThorCluster", fileName = "thor.xml", bCluster = true;
                     else if (!strnicmp(compType, "Hole", 4))
                         compType = "HoleCluster", fileName = "edata.ini", bCluster = true;
+                }
             }
         }
         else
         {
             fileName = "";
             if (strlen(compType)>4)
+            {
                 if (!strnicmp(compType, "Roxie", 5))
                     compType = "RoxieCluster", bCluster = true;
                 else if (!strnicmp(compType, "Thor", 4))
                     compType = "ThorCluster", bCluster = true;
                 else if (!strnicmp(compType, "Hole", 4))
                     compType = "HoleCluster", bCluster = true;
+            }
         }
 
         if (!fileName)

+ 2 - 0
esp/smc/SMCLib/TpWrapper.cpp

@@ -1268,12 +1268,14 @@ void CTpWrapper::getClusterProcessList(const char* ClusterType, IArrayOf<IEspTpC
                     unsigned int clusterTypeLen = strlen(ClusterType);
                     const char* childType = NULL;
                     if (clusterTypeLen > 4)
+                    {
                         if (!strnicmp(ClusterType, "roxie", 4))
                             childType = "RoxieServerProcess[1]";
                         else if (!strnicmp(ClusterType, "thor", 4))
                             childType = "ThorMasterProcess";
                         else
                             childType = "HoleControlProcess";
+                    }
                     if (childType)
                     {
                         IPropertyTree* pChild = cluster.queryPropTree(childType);

+ 4 - 0
system/jhtree/keydiff.cpp

@@ -1341,6 +1341,7 @@ public:
         }
         verifyCRCs();
         if(newOutput->queryCount())
+        {
             if(tlkGen)
             {
                 bool wait = tlkGen->addNode(newprev.getNodeInfo(newOutput->queryCount()-1));
@@ -1352,6 +1353,7 @@ public:
                 Owned<CNodeInfo> ni(newprev.getNodeInfo(newOutput->queryCount()-1));
                 tlkSender->send(*ni);
             }
+        }
     }
 
     virtual void getHeaderVersionInfo(unsigned short & versionMajor, unsigned short & versionMinor, unsigned short & minPatchVersionMajor, unsigned short & minPatchVersionMinor)
@@ -1399,10 +1401,12 @@ private:
         if(tlkGen)
         {
             if(!newTLK.get())
+            {
                 if(keydiff.queryHeader().hasTLKInfo())
                     newTLK.set(keydiff.queryHeader().queryNewTLK());
                 else
                     throw MakeStringException(0, "Trying to generate TLK using filename from patch, but patch does not include TLK header information");
+            }
         }
         else if(keydiff.queryHeader().hasTLKInfo() && !ignoreTLK)
             throw MakeStringException(0, "Patch includes TLK header information, but TLK generation not enabled --- aborting, invoke with warning suppressed to go ahead");

+ 40 - 0
system/jlib/jlog.cpp

@@ -126,10 +126,12 @@ StringBuffer & LogMsg::toStringPlain(StringBuffer & out, unsigned fields) const
     if(fields & MSGFIELD_thread)
         out.appendf("tid=%d ",sysInfo.queryThreadID());
     if(fields & MSGFIELD_session)
+    {
         if(sysInfo.querySessionID() == UnknownSession)
             out.append("sid=unknown ");
         else
             out.appendf("sid=%"I64F"u ", sysInfo.querySessionID());
+    }
     if(fields & MSGFIELD_node)
     {
         size32_t len = out.length();
@@ -137,15 +139,19 @@ StringBuffer & LogMsg::toStringPlain(StringBuffer & out, unsigned fields) const
         out.append(" ");
     }
     if(fields & MSGFIELD_job)
+    {
         if(jobInfo.queryJobID() == UnknownJob)
             out.append("job=unknown ");
         else
             out.appendf("job=%"I64F"u ", jobInfo.queryJobID());
+    }
     if(fields & MSGFIELD_user)
+    {
         if(jobInfo.queryUserID() == UnknownUser)
             out.append("usr=unknown ");
         else
             out.appendf("usr=%"I64F"u ", jobInfo.queryUserID());
+    }
     if(fields & MSGFIELD_component)
         out.appendf("cmp=%u ", component);
     if (fields & MSGFIELD_quote)
@@ -206,10 +212,12 @@ StringBuffer & LogMsg::toStringXML(StringBuffer & out, unsigned fields) const
     if(fields & MSGFIELD_thread)
         out.append("TID=\"").append(sysInfo.queryThreadID()).append("\" ");
     if(fields & MSGFIELD_session)
+    {
         if(sysInfo.querySessionID() == UnknownSession)
             out.append("SessionID=\"unknown\" ");
         else
             out.append("SessionID=\"").append(sysInfo.querySessionID()).append("\" ");
+    }
     if(fields & MSGFIELD_node)
     {
         out.append("Node=\"");
@@ -220,15 +228,19 @@ StringBuffer & LogMsg::toStringXML(StringBuffer & out, unsigned fields) const
     if(fields & MSGFIELD_allSysInfo) out.append("\n     ");
 #endif
     if(fields & MSGFIELD_job)
+    {
         if(jobInfo.queryJobID() == UnknownJob)
             out.append("JobID=\"unknown\" ");
         else
             out.append("JobID=\"").append(jobInfo.queryJobID()).append("\" ");
+    }
     if(fields & MSGFIELD_user)
+    {
         if(jobInfo.queryUserID() == UnknownUser)
             out.append("UserID=\"unknown\" ");
         else
             out.append("UserID=\"").append(jobInfo.queryUserID()).append("\" ");
+    }
 #ifdef LOG_MSG_NEWLINE
     if(fields & MSGFIELD_allJobInfo) out.append("\n     ");
 #endif
@@ -280,10 +292,12 @@ StringBuffer & LogMsg::toStringTable(StringBuffer & out, unsigned fields) const
     if(fields & MSGFIELD_thread)
         out.appendf("%5d ",sysInfo.queryThreadID());
     if(fields & MSGFIELD_session)
+    {
         if(sysInfo.querySessionID() == UnknownSession)
             out.append("      unknown        ");
         else
             out.appendf("%20"I64F"u ", sysInfo.querySessionID());
+    }
     if(fields & MSGFIELD_node)
     {
         size32_t len = out.length();
@@ -291,15 +305,19 @@ StringBuffer & LogMsg::toStringTable(StringBuffer & out, unsigned fields) const
         out.appendN(20 + len - out.length(), ' ');
     }
     if(fields & MSGFIELD_job)
+    {
         if(jobInfo.queryJobID() == UnknownJob)
             out.append("unknown ");
         else
             out.appendf("%7"I64F"u ", jobInfo.queryJobID());
+    }
     if(fields & MSGFIELD_user)
+    {
         if(jobInfo.queryUserID() == UnknownUser)
             out.append("unknown ");
         else
             out.appendf("%7"I64F"u ", jobInfo.queryUserID());
+    }
     if(fields & MSGFIELD_component)
         out.appendf("%6u ", component);
     if (fields & MSGFIELD_quote)
@@ -388,10 +406,12 @@ void LogMsg::fprintPlain(FILE * handle, unsigned fields) const
     if(fields & MSGFIELD_thread)
         fprintf(handle, "tid=%d ",sysInfo.queryThreadID());
     if(fields & MSGFIELD_session)
+    {
         if(sysInfo.querySessionID() == UnknownSession)
             fprintf(handle, "sid=unknown ");
         else
             fprintf(handle, "sid=%"I64F"u ", sysInfo.querySessionID());
+    }
     if(fields & MSGFIELD_node)
     {
         StringBuffer buff;
@@ -399,15 +419,19 @@ void LogMsg::fprintPlain(FILE * handle, unsigned fields) const
         fprintf(handle, "%s ", buff.str());
     }
     if(fields & MSGFIELD_job)
+    {
         if(jobInfo.queryJobID() == UnknownJob)
             fprintf(handle, "job=unknown ");
         else
             fprintf(handle, "job=%"I64F"u ", jobInfo.queryJobID());
+    }
     if(fields & MSGFIELD_user)
+    {
         if(jobInfo.queryUserID() == UnknownUser)
             fprintf(handle, "usr=unknown ");
         else
             fprintf(handle, "usr=%"I64F"u ", jobInfo.queryUserID());
+    }
     if(fields & MSGFIELD_component)
         fprintf(handle, "cmp=%u ", component);
     
@@ -463,10 +487,12 @@ void LogMsg::fprintXML(FILE * handle, unsigned fields) const
     if(fields & MSGFIELD_thread)
         fprintf(handle, "TID=\"%d\" ", sysInfo.queryThreadID());
     if(fields & MSGFIELD_session)
+    {
         if(sysInfo.querySessionID() == UnknownSession)
             fprintf(handle, "SessionID=\"unknown\" ");
         else
             fprintf(handle, "SessionID=\"%"I64F"u\" ", sysInfo.querySessionID());
+    }
     if(fields & MSGFIELD_node)
     {
         StringBuffer buff;
@@ -477,15 +503,19 @@ void LogMsg::fprintXML(FILE * handle, unsigned fields) const
     if(fields & MSGFIELD_allSysInfo) fprintf(handle, "\n     ");
 #endif
     if(fields & MSGFIELD_job)
+    {
         if(jobInfo.queryJobID() == UnknownJob)
             fprintf(handle, "JobID=\"unknown\" ");
         else
             fprintf(handle, "JobID=\"%"I64F"u\" ", jobInfo.queryJobID());
+    }
     if(fields & MSGFIELD_user)
+    {
         if(jobInfo.queryUserID() == UnknownUser)
             fprintf(handle, "UserID=\"unknown\" ");
         else
             fprintf(handle, "UserID=\"%"I64F"u\" ", jobInfo.queryUserID());
+    }
     if(fields & MSGFIELD_component)
         fprintf(handle, "Component=\"%6u\" ", component);
 #ifdef LOG_MSG_NEWLINE
@@ -536,10 +566,12 @@ void LogMsg::fprintTable(FILE * handle, unsigned fields) const
     if(fields & MSGFIELD_thread)
         fprintf(handle, "%5d ",sysInfo.queryThreadID());
     if(fields & MSGFIELD_session)
+    {
         if(sysInfo.querySessionID() == UnknownSession)
             fprintf(handle, "       unknown       ");
         else
             fprintf(handle, "%20"I64F"u ", sysInfo.querySessionID());
+    }
     if(fields & MSGFIELD_node)
     {
         StringBuffer buff;
@@ -548,15 +580,19 @@ void LogMsg::fprintTable(FILE * handle, unsigned fields) const
         fprintf(handle, "%s%s", buff.str(), (buff.length()<=20) ? twenty_spaces+buff.length() : "");
     }
     if(fields & MSGFIELD_job)
+    {
         if(jobInfo.queryJobID() == UnknownJob)
             fprintf(handle, "unknown ");
         else
             fprintf(handle, "%7"I64F"u ", jobInfo.queryJobID());
+    }
     if(fields & MSGFIELD_user)
+    {
         if(jobInfo.queryUserID() == UnknownUser)
             fprintf(handle, "unknown ");
         else
             fprintf(handle, "%7"I64F"u ", jobInfo.queryUserID());
+    }
     if(fields & MSGFIELD_component)
         fprintf(handle, "%6u ", component);
     const char * quote = (fields & MSGFIELD_quote) ? "\"" : "";
@@ -1918,10 +1954,12 @@ ILogMsgFilter * queryPassNoneLogMsgFilter()
 ILogMsgFilter * getCategoryLogMsgFilter(unsigned audiences, unsigned classes, LogMsgDetail maxDetail, bool local)
 {
     if((audiences==MSGAUD_all) && (classes==MSGCLS_all) && (maxDetail==TopDetail))
+    {
         if(local)
             return LINK(thePassLocalFilter);
         else
             return LINK(thePassAllFilter);
+    }
     return new CategoryLogMsgFilter(audiences, classes, maxDetail, local);
 }
 
@@ -2073,10 +2111,12 @@ ILogMsgHandler * getLogMsgHandlerFromPTree(IPropertyTree * tree)
     unsigned fields = MSGFIELD_all;
     char const * fstr = tree->queryProp("@fields");
     if(fstr)
+    {
         if(isdigit(fstr[0]))
             fields = atoi(fstr);
         else
             fields = LogMsgFieldsFromAbbrevs(fstr);
+    }
     if(strcmp(type.str(), "stderr")==0)
         return getHandleLogMsgHandler(stderr, fields, tree->hasProp("@writeXML"));
     else if(strcmp(type.str(), "file")==0)

+ 2 - 0
system/jlib/jlog.hpp

@@ -322,10 +322,12 @@ inline unsigned LogMsgFieldsFromAbbrevs(char const * abbrevs)
         if(strlen(abbrevs)<3) break;
         unsigned field = LogMsgFieldFromAbbrev(abbrevs);
         if(field)
+        {
             if(negate)
                 fields &= ~field;
             else
                 fields |= field;
+        }
         switch(abbrevs[3])
         {
         case '+':

+ 2 - 1
system/jlib/jlzw.cpp

@@ -2003,11 +2003,12 @@ public:
             compblkptr = (byte *)compblk.allocate(trailer.blockSize+trailer.recordSize*2+16); // over estimate!
             compblklen = 0;
             if (trailer.recordSize==0) {
-                if (!compressor)
+                if (!compressor) {
                     if (fast)
                         compressor.setown(createFastLZCompressor());
                     else
                         compressor.setown(createLZWCompressor(true));
+                }
                 compressor->open(compblkptr, trailer.blockSize);
             }
         }

+ 4 - 0
system/jlib/jptree.cpp

@@ -165,11 +165,15 @@ public:
     inline void removekey(AttrStr *a,bool nc)
     {
         if (a->linkcount!=(unsigned short)-1)
+        {
             if (--(a->linkcount)==0) 
+            {
                 if (nc)
                     htnc.remove((AttrStrNC *)a);
                 else
                     htc.remove((AttrStrC *)a);
+            }
+        }
     }
 
     inline void removeval(AttrStr *a)

+ 2 - 0
system/jlib/jsocket.cpp

@@ -2649,10 +2649,12 @@ IpAddress & queryLocalIP()
 {
     CriticalBlock c(hostnamesect);
     if (localhostip.isNull()) 
+    {
         if (IP6preferred)
             localhostip.ipset("::1");   //IPv6 
         else
             localhostip.ipset("127.0.0.1"); //IPv4
+    }
     return localhostip;
 }
 

+ 2 - 0
system/jlib/jsort.cpp

@@ -601,10 +601,12 @@ static inline int cmpicindstable(VECTOR a, VECTOR b, const ICompare & compare)
 {
     int ret = compare.docompare(**a,**b);
     if (ret==0) 
+    {
         if (*a>*b)
             ret = 1;
         else if (*a<*b)
             ret = -1;
+    }
     return ret;
 }
 

+ 1 - 1
thorlcr/activities/thdiskbase.cpp

@@ -202,7 +202,7 @@ void CWriteMasterBase::preStart(size32_t parentExtractSz, const byte *parentExtr
             Owned<IDistributedFile> file = queryThorFileManager().lookup(container.queryJob(), fname, false, true);
             if (file)
             {
-                if (0 == (TDWextend+TDWoverwrite & diskHelperBase->getFlags()))
+                if (0 == ((TDWextend+TDWoverwrite) & diskHelperBase->getFlags()))
                     throw MakeActivityException(this, TE_OverwriteNotSpecified, "Cannot write %s, file already exists (missing OVERWRITE attribute?)", file->queryLogicalName());
                 checkSuperFileOwnership(*file);
             }

+ 2 - 1
tools/hidl/hidlcomp.cpp

@@ -2097,7 +2097,7 @@ void ProcInfo::out_clarion_method()
 
 void ProcInfo::out_method(const char *classpfx, int omitvirt)
 {
-    if (virt&&!omitvirt)
+    if (virt&&!omitvirt) {
         if (callback) 
             outf("HRPCvirtualcallback ");
         else {
@@ -2126,6 +2126,7 @@ void ProcInfo::out_method(const char *classpfx, int omitvirt)
             else
                 outf(" HRPCpure%s",callback?"callback":"");
         }
+    }
 }
 
 void ProcInfo::out_parameter_list(const char *pfx,int forclarion)