Bugfix: fixed the compiler can assume that the address of ‘t’ will never be NULL warning [-Waddress]

This commit is contained in:
Danial Khazaei 2019-01-31 17:33:45 +03:30
parent 9c81a37a62
commit 0803bdbe20
No known key found for this signature in database
GPG key ID: 0EF86F9BFB18F88C
4 changed files with 22 additions and 15 deletions

View file

@ -962,11 +962,12 @@ void Foam::ensightMesh::writeAllFacePrims
{ {
if (nPrims) if (nPrims)
{ {
const labelList* pPrims = &prims;
if (Pstream::master()) if (Pstream::master())
{ {
ensightGeometryFile << key << nl << setw(10) << nPrims << nl; ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
if (&prims != nullptr) if (pPrims != nullptr)
{ {
writeFacePrims writeFacePrims
( (
@ -993,7 +994,7 @@ void Foam::ensightMesh::writeAllFacePrims
} }
} }
} }
else if (&prims != nullptr) else if (pPrims != nullptr)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< ensMap(patchFaces, prims); toMaster<< ensMap(patchFaces, prims);
@ -1050,10 +1051,11 @@ void Foam::ensightMesh::writeAllNSided
<< "nsided" << nl << setw(10) << nPrims << nl; << "nsided" << nl << setw(10) << nPrims << nl;
} }
const labelList* pPrims = &prims;
// Number of points for each face // Number of points for each face
if (Pstream::master()) if (Pstream::master())
{ {
if (&prims != nullptr) if (pPrims != nullptr)
{ {
writeNSidedNPointsPerFace writeNSidedNPointsPerFace
( (
@ -1078,7 +1080,7 @@ void Foam::ensightMesh::writeAllNSided
} }
} }
} }
else if (&prims != nullptr) else if (pPrims != nullptr)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< ensMap(patchFaces, prims); toMaster<< ensMap(patchFaces, prims);
@ -1087,7 +1089,7 @@ void Foam::ensightMesh::writeAllNSided
// List of points id for each face // List of points id for each face
if (Pstream::master()) if (Pstream::master())
{ {
if (&prims != nullptr) if (pPrims != nullptr)
{ {
writeNSidedPoints writeNSidedPoints
( (
@ -1114,7 +1116,7 @@ void Foam::ensightMesh::writeAllNSided
} }
} }
} }
else if (&prims != nullptr) else if (pPrims != nullptr)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< ensMap(patchFaces, prims); toMaster<< ensMap(patchFaces, prims);
@ -1174,10 +1176,11 @@ void Foam::ensightMesh::writeAllNSidedBinary
writeEnsDataBinary(nPrims,ensightGeometryFile); writeEnsDataBinary(nPrims,ensightGeometryFile);
} }
const labelList* pPrims = &prims;
// Number of points for each face // Number of points for each face
if (Pstream::master()) if (Pstream::master())
{ {
if (&prims != nullptr) if (pPrims != nullptr)
{ {
writeNSidedNPointsPerFaceBinary writeNSidedNPointsPerFaceBinary
( (
@ -1202,7 +1205,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
} }
} }
} }
else if (&prims != nullptr) else if (pPrims != nullptr)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< ensMap(patchFaces, prims); toMaster<< ensMap(patchFaces, prims);
@ -1211,7 +1214,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
// List of points id for each face // List of points id for each face
if (Pstream::master()) if (Pstream::master())
{ {
if (&prims != nullptr) if (pPrims != nullptr)
{ {
writeNSidedPointsBinary writeNSidedPointsBinary
( (
@ -1238,7 +1241,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
} }
} }
} }
else if (&prims != nullptr) else if (pPrims != nullptr)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< ensMap(patchFaces, prims); toMaster<< ensMap(patchFaces, prims);
@ -1260,12 +1263,13 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
{ {
if (nPrims) if (nPrims)
{ {
const labelList* pPrims = &prims;
if (Pstream::master()) if (Pstream::master())
{ {
writeEnsDataBinary(key,ensightGeometryFile); writeEnsDataBinary(key,ensightGeometryFile);
writeEnsDataBinary(nPrims,ensightGeometryFile); writeEnsDataBinary(nPrims,ensightGeometryFile);
if (&prims != nullptr) if (pPrims != nullptr)
{ {
writeFacePrimsBinary writeFacePrimsBinary
( (
@ -1292,7 +1296,7 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
} }
} }
} }
else if (&prims != nullptr) else if (pPrims != nullptr)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< ensMap(patchFaces, prims); toMaster<< ensMap(patchFaces, prims);

View file

@ -65,7 +65,8 @@ void Foam::ensightPartCells::classify(const labelList& idList)
size_ = mesh.nCells(); size_ = mesh.nCells();
bool limited = false; bool limited = false;
if (&idList) const labelList* pIdList = &idList;
if (pIdList)
{ {
limited = true; limited = true;
size_ = idList.size(); size_ = idList.size();

View file

@ -133,7 +133,8 @@ inline bool isType(const Type& t)
template<class TestType, class Type> template<class TestType, class Type>
inline bool isA(const Type& t) inline bool isA(const Type& t)
{ {
return dynamic_cast<const TestType*>(&t); const Type* p = &t;
return dynamic_cast<const TestType*>(p);
} }

View file

@ -154,7 +154,8 @@ void Foam::sampledPatch::remapFaces
) )
{ {
// recalculate the cells cut // recalculate the cells cut
if (&faceMap && faceMap.size()) const UList<label>* pFaceMap = &faceMap;
if (pFaceMap && faceMap.size())
{ {
MeshStorage::remapFaces(faceMap); MeshStorage::remapFaces(faceMap);
} }