Merge branch 'cppcheck' of https://github.com/tobbi/stk-code into tobbi-cppcheck
This commit is contained in:
commit
51be8195bc
@ -128,8 +128,13 @@ void generateLifetimeSizeDirection(scene::IParticleEmitter *emitter, float &life
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePointEmitter *emitter)
|
||||
{
|
||||
ParticleParams = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * count);
|
||||
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
ParticleData* ParticleParamsTmp = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * count);
|
||||
ParticleData* InitialValuesTmp = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
|
||||
if(ParticleParamsTmp != NULL) // In case memory allocation succeeded
|
||||
ParticleParams = ParticleParamsTmp;
|
||||
if(InitialValuesTmp != NULL)
|
||||
InitialValues = InitialValuesTmp;
|
||||
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
@ -150,8 +155,13 @@ void ParticleSystemProxy::generateParticlesFromPointEmitter(scene::IParticlePoin
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmitter *emitter)
|
||||
{
|
||||
ParticleParams = (ParticleData *)realloc(ParticleParams, sizeof(ParticleData)* count);
|
||||
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
ParticleData* ParticleParamsTmp = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * count);
|
||||
ParticleData* InitialValuesTmp = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
|
||||
if(ParticleParamsTmp != NULL) // In case memory allocation succeeded
|
||||
ParticleParams = ParticleParamsTmp;
|
||||
if(InitialValuesTmp != NULL)
|
||||
InitialValues = InitialValuesTmp;
|
||||
|
||||
const core::vector3df& extent = emitter->getBox().getExtent();
|
||||
|
||||
@ -177,8 +187,13 @@ void ParticleSystemProxy::generateParticlesFromBoxEmitter(scene::IParticleBoxEmi
|
||||
|
||||
void ParticleSystemProxy::generateParticlesFromSphereEmitter(scene::IParticleSphereEmitter *emitter)
|
||||
{
|
||||
ParticleParams = (ParticleData *)realloc(ParticleParams, sizeof(ParticleData)* count);
|
||||
InitialValues = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
ParticleData* ParticleParamsTmp = (ParticleData *) realloc(ParticleParams, sizeof(ParticleData) * count);
|
||||
ParticleData* InitialValuesTmp = (ParticleData *)realloc(InitialValues, sizeof(ParticleData)* count);
|
||||
|
||||
if(ParticleParamsTmp != NULL) // In case memory allocation succeeded
|
||||
ParticleParams = ParticleParamsTmp;
|
||||
if(InitialValuesTmp != NULL)
|
||||
InitialValues = InitialValuesTmp;
|
||||
|
||||
for (unsigned i = 0; i < count; i++) {
|
||||
// Random distance from center
|
||||
|
@ -44,7 +44,7 @@ Wiimote::Wiimote(wiimote_t* wiimote_handle, int wiimote_id,
|
||||
|
||||
gamepad_config->setPlugged();
|
||||
// Determine number of bits in the bit mask of all buttons.
|
||||
int button_count = (int)( log((float)WIIMOTE_BUTTON_ALL) / log(2.0f))+1;
|
||||
int button_count = (int)( log((float)WIIMOTE_BUTTON_ALL) / log((float)2.0f))+1;
|
||||
|
||||
m_gamepad_device = new GamePadDevice(getIrrId(),
|
||||
gamepad_name.c_str(),
|
||||
|
@ -164,7 +164,7 @@ void WiimoteManager::launchDetection(int timeout)
|
||||
|
||||
device_manager->getConfigForGamepad(WIIMOTE_START_IRR_ID, "Wiimote",
|
||||
&gamepad_config);
|
||||
int num_buttons = (int)( log((float)WIIMOTE_BUTTON_ALL) / log(2.0f))+1;
|
||||
int num_buttons = (int)( log((float)WIIMOTE_BUTTON_ALL) / log((float)2.0f))+1;
|
||||
gamepad_config->setNumberOfButtons(num_buttons);
|
||||
gamepad_config->setNumberOfAxis(1);
|
||||
|
||||
@ -213,7 +213,7 @@ void WiimoteManager::launchDetection(int timeout)
|
||||
*/
|
||||
int getButton(int n)
|
||||
{
|
||||
return (int)(log((float)n)/log(2.0f));
|
||||
return (int)(log((float)n)/log((float)2.0f));
|
||||
} // getButton
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -1284,7 +1284,12 @@ bool FileManager::copyFile(const std::string &source, const std::string &dest)
|
||||
|
||||
const int BUFFER_SIZE=32768;
|
||||
char *buffer = new char[BUFFER_SIZE];
|
||||
if(!buffer) return false;
|
||||
if(!buffer)
|
||||
{
|
||||
fclose(f_source);
|
||||
fclose(f_dest);
|
||||
return false;
|
||||
}
|
||||
size_t n;
|
||||
while((n=fread(buffer, 1, BUFFER_SIZE, f_source))>0)
|
||||
{
|
||||
|
@ -253,7 +253,7 @@ void History::Load()
|
||||
Log::fatal("History", "Could not read history.dat.");
|
||||
|
||||
unsigned int num_karts;
|
||||
if(sscanf(s, "numkarts: %d",&num_karts)!=1)
|
||||
if(sscanf(s, "numkarts: %d",(int*) &num_karts)!=1)
|
||||
Log::fatal("History", "No number of karts found in history file.");
|
||||
race_manager->setNumKarts(num_karts);
|
||||
|
||||
|
@ -100,7 +100,7 @@ void ReplayPlay::Load()
|
||||
Log::fatal("Replay", "Could not read '%s'.", getReplayFilename().c_str());
|
||||
|
||||
unsigned int version;
|
||||
if (sscanf(s,"Version: %d", &version) != 1)
|
||||
if (sscanf(s,"Version: %u", &version) != 1)
|
||||
Log::fatal("Replay", "No Version information found in replay file (bogus replay file).");
|
||||
|
||||
if (version != getReplayVersion())
|
||||
@ -130,7 +130,7 @@ void ReplayPlay::Load()
|
||||
|
||||
unsigned int num_laps;
|
||||
fgets(s, 1023, fd);
|
||||
if(sscanf(s, "Laps: %d", &num_laps) != 1)
|
||||
if(sscanf(s, "Laps: %u", &num_laps) != 1)
|
||||
Log::fatal("Replay", "No number of laps found in replay file.");
|
||||
|
||||
race_manager->setNumLaps(num_laps);
|
||||
@ -164,7 +164,7 @@ void ReplayPlay::readKartData(FILE *fd, char *next_line)
|
||||
|
||||
fgets(s, 1023, fd);
|
||||
unsigned int size;
|
||||
if(sscanf(s,"size: %d",&size)!=1)
|
||||
if(sscanf(s,"size: %u",&size)!=1)
|
||||
Log::fatal("Replay", "Number of records not found in replay file "
|
||||
"for kart %d.",
|
||||
m_ghost_karts.size()-1);
|
||||
@ -198,7 +198,7 @@ void ReplayPlay::readKartData(FILE *fd, char *next_line)
|
||||
} // for i
|
||||
fgets(s, 1023, fd);
|
||||
unsigned int num_events;
|
||||
if(sscanf(s,"events: %d",&num_events)!=1)
|
||||
if(sscanf(s,"events: %u",&num_events)!=1)
|
||||
Log::warn("Replay", "Number of events not found in replay file "
|
||||
"for kart %d.", m_ghost_karts.size()-1);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user