Skip to content

Commit

Permalink
Fixed some errors pointed out by sanitizers and clang
Browse files Browse the repository at this point in the history
  • Loading branch information
ensiform committed Apr 9, 2023
1 parent d3e8c8d commit 6f5c578
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion code/cgame/cg_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ This is the only way control passes into the cgame module.
This must be the very first function compiled into the .q3vm file
================
*/
extern "C" Q_EXPORT intptr_t QDECL vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) {
extern "C" Q_EXPORT intptr_t QDECL vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) {
centity_t *cent;

switch ( command ) {
Expand Down
2 changes: 1 addition & 1 deletion code/client/snd_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData)
if (iInWidth == 2) {
iSample = LittleShort ( ((short *)pData)[iSrcSample] );
} else {
iSample = (int)( (unsigned char)(pData[iSrcSample]) - 128) << 8;
iSample = (unsigned int)( (unsigned char)(pData[iSrcSample]) - 128) << 8;
}

sfx->pSoundData[i] = (short)iSample;
Expand Down
8 changes: 4 additions & 4 deletions code/qcommon/cm_polylib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ ChopWindingInPlace
void ChopWindingInPlace (winding_t **inout, vec3_t normal, vec_t dist, vec_t epsilon)
{
winding_t *in;
vec_t dists[MAX_POINTS_ON_WINDING+4];
int sides[MAX_POINTS_ON_WINDING+4];
float dists[MAX_POINTS_ON_WINDING+4] = { 0 };
int sides[MAX_POINTS_ON_WINDING+4] = { 0 };
int counts[3];
static vec_t dot; // VC 4.2 optimizer bug if not static
static float dot; // VC 4.2 optimizer bug if not static
int i, j;
vec_t *p1, *p2;
float *p1, *p2;
vec3_t mid;
winding_t *f;
int maxpts;
Expand Down
10 changes: 5 additions & 5 deletions code/qcommon/z_memman_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -993,25 +993,25 @@ Touch all known used data to make sure it is paged in
void Com_TouchMemory( void ) {
//int start, end;
int i, j;
int sum;
int totalTouched;
unsigned int sum;
//int totalTouched;

Z_Validate();

//start = Sys_Milliseconds();

sum = 0;
totalTouched=0;
//totalTouched=0;

zoneHeader_t *pMemory = TheZone.Header.pNext;
while (pMemory)
{
byte *pMem = (byte *) &pMemory[1];
j = pMemory->iSize >> 2;
for (i=0; i<j; i+=64){
sum += ((int*)pMem)[i];
sum += ((unsigned int*)pMem)[i];
}
totalTouched+=pMemory->iSize;
//totalTouched+=pMemory->iSize;
pMemory = pMemory->pNext;
}

Expand Down
4 changes: 2 additions & 2 deletions code/rd-vanilla/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void ParseFace( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int *
numIndexes = LittleLong( ds->numIndexes );

// create the srfSurfaceFace_t
sfaceSize = ( intptr_t ) &((srfSurfaceFace_t *)0)->points[numPoints];
sfaceSize = sizeof( *cv ) - sizeof( cv->points ) + sizeof( cv->points[0] ) * numPoints;
ofsIndexes = sfaceSize;
sfaceSize += sizeof( int ) * numIndexes;

Expand Down Expand Up @@ -684,7 +684,7 @@ static void R_LoadSurfaces( lump_t *surfs, lump_t *verts, lump_t *indexLump, wor
{
case MST_PLANAR:

int sfaceSize = ( intptr_t ) &((srfSurfaceFace_t *)0)->points[LittleLong(in->numVerts)];
int sfaceSize = sizeof( srfSurfaceFace_t ) - sizeof( float[1][VERTEXSIZE] ) + sizeof( float[VERTEXSIZE] ) * LittleLong(in->numVerts);
sfaceSize += sizeof( int ) * LittleLong(in->numIndexes);

iFaceDataSizeRequired += sfaceSize;
Expand Down
2 changes: 1 addition & 1 deletion code/rd-vanilla/tr_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ qhandle_t RE_RegisterModel( const char *name )

qhandle_t q = RE_RegisterModel_Actual( name );

if (Q_stricmp(&name[strlen(name)-4],".gla")){
if (!COM_CompareExtension(name, ".gla")) {
gbInsideRegisterModel = qfalse; // GLA files recursively call this, so don't turn off half way. A reference count would be nice, but if any ERR_DROP ever occurs within the load then the refcount will be knackered from then on
}

Expand Down
2 changes: 1 addition & 1 deletion codeJK2/cgame/cg_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ This is the only way control passes into the cgame module.
This must be the very first function compiled into the .q3vm file
================
*/
extern "C" Q_EXPORT intptr_t vmMain( intptr_t command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) {
extern "C" Q_EXPORT intptr_t vmMain( int command, intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5, intptr_t arg6, intptr_t arg7 ) {
centity_t *cent;

switch ( command ) {
Expand Down
2 changes: 1 addition & 1 deletion codemp/client/snd_mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void ResampleSfx (sfx_t *sfx, int iInRate, int iInWidth, byte *pData)
if (iInWidth == 2) {
iSample = LittleShort ( ((short *)pData)[iSrcSample] );
} else {
iSample = (int)( (unsigned char)(pData[iSrcSample]) - 128) << 8;
iSample = (unsigned int)( (unsigned char)(pData[iSrcSample]) - 128) << 8;
}

sfx->pSoundData[i] = (short)iSample;
Expand Down
14 changes: 7 additions & 7 deletions codemp/qcommon/RoffSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,19 +869,19 @@ qboolean CROFFSystem::ApplyROFF( SROFFEntity *roff_ent, CROFFSystem::CROFF *roff
return qtrue;
}

#ifndef DEDICATED
vec3_t originTemp, angleTemp;
if (roff_ent->mIsClient)
{
#ifndef DEDICATED
vec3_t originTemp, angleTemp;
originTrajectory = CGVM_GetOriginTrajectory( roff_ent->mEntID );
angleTrajectory = CGVM_GetAngleTrajectory( roff_ent->mEntID );
CGVM_GetOrigin( roff_ent->mEntID, originTemp );
origin = originTemp;
CGVM_GetAngles( roff_ent->mEntID, angleTemp );
angle = angleTemp;
#endif
}
else
#endif
{
// Find the entity to apply the roff to
ent = SV_GentityNum( roff_ent->mEntID );
Expand Down Expand Up @@ -982,7 +982,7 @@ void CROFFSystem::ProcessNote(SROFFEntity *roff_ent, char *note)
{
temp[size++] = note[pos++];
}
temp[size] = 0;
temp[size] = '\0';

if (size)
{
Expand Down Expand Up @@ -1016,19 +1016,19 @@ qboolean CROFFSystem::ClearLerp( SROFFEntity *roff_ent )
trajectory_t *originTrajectory = NULL, *angleTrajectory = NULL;
float *origin = NULL, *angle = NULL;

#ifndef DEDICATED
vec3_t originTemp, angleTemp;
if (roff_ent->mIsClient)
{
#ifndef DEDICATED
vec3_t originTemp, angleTemp;
originTrajectory = CGVM_GetOriginTrajectory( roff_ent->mEntID );
angleTrajectory = CGVM_GetAngleTrajectory( roff_ent->mEntID );
CGVM_GetOrigin( roff_ent->mEntID, originTemp );
origin = originTemp;
CGVM_GetAngles( roff_ent->mEntID, angleTemp );
angle = angleTemp;
#endif
}
else
#endif
{
// Find the entity to apply the roff to
ent = SV_GentityNum( roff_ent->mEntID );
Expand Down
4 changes: 2 additions & 2 deletions codemp/qcommon/z_memman_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Touch all known used data to make sure it is paged in
void Com_TouchMemory( void ) {
// int start, end;
int i, j;
int sum;
unsigned int sum;

// start = Sys_Milliseconds();
Z_Validate();
Expand All @@ -679,7 +679,7 @@ void Com_TouchMemory( void ) {
byte *pMem = (byte *) &pMemory[1];
j = pMemory->iSize >> 2;
for (i=0; i<j; i+=64){
sum += ((int*)pMem)[i];
sum += ((unsigned int*)pMem)[i];
}

pMemory = pMemory->pNext;
Expand Down
2 changes: 1 addition & 1 deletion codemp/rd-vanilla/tr_bsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ static void ParseFace( dsurface_t *ds, mapVert_t *verts, msurface_t *surf, int *
numIndexes = LittleLong( ds->numIndexes );

// create the srfSurfaceFace_t
sfaceSize = ( size_t ) &((srfSurfaceFace_t *)0)->points[numPoints];
sfaceSize = sizeof( *cv ) - sizeof( cv->points ) + sizeof( cv->points[0] ) * numPoints;
ofsIndexes = sfaceSize;
sfaceSize += sizeof( int ) * numIndexes;

Expand Down

0 comments on commit 6f5c578

Please sign in to comment.