[warning-fix][Wparentheses]: warnings regarding parentheses and braces

Fix warnings such as
-- warning: suggest explicit braces to avoid ambiguous ‘else’
-- suggest parentheses around assignment used as truth value
-- warning: suggest parentheses around ‘&&’ within ‘||’
This commit is contained in:
Mark Pictor
2011-08-03 20:32:21 -04:00
parent 4a6179613d
commit f678f0bc83
9 changed files with 33 additions and 31 deletions
+3 -3
View File
@@ -514,7 +514,7 @@ STEPfile::HeaderMergeInstances(InstMgr* im)
//checking for _headerInstances::FILE_NAME
idnum = HeaderId("File_Name");
if(se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)))
if( (se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum))) )
{
from = im->GetApplication_instance(im->FindFileId(idnum));
@@ -534,7 +534,7 @@ STEPfile::HeaderMergeInstances(InstMgr* im)
//checking for _headerInstances::FILE_DESCRIPTION
idnum = HeaderId("File_Description");
if(se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)))
if( (se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum))) )
{
from = im->GetApplication_instance(im->FindFileId(idnum));
@@ -549,7 +549,7 @@ STEPfile::HeaderMergeInstances(InstMgr* im)
//checking for _headerInstances::FILE_SCHEMA
idnum = HeaderId("File_Schema");
if(se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum)))
if( (se = _headerInstances->GetApplication_instance(_headerInstances->FindFileId(idnum))) )
{
from = im->GetApplication_instance(im->FindFileId(idnum));
+6 -6
View File
@@ -240,12 +240,12 @@ MgrNode *InstMgr::Append(SCLP23(Application_instance) *se, stateEnum listState)
if (se->StepFileId () == 0) // no id assigned
se->StepFileId( NextFileId () ); // assign a file id
if (mn = FindFileId (se->StepFileId())) // if id already in list
// and it's because instance is already in list
if (GetApplication_instance (mn) == se)
return 0; // return 0 or mn?
else se->StepFileId( NextFileId () ); // otherwise assign a new file id
if( (mn = FindFileId (se->StepFileId())) ) {// if id already in list
// and it's because instance is already in list
if (GetApplication_instance (mn) == se)
return 0; // return 0 or mn?
else se->StepFileId( NextFileId () ); // otherwise assign a new file id
}
// update the maxFileId if needed
if (se->StepFileId() > MaxFileId()) maxFileId = se->StepFileId();
+9 -10
View File
@@ -1236,14 +1236,13 @@ EntityDescriptor::QualifiedName(SCLstring &s) const
int count = 1;
const EntityDescriptor * ed = 0;
while(ed = edi.NextEntityDesc())
while( (ed = edi.NextEntityDesc()) )
{
if(count > 1)
{
s.Append("&");
}
s.Append(ed->Name());
count++;
if(count > 1) {
s.Append("&");
}
s.Append(ed->Name());
count++;
}
if(count > 1) s.Append("&");
s.Append(Name());
@@ -2074,7 +2073,7 @@ SelectTypeDescriptor::CanBe (const TypeDescriptor * other) const
const TypeDescriptor * td =0;
if (this == other) return other;
while (td = elements.NextTypeDesc ()) {
while( (td = elements.NextTypeDesc ()) ) {
// if (found = (td -> CanBe (other))) return found;
if (td -> CanBe (other)) return td;
}
@@ -2096,7 +2095,7 @@ SelectTypeDescriptor::CanBe (const char * other) const
return this;
// see if other is one of the elements
while (td = elements.NextTypeDesc ()) {
while( (td = elements.NextTypeDesc ()) ) {
if (td -> CanBe (other)) return td;
// if (found = (td -> CanBe (other))) return found;
}
@@ -2127,7 +2126,7 @@ SelectTypeDescriptor::CanBeSet (const char * other, const char *schNm) const
TypeDescItr elements (GetElements()) ;
const TypeDescriptor * td =0;
while (td = elements.NextTypeDesc ()) {
while( (td = elements.NextTypeDesc ()) ) {
if ( td->Type() == REFERENCE_TYPE && td->NonRefType() == sdaiSELECT ) {
// Just look at this level, don't look at my items (see intro).
if ( td->CurrName( other, schNm ) ) {
+1 -2
View File
@@ -254,8 +254,7 @@ uniqueNames( const char *entnm, const SchRename *altlist )
const SchRename *alt = altlist;
while ( alt ) {
if ( !( alt->next
&& alt->next->choice( alt->objName() )
if ( !( ( alt->next && alt->next->choice( alt->objName() ) )
|| !StrCmpIns( alt->objName(), entnm ) ) ) {
// alt has a unique alternate name if it's not reused by a later
// alt. alt->next->choice() returns 1 if one of the later alts
+6 -4
View File
@@ -260,8 +260,9 @@ STEPaggregate::asStr(SCLstring & s) const
while (n)
{
s.Append( n->STEPwrite(tmp) );
if (n = (STEPnode *) n -> NextNode ())
s.Append(',');
if ( (n = (STEPnode *) n -> NextNode ()) ) {
s.Append(',');
}
}
s.Append(')');
}
@@ -279,8 +280,9 @@ STEPaggregate::STEPwrite(ostream& out, const char *currSch) const
while (n)
{
out << n->STEPwrite (s, currSch);
if ( n = (STEPnode *)(n -> NextNode ()) )
out << ',';
if ( ( n = (STEPnode *)(n -> NextNode ()) ) ) {
out << ',';
}
}
out << ')';
}
+2 -1
View File
@@ -49,8 +49,9 @@ SCLP23(Application_instance)::~SCLP23_NAME(Application_instance) ()
{
STEPattribute * next =0;
ResetAttributes ();
while (next = NextAttribute ())
while ( (next = NextAttribute ()) ) {
delete next;
}
if(MultipleInheritance())
{
+1 -1
View File
@@ -1137,7 +1137,7 @@ generic_type : TOK_GENERIC
TypeBody g = TYPEBODYcreate(generic_);
$$ = TYPEcreate_from_body_anonymously(g);
SCOPEadd_super($$);
if (g->tag = TYPEcreate_user_defined_tag($$,CURRENT_SCOPE,$3))
if ( (g->tag = TYPEcreate_user_defined_tag($$,CURRENT_SCOPE,$3)) )
SCOPEadd_super(g->tag);
}
;
+2 -1
View File
@@ -439,8 +439,9 @@ HASHexpand_table(Hash_Table table)
NewAddress = table->maxp + table->p;
NewSegmentDir = DIV(NewAddress, SEGMENT_SIZE_SHIFT);
NewSegmentIndex = MOD(NewAddress, SEGMENT_SIZE);
if (NewSegmentIndex == 0)
if (NewSegmentIndex == 0) {
CALLOC(table->Directory[NewSegmentDir], SEGMENT_SIZE, Element);
}
/* "segment in HASHexpand_table");*/
NewSegment = table->Directory[NewSegmentDir];
/*
+3 -3
View File
@@ -535,7 +535,7 @@ TYPEget_express_type (const Type t)
/* case TYPE_ENTITY: */
/* case TYPE_SELECT: */
if (n = TYPEget_name (t)) {
if ( (n = TYPEget_name (t)) ) {
PrettyTmpName (n);
}
@@ -2301,8 +2301,8 @@ DataMemberPrint(Entity entity, FILE* file,Schema schema)
if (VARget_optional (a)) fprintf (file, " // OPTIONAL");
if (isAggregate (a)) {
/* if it's a named type, comment the type */
if (etype = TYPEget_name
(TYPEget_nonaggregate_base_type (VARget_type (a))))
if ( (etype = TYPEget_name
(TYPEget_nonaggregate_base_type (VARget_type (a)))) )
fprintf (file, "\t // of %s\n", etype);
}