Fixed cppcheck warnings.

This commit is contained in:
Mathew Sutcliffe
2014-11-16 23:05:38 +00:00
parent 2cda546ceb
commit 4f342fade6
10 changed files with 29 additions and 24 deletions

View File

@@ -35,21 +35,21 @@ void loadjobthread::execute()
{ {
case MSG_LOADJOB_OBJ: case MSG_LOADJOB_OBJ:
{ {
CSLPlane_t* toload = ((loadjob*)msg)->toload; CSLPlane_t* toload = static_cast<loadjob*>(msg)->toload;
toload->obj_idx = OBJ_LoadModel(toload->file_path.c_str()); toload->obj_idx = OBJ_LoadModel(toload->file_path.c_str());
} }
break; break;
case MSG_LOADJOB_TEX: case MSG_LOADJOB_TEX:
{ {
CSLPlane_t* toload = ((loadjob*)msg)->toload; CSLPlane_t* toload = static_cast<loadjob*>(msg)->toload;
toload->texID = OBJ_LoadTexture(toload->tex_path.c_str(), false); toload->texID = OBJ_LoadTexture(toload->tex_path.c_str(), false);
} }
break; break;
case MSG_LOADJOB_TEX_LIT: case MSG_LOADJOB_TEX_LIT:
{ {
CSLPlane_t* toload = ((loadjob*)msg)->toload; CSLPlane_t* toload = static_cast<loadjob*>(msg)->toload;
toload->texLitID = OBJ_LoadTexture(toload->texLit_path.c_str(), false); toload->texLitID = OBJ_LoadTexture(toload->texLit_path.c_str(), false);
} }
break; break;

View File

@@ -34,6 +34,8 @@ protected:
public: public:
CSLLoaderType() { jq=new pt::jobqueue(); } CSLLoaderType() { jq=new pt::jobqueue(); }
~CSLLoaderType() {} ~CSLLoaderType() {}
CSLLoaderType(const CSLLoaderType &) = delete;
CSLLoaderType &operator =(const CSLLoaderType &) = delete;
void startthreads(); void startthreads();
void load(CSLPlane_t* toload); void load(CSLPlane_t* toload);
void loadTex(CSLPlane_t* toload); void loadTex(CSLPlane_t* toload);

View File

@@ -54,7 +54,6 @@ static void HalfBitmap(ImageInfo& ioImage)
ioImage.height /= 2; ioImage.height /= 2;
ioImage.width /= 2; ioImage.width /= 2;
int yr = ioImage.height; int yr = ioImage.height;
int t1, t2, t3, t4;
if (ioImage.channels == 3) if (ioImage.channels == 3)
{ {
@@ -63,9 +62,9 @@ static void HalfBitmap(ImageInfo& ioImage)
int xr = ioImage.width; int xr = ioImage.width;
while (xr--) while (xr--)
{ {
t1 = *srcp1++; int t1 = *srcp1++;
t2 = *srcp1++; int t2 = *srcp1++;
t3 = *srcp1++; int t3 = *srcp1++;
t1 += *srcp1++; t1 += *srcp1++;
t2 += *srcp1++; t2 += *srcp1++;
@@ -100,10 +99,10 @@ static void HalfBitmap(ImageInfo& ioImage)
int xr = ioImage.width; int xr = ioImage.width;
while (xr--) while (xr--)
{ {
t1 = *srcp1++; int t1 = *srcp1++;
t2 = *srcp1++; int t2 = *srcp1++;
t3 = *srcp1++; int t3 = *srcp1++;
t4 = *srcp1++; int t4 = *srcp1++;
t1 += *srcp1++; t1 += *srcp1++;
t2 += *srcp1++; t2 += *srcp1++;
@@ -145,7 +144,6 @@ bool LoadTextureFromFile(const char * inFileName, int inTexNum, bool magentaAlph
{ {
bool ok = false; bool ok = false;
struct ImageInfo im; struct ImageInfo im;
long count = 0;
#if 1 #if 1
unsigned char * p; unsigned char * p;
#endif #endif
@@ -168,7 +166,7 @@ bool LoadTextureFromFile(const char * inFileName, int inTexNum, bool magentaAlph
{ {
#if 1 #if 1
p = im.data; p = im.data;
count = im.width * im.height; long count = im.width * im.height;
while (count--) while (count--)
{ {
std::swap(p[0], p[2]); std::swap(p[0], p[2]);
@@ -185,7 +183,7 @@ bool LoadTextureFromFile(const char * inFileName, int inTexNum, bool magentaAlph
} else { } else {
#if 1 #if 1
p = im.data; p = im.data;
count = im.width * im.height; long count = im.width * im.height;
while (count--) while (count--)
{ {
std::swap(p[0], p[2]); std::swap(p[0], p[2]);

View File

@@ -42,7 +42,7 @@
bool XObjRead(const char * inFile, XObj& outObj) bool XObjRead(const char * inFile, XObj& outObj)
{ {
vector<string> tokens; vector<string> tokens;
string ascii, vers, tag, line; string /*ascii,*/ vers, /*tag,*/ line;
int cmd_id, count, obj2_op; int cmd_id, count, obj2_op;
int version = 1; int version = 1;
vec_tex vst; vec_tex vst;
@@ -65,7 +65,7 @@ bool XObjRead(const char * inFile, XObj& outObj)
line = f.get(); line = f.get();
BreakString(line, tokens); BreakString(line, tokens);
if (tokens.empty()) return false; if (tokens.empty()) return false;
ascii = tokens[0]; //ascii = tokens[0];
f.next(); f.next();
if (f.done()) return false; if (f.done()) return false;
@@ -89,7 +89,7 @@ bool XObjRead(const char * inFile, XObj& outObj)
line = f.get(); line = f.get();
BreakString(line, tokens); BreakString(line, tokens);
if (tokens.empty()) return false; if (tokens.empty()) return false;
tag = tokens[0]; //tag = tokens[0];
f.next(); f.next();
if (f.done()) return false; if (f.done()) return false;
} }

View File

@@ -470,7 +470,7 @@ int XPMPGetPlaneData(
XPMPPlanePtr XPMPPlaneIsValid(XPMPPlaneID inID, XPMPPlaneVector::iterator * outIter) XPMPPlanePtr XPMPPlaneIsValid(XPMPPlaneID inID, XPMPPlaneVector::iterator * outIter)
{ {
XPMPPlanePtr ptr = (XPMPPlanePtr) inID; XPMPPlanePtr ptr = static_cast<XPMPPlanePtr>(inID);
XPMPPlaneVector::iterator iter = std::find(gPlanes.begin(), gPlanes.end(), ptr); XPMPPlaneVector::iterator iter = std::find(gPlanes.begin(), gPlanes.end(), ptr);
if (iter == gPlanes.end()) if (iter == gPlanes.end())
return NULL; return NULL;

View File

@@ -296,7 +296,6 @@ bool LoadOnePackage(const string& inPath, int pass)
FILE * fi = fopen(path.c_str(), "r"); FILE * fi = fopen(path.c_str(), "r");
XPLMGetVersions(&sim, &xplm, &host); XPLMGetVersions(&sim, &xplm, &host);
int lineNum = 0;
if (fi != NULL) if (fi != NULL)
{ {
@@ -320,6 +319,7 @@ bool LoadOnePackage(const string& inPath, int pass)
// tokens.push_back(""); // tokens.push_back("");
// Go through the file and handle each token. // Go through the file and handle each token.
int lineNum = 0;
while(!feof(fi)) while(!feof(fi))
{ {
if (!fgets_multiplatform(line, sizeof(line), fi)) if (!fgets_multiplatform(line, sizeof(line), fi))

View File

@@ -700,7 +700,6 @@ void OBJ_DrawLights(int model, float inDistance, double inX, double inY,
return; return;
GLfloat size; GLfloat size;
double distance;
// Where are we looking? // Where are we looking?
XPLMCameraPosition_t cameraPos; XPLMCameraPosition_t cameraPos;
XPLMReadCameraPosition(&cameraPos); XPLMReadCameraPosition(&cameraPos);
@@ -734,7 +733,7 @@ void OBJ_DrawLights(int model, float inDistance, double inX, double inY,
float dx = cameraPos.x - static_cast<float>(inX); float dx = cameraPos.x - static_cast<float>(inX);
float dy = cameraPos.y - static_cast<float>(inY); float dy = cameraPos.y - static_cast<float>(inY);
float dz = cameraPos.z - static_cast<float>(inZ); float dz = cameraPos.z - static_cast<float>(inZ);
distance = sqrt((dx * dx) + (dy * dy) + (dz * dz)); double distance = sqrt((dx * dx) + (dy * dy) + (dz * dz));
// Convert to NM // Convert to NM
distance *= kMetersToNM; distance *= kMetersToNM;

View File

@@ -392,7 +392,7 @@ void XPMPDefaultPlaneRenderer(int is_blend)
renderRecord.pitch = pos.pitch; renderRecord.pitch = pos.pitch;
renderRecord.heading = pos.heading; renderRecord.heading = pos.heading;
renderRecord.roll = pos.roll; renderRecord.roll = pos.roll;
renderRecord.model=((XPMPPlanePtr)id)->model; renderRecord.model = static_cast<XPMPPlanePtr>(id)->model;
renderRecord.cull = cull; // NO other planes. Doing so causes a lot of things to go nuts! renderRecord.cull = cull; // NO other planes. Doing so causes a lot of things to go nuts!
renderRecord.tcas = tcas; renderRecord.tcas = tcas;

View File

@@ -42,12 +42,13 @@
static char * my_fgets(char * s, int n, FILE * file) static char * my_fgets(char * s, int n, FILE * file)
{ {
char * p = s; char * p = s;
int c;
if (--n < 0) if (--n < 0)
return(NULL); return(NULL);
if (n) if (n)
{
int c;
do do
{ {
c = fgetc(file); c = fgetc(file);
@@ -65,6 +66,7 @@ static char * my_fgets(char * s, int n, FILE * file)
*p++ = c; *p++ = c;
} }
while (c != '\n' && c != '\r' && --n); while (c != '\n' && c != '\r' && --n);
}
*p = 0; *p = 0;
@@ -413,6 +415,7 @@ struct XPointPool::XPointPoolImp {
return static_cast<int>(pts.size()); return static_cast<int>(pts.size());
} }
#if 0
int accumulate(const float xyz[3], const float st[2]) int accumulate(const float xyz[3], const float st[2])
{ {
static char buf[256]; static char buf[256];
@@ -433,6 +436,7 @@ struct XPointPool::XPointPoolImp {
pts.push_back(p); pts.push_back(p);
return static_cast<int>(pts.size())-1; return static_cast<int>(pts.size())-1;
} }
#endif
void get(int i, float xyz[3], float st[2]) void get(int i, float xyz[3], float st[2])
{ {
@@ -457,10 +461,12 @@ void XPointPool::clear()
mImp->clear(); mImp->clear();
} }
#if 0
int XPointPool::accumulate(const float xyz[3], const float st[2]) int XPointPool::accumulate(const float xyz[3], const float st[2])
{ {
return mImp->accumulate(xyz, st); return mImp->accumulate(xyz, st);
} }
#endif
void XPointPool::get(int index, float xyz[3], float st[2]) void XPointPool::get(int index, float xyz[3], float st[2])
{ {

View File

@@ -109,7 +109,7 @@ public:
XPointPool(); XPointPool();
~XPointPool(); ~XPointPool();
void clear(); void clear();
int accumulate(const float xyz[3], const float st[2]); //int accumulate(const float xyz[3], const float st[2]);
int count(void); int count(void);
void get(int index, float xyz[3], float st[2]); void get(int index, float xyz[3], float st[2]);