mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-24 07:55:35 +08:00
[swift] killed approximately 150 compiler warnings
This commit is contained in:
@@ -53,12 +53,14 @@ static char * my_fgets(char * s, int n, FILE * file)
|
||||
c = fgetc(file);
|
||||
|
||||
if (c == EOF)
|
||||
{
|
||||
if (/*feof(file) &&*/ p != s)
|
||||
break;
|
||||
else
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
*p++ = c;
|
||||
}
|
||||
@@ -109,7 +111,7 @@ void StTextFileScanner::read_next(void)
|
||||
|
||||
while (mFile && /*!feof(mFile) &&*/ my_fgets(buf, sizeof(buf), mFile))
|
||||
{
|
||||
int len = strlen(buf);
|
||||
int len = static_cast<int>(strlen(buf));
|
||||
while ((len > 0) && (buf[len-1] == '\r' || buf[len-1] == '\n'))
|
||||
{
|
||||
buf[len-1] = 0;
|
||||
@@ -223,13 +225,13 @@ int PickRandom(vector<double>& chances)
|
||||
{
|
||||
double v = (double) (rand() % RAND_MAX) / (double) RAND_MAX;
|
||||
|
||||
for (int n = 0; n < chances.size(); ++n)
|
||||
for (size_t n = 0; n < chances.size(); ++n)
|
||||
{
|
||||
if (v < chances[n])
|
||||
return n;
|
||||
return static_cast<int>(n);
|
||||
v -= chances[n];
|
||||
}
|
||||
return chances.size();
|
||||
return static_cast<int>(chances.size());
|
||||
}
|
||||
|
||||
bool RollDice(double inProb)
|
||||
@@ -351,8 +353,8 @@ void ExtractFixedRecordString(
|
||||
{
|
||||
int sp = inBegin-1;
|
||||
int ep = inEnd;
|
||||
if (ep > inLine.length()) ep = inLine.length();
|
||||
if (sp > inLine.length()) sp = inLine.length();
|
||||
if (ep > static_cast<int>(inLine.length())) ep = static_cast<int>(inLine.length());
|
||||
if (sp > static_cast<int>(inLine.length())) sp = static_cast<int>(inLine.length());
|
||||
|
||||
while ((sp < ep) && (inLine[sp] == ' '))
|
||||
++sp;
|
||||
@@ -389,7 +391,7 @@ bool ExtractFixedRecordUnsignedLong(
|
||||
return true;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
//#pragma mark -
|
||||
|
||||
struct XPointPool::XPointPoolImp {
|
||||
|
||||
@@ -408,7 +410,7 @@ struct XPointPool::XPointPoolImp {
|
||||
|
||||
int count(void)
|
||||
{
|
||||
return pts.size();
|
||||
return static_cast<int>(pts.size());
|
||||
}
|
||||
|
||||
int accumulate(const float xyz[3], const float st[2])
|
||||
@@ -427,9 +429,9 @@ struct XPointPool::XPointPoolImp {
|
||||
memcpy(p.xyz, xyz, sizeof(p.xyz));
|
||||
memcpy(p.st, st, sizeof(p.st));
|
||||
pts.push_back(p);
|
||||
index.insert(map<string,int>::value_type(key, pts.size()));
|
||||
index.insert(map<string,int>::value_type(key, static_cast<int>(pts.size())));
|
||||
pts.push_back(p);
|
||||
return pts.size()-1;
|
||||
return static_cast<int>(pts.size())-1;
|
||||
}
|
||||
|
||||
void get(int i, float xyz[3], float st[2])
|
||||
@@ -501,12 +503,12 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
|
||||
case obj_Polygon:
|
||||
// Polygons might be ok. But if we have to break them down,
|
||||
// we generate N-2 triangles in a fan configuration.
|
||||
if (maxValence < inCmd.st.size())
|
||||
if (maxValence < static_cast<int>(inCmd.st.size()))
|
||||
{
|
||||
c.st.push_back(inCmd.st[0]);
|
||||
c.st.push_back(inCmd.st[1]);
|
||||
c.st.push_back(inCmd.st[2]);
|
||||
for (int n = 2; n < inCmd.st.size(); ++n)
|
||||
for (size_t n = 2; n < inCmd.st.size(); ++n)
|
||||
{
|
||||
c.st[1] = inCmd.st[n-1];
|
||||
c.st[2] = inCmd.st[n ];
|
||||
@@ -521,7 +523,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
|
||||
c.st.push_back(inCmd.st[0]);
|
||||
c.st.push_back(inCmd.st[1]);
|
||||
c.st.push_back(inCmd.st[2]);
|
||||
for (int n = 2; n < inCmd.st.size(); ++n)
|
||||
for (size_t n = 2; n < inCmd.st.size(); ++n)
|
||||
{
|
||||
if (n%2)
|
||||
{
|
||||
@@ -542,7 +544,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
|
||||
c.st.push_back(inCmd.st[0]);
|
||||
c.st.push_back(inCmd.st[1]);
|
||||
c.st.push_back(inCmd.st[2]);
|
||||
for (int n = 2; n < inCmd.st.size(); ++n)
|
||||
for (size_t n = 2; n < inCmd.st.size(); ++n)
|
||||
{
|
||||
c.st[1] = inCmd.st[n-1];
|
||||
c.st[2] = inCmd.st[n ];
|
||||
@@ -558,7 +560,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
|
||||
c.st.push_back(inCmd.st[1]);
|
||||
c.st.push_back(inCmd.st[2]);
|
||||
c.st.push_back(inCmd.st[3]);
|
||||
for (int n = 2; n < inCmd.st.size(); n += 2)
|
||||
for (size_t n = 2; n < inCmd.st.size(); n += 2)
|
||||
{
|
||||
c.st[0] = inCmd.st[n-2];
|
||||
c.st[1] = inCmd.st[n-1];
|
||||
@@ -570,7 +572,7 @@ void DecomposeObjCmd(const XObjCmd& inCmd, vector<XObjCmd>& outCmds, int maxVale
|
||||
c.st.push_back(inCmd.st[0]);
|
||||
c.st.push_back(inCmd.st[1]);
|
||||
c.st.push_back(inCmd.st[2]);
|
||||
for (int n = 2; n < inCmd.st.size(); ++n)
|
||||
for (size_t n = 2; n < inCmd.st.size(); ++n)
|
||||
{
|
||||
if (n%2)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user