Skip to content
Snippets Groups Projects
Commit f18ecffd authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

coverity

parent 6cec5fcb
Branches
Tags
No related merge requests found
...@@ -330,9 +330,9 @@ class GmshServer : public GmshSocket{ ...@@ -330,9 +330,9 @@ class GmshServer : public GmshSocket{
virtual int NonBlockingWait(double waitint, double timeout, int socket=-1) = 0; virtual int NonBlockingWait(double waitint, double timeout, int socket=-1) = 0;
// start the client by launching "exe args" (args is supposed to contain // start the client by launching "exe args" (args is supposed to contain
// '%s' where the socket name should appear) // '%s' where the socket name should appear)
int Start(const char *exe, const char *args, const char *sockname, double timeout) int Start(const std::string &exe, const std::string &args, const std::string &sockname,
double timeout)
{ {
if(!sockname) throw "Invalid (null) socket name";
_sockname = sockname; _sockname = sockname;
int tmpsock; int tmpsock;
if(strstr(_sockname.c_str(), "/") || strstr(_sockname.c_str(), "\\") || if(strstr(_sockname.c_str(), "/") || strstr(_sockname.c_str(), "\\") ||
...@@ -395,9 +395,9 @@ class GmshServer : public GmshSocket{ ...@@ -395,9 +395,9 @@ class GmshServer : public GmshSocket{
} }
} }
if((exe && strlen(exe)) || (args && strlen(args))){ if(exe.size() || args.size()){
char s[1024]; char s[1024];
sprintf(s, args, _sockname.c_str()); sprintf(s, args.c_str(), _sockname.c_str());
NonBlockingSystemCall(exe, s); // starts the solver NonBlockingSystemCall(exe, s); // starts the solver
} }
else{ else{
......
...@@ -132,8 +132,7 @@ class onelabGmshServer : public GmshServer{ ...@@ -132,8 +132,7 @@ class onelabGmshServer : public GmshServer{
int sock; int sock;
try{ try{
sock = Start(exe.c_str(), args.c_str(), sockname.c_str(), sock = Start(exe, args, sockname, CTX::instance()->solver.timeout);
CTX::instance()->solver.timeout);
} }
catch(const char *err){ catch(const char *err){
Msg::Error("Abnormal server termination (%s on socket %s)", err, Msg::Error("Abnormal server termination (%s on socket %s)", err,
......
...@@ -180,7 +180,7 @@ int GModel::readMSH(const std::string &name) ...@@ -180,7 +180,7 @@ int GModel::readMSH(const std::string &name)
// $Nodes section // $Nodes section
else if(!strncmp(&str[1], "Nodes", 5)) { else if(!strncmp(&str[1], "Nodes", 5)) {
if(!fgets(str, sizeof(str), fp)){ return 0; fclose(fp); } if(!fgets(str, sizeof(str), fp)){ fclose(fp); return 0; }
int numVertices; int numVertices;
if(sscanf(str, "%d", &numVertices) != 1){ fclose(fp); return 0; } if(sscanf(str, "%d", &numVertices) != 1){ fclose(fp); return 0; }
Msg::Info("%d vertices", numVertices); Msg::Info("%d vertices", numVertices);
......
...@@ -42,32 +42,8 @@ SOrientedBoundingRectangle::~SOrientedBoundingRectangle() ...@@ -42,32 +42,8 @@ SOrientedBoundingRectangle::~SOrientedBoundingRectangle()
delete axisY; delete axisY;
} }
SOrientedBoundingBox::SOrientedBoundingBox() void SOrientedBoundingBox::fillp()
{ {
center = SVector3();
size = SVector3();
axisX = SVector3();
axisY = SVector3();
axisZ = SVector3();
}
SOrientedBoundingBox::SOrientedBoundingBox(SVector3 &center_,
double sizeX,
double sizeY,
double sizeZ,
const SVector3 &axisX_,
const SVector3 &axisY_,
const SVector3 &axisZ_)
{
center = center_;
size = SVector3(sizeX, sizeY, sizeZ);
axisX = axisX_;
axisX.normalize();
axisY = axisY_;
axisY.normalize();
axisZ = axisZ_;
axisZ.normalize();
double dx = 0.5 * size[0]; double dx = 0.5 * size[0];
double dy = 0.5 * size[1]; double dy = 0.5 * size[1];
double dz = 0.5 * size[2]; double dz = 0.5 * size[2];
...@@ -105,6 +81,35 @@ SOrientedBoundingBox::SOrientedBoundingBox(SVector3 &center_, ...@@ -105,6 +81,35 @@ SOrientedBoundingBox::SOrientedBoundingBox(SVector3 &center_,
p8z = center[2] + (axisX[2]*dx) + (axisY[2]*dy) + (axisZ[2]*dz); p8z = center[2] + (axisX[2]*dx) + (axisY[2]*dy) + (axisZ[2]*dz);
} }
SOrientedBoundingBox::SOrientedBoundingBox()
{
center = SVector3();
size = SVector3();
axisX = SVector3();
axisY = SVector3();
axisZ = SVector3();
fillp();
}
SOrientedBoundingBox::SOrientedBoundingBox(SVector3 &center_,
double sizeX,
double sizeY,
double sizeZ,
const SVector3 &axisX_,
const SVector3 &axisY_,
const SVector3 &axisZ_)
{
center = center_;
size = SVector3(sizeX, sizeY, sizeZ);
axisX = axisX_;
axisX.normalize();
axisY = axisY_;
axisY.normalize();
axisZ = axisZ_;
axisZ.normalize();
fillp();
}
SOrientedBoundingBox::SOrientedBoundingBox(SOrientedBoundingBox* other) SOrientedBoundingBox::SOrientedBoundingBox(SOrientedBoundingBox* other)
{ {
size = other->getSize(); size = other->getSize();
...@@ -112,43 +117,7 @@ SOrientedBoundingBox::SOrientedBoundingBox(SOrientedBoundingBox* other) ...@@ -112,43 +117,7 @@ SOrientedBoundingBox::SOrientedBoundingBox(SOrientedBoundingBox* other)
axisY = other->getAxis(1); axisY = other->getAxis(1);
axisZ = other->getAxis(2); axisZ = other->getAxis(2);
center = other->getCenter(); center = other->getCenter();
fillp();
double dx = 0.5*size[0];
double dy = 0.5*size[1];
double dz = 0.5*size[2];
p1x = center[0] - (axisX[0]*dx) - (axisY[0]*dy) - (axisZ[0]*dz);
p1y = center[1] - (axisX[1]*dx) - (axisY[1]*dy) - (axisZ[1]*dz);
p1z = center[2] - (axisX[2]*dx) - (axisY[2]*dy) - (axisZ[2]*dz);
p2x = center[0] + (axisX[0]*dx) - (axisY[0]*dy) - (axisZ[0]*dz);
p2y = center[1] + (axisX[1]*dx) - (axisY[1]*dy) - (axisZ[1]*dz);
p2z = center[2] + (axisX[2]*dx) - (axisY[2]*dy) - (axisZ[2]*dz);
p3x = center[0] - (axisX[0]*dx) + (axisY[0]*dy) - (axisZ[0]*dz);
p3y = center[1] - (axisX[1]*dx) + (axisY[1]*dy) - (axisZ[1]*dz);
p3z = center[2] - (axisX[2]*dx) + (axisY[2]*dy) - (axisZ[2]*dz);
p4x = center[0] + (axisX[0]*dx) + (axisY[0]*dy) - (axisZ[0]*dz);
p4y = center[1] + (axisX[1]*dx) + (axisY[1]*dy) - (axisZ[1]*dz);
p4z = center[2] + (axisX[2]*dx) + (axisY[2]*dy) - (axisZ[2]*dz);
p5x = center[0] - (axisX[0]*dx) - (axisY[0]*dy) + (axisZ[0]*dz);
p5y = center[1] - (axisX[1]*dx) - (axisY[1]*dy) + (axisZ[1]*dz);
p5z = center[2] - (axisX[2]*dx) - (axisY[2]*dy) + (axisZ[2]*dz);
p6x = center[0] + (axisX[0]*dx) - (axisY[0]*dy) + (axisZ[0]*dz);
p6y = center[1] + (axisX[1]*dx) - (axisY[1]*dy) + (axisZ[1]*dz);
p6z = center[2] + (axisX[2]*dx) - (axisY[2]*dy) + (axisZ[2]*dz);
p7x = center[0] - (axisX[0]*dx) + (axisY[0]*dy) + (axisZ[0]*dz);
p7y = center[1] - (axisX[1]*dx) + (axisY[1]*dy) + (axisZ[1]*dz);
p7z = center[2] - (axisX[2]*dx) + (axisY[2]*dy) + (axisZ[2]*dz);
p8x = center[0] + (axisX[0]*dx) + (axisY[0]*dy) + (axisZ[0]*dz);
p8y = center[1] + (axisX[1]*dx) + (axisY[1]*dy) + (axisZ[1]*dz);
p8z = center[2] + (axisX[2]*dx) + (axisY[2]*dy) + (axisZ[2]*dz);
} }
double SOrientedBoundingBox::getMaxSize() double SOrientedBoundingBox::getMaxSize()
......
...@@ -34,6 +34,7 @@ class SOrientedBoundingBox { ...@@ -34,6 +34,7 @@ class SOrientedBoundingBox {
SVector3 axisX; SVector3 axisX;
SVector3 axisY; SVector3 axisY;
SVector3 axisZ; SVector3 axisZ;
void fillp();
public: public:
double p1x, p1y, p1z; double p1x, p1y, p1z;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment