Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all warnings generated by GCC #20

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aas_facemerging.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ int AAS_CanMergePlaneFaces(tmp_area_t *tmparea, int planenum)
{
tmp_area_t *frontarea, *backarea;
tmp_face_t *face1;
int side1, merge, faceflags;
int side1 = 0, merge = 0, faceflags = 0;

frontarea = backarea = NULL;
merge = false;
Expand Down
2 changes: 1 addition & 1 deletion aas_gsubdiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ tmp_node_t *AAS_LadderSubdivideArea_r(tmp_node_t *tmpnode)
tmp_area_t *tmparea, *frontarea, *backarea;
tmp_face_t *face1;
tmp_node_t *tmpnode1, *tmpnode2;
vec3_t lowestpoint, normal = {0, 0, 1};
vec3_t lowestpoint = {0}, normal = {0, 0, 1};
plane_t *plane;
winding_t *w;

Expand Down
9 changes: 7 additions & 2 deletions bspc.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,17 @@ void CreateAASFilesForAllBSPFiles(char *quakepath)
//
for (qf = bspfiles; qf; qf = qf->next)
{
sprintf(aasfile, "%s/%s", qf->pakfile, qf->origname);
if (snprintf(aasfile, sizeof(aasfile), "%s/%s", qf->pakfile, qf->origname) >= sizeof(aasfile))
{
fprintf(stderr, "Error: AAS file name too long.");
}
Log_Print("found %s\n", aasfile);
strcpy(&aasfile[strlen(aasfile)-strlen(".bsp")], ".aas");
for (qf2 = aasfiles; qf2; qf2 = qf2->next)
{
sprintf(buf, "%s/%s", qf2->pakfile, qf2->origname);
if (snprintf(buf, sizeof(buf), "%s/%s", qf2->pakfile, qf2->origname) >= sizeof(buf)) {
fprintf(stderr, "Error: AAS file name too long.");
}
if (!stricmp(aasfile, buf))
{
Log_Print("found %s\n", buf);
Expand Down
6 changes: 3 additions & 3 deletions deps/botlib/be_aas_reach.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,8 @@ int AAS_Reachability_Step_Barrier_WaterJump_WalkOffLedge(int area1num, int area2
float length, ground_bestlength, water_bestlength, ground_bestdist, water_bestdist;
vec3_t v1, v2, v3, v4, tmpv, p1area1, p1area2, p2area1, p2area2;
vec3_t normal, ort, edgevec, start, end, dir;
vec3_t ground_beststart, ground_bestend, ground_bestnormal;
vec3_t water_beststart, water_bestend, water_bestnormal;
vec3_t ground_beststart = {0}, ground_bestend = {0}, ground_bestnormal = {0};
vec3_t water_beststart = {0}, water_bestend = {0}, water_bestnormal = {0};
vec3_t invgravity = {0, 0, 1};
vec3_t testpoint;
aas_plane_t *plane;
Expand Down Expand Up @@ -2380,7 +2380,7 @@ int AAS_Reachability_Ladder(int area1num, int area2num)
float face1area, face2area, bestface1area, bestface2area;
float phys_jumpvel, maxjumpheight;
vec3_t area1point, area2point, v1, v2, up = {0, 0, 1};
vec3_t mid, lowestpoint, start, end, sharededgevec, dir;
vec3_t mid, lowestpoint = {0}, start, end, sharededgevec, dir;
aas_area_t *area1, *area2;
aas_face_t *face1, *face2, *ladderface1, *ladderface2;
aas_plane_t *plane1, *plane2;
Expand Down
10 changes: 5 additions & 5 deletions deps/botlib/l_precomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define
case BUILTIN_DATE:
{
t = time(NULL);
curtime = ctime(&t);
curtime = ctime((const long int *)&t);
strcpy(token->string, "\"");
strncat(token->string, curtime+4, 7);
strncat(token->string+7, curtime+20, 4);
Expand All @@ -754,7 +754,7 @@ int PC_ExpandBuiltinDefine(source_t *source, token_t *deftoken, define_t *define
case BUILTIN_TIME:
{
t = time(NULL);
curtime = ctime(&t);
curtime = ctime((const long int *)&t);
strcpy(token->string, "\"");
strncat(token->string, curtime+11, 8);
strcat(token->string, "\"");
Expand Down Expand Up @@ -1702,7 +1702,7 @@ int PC_EvaluateTokens(source_t *source, token_t *tokens, signed long int *intval
int lastoperatortype = 0;
//
operator_t operator_heap[MAX_OPERATORS];
int numoperators = 0;
int numoperators = lastoperatortype = 0;
value_t value_heap[MAX_VALUES];
int numvalues = 0;

Expand Down Expand Up @@ -2997,7 +2997,7 @@ source_t *LoadSourceFile(const char *filename)
source = (source_t *) GetMemory(sizeof(source_t));
Com_Memset(source, 0, sizeof(source_t));

strncpy(source->filename, filename, MAX_PATH);
strncpy(source->filename, filename, MAX_PATH-1);
source->scriptstack = script;
source->tokens = NULL;
source->defines = NULL;
Expand Down Expand Up @@ -3030,7 +3030,7 @@ source_t *LoadSourceMemory(char *ptr, int length, char *name)
source = (source_t *) GetMemory(sizeof(source_t));
Com_Memset(source, 0, sizeof(source_t));

strncpy(source->filename, name, MAX_PATH);
strncpy(source->filename, name, MAX_PATH-1);
source->scriptstack = script;
source->tokens = NULL;
source->defines = NULL;
Expand Down
4 changes: 2 additions & 2 deletions deps/botlib/l_precomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ typedef struct indent_s
//source file
typedef struct source_s
{
char filename[1024]; //file name of the script
char includepath[1024]; //path to include files
char filename[8192]; //file name of the script
char includepath[9215]; //path to include files
punctuation_t *punctuations; //punctuations to use
script_t *scriptstack; //stack with scripts of the source
token_t *tokens; //tokens to read first
Expand Down
2 changes: 2 additions & 0 deletions deps/botlib/l_script.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ typedef enum {qfalse, qtrue} qboolean;

#endif //SCREWUP

int COM_Compress( char *data_p );

#ifdef BOTLIB
//include files for usage in the bot library
#include "qcommon/q_shared.h"
Expand Down
2 changes: 1 addition & 1 deletion deps/qcommon/cm_patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,7 @@ void CM_TraceThroughPatchCollide( traceWork_t *tw, const struct patchCollide_s *
float offset, enterFrac, leaveFrac, t;
patchPlane_t *planes;
facet_t *facet;
float plane[4], bestplane[4];
float plane[4] = {0}, bestplane[4] = {0};
vec3_t startp, endp;
#ifndef BSPC
static cvar_t *cv;
Expand Down
4 changes: 2 additions & 2 deletions deps/qcommon/cm_trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ float SquareRootFloat(float number) {

x = number * 0.5F;
y = number;
i = * ( long * ) &y;
i = (long)y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
y = (float)i;
y = y * ( f - ( x * y * y ) );
y = y * ( f - ( x * y * y ) );
return number * y;
Expand Down
33 changes: 23 additions & 10 deletions deps/qcommon/unzip.c
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,10 @@ static int unzlocal_getShort (FILE* fin, uLong *pX)
{
short v;

fread( &v, sizeof(v), 1, fin );
if (fread(&v, sizeof(v), 1, fin) != sizeof(v))
{
perror("Could not read data from compressed file.");
}

*pX = LittleShort( v);
return UNZ_OK;
Expand Down Expand Up @@ -1137,7 +1140,10 @@ static int unzlocal_getLong (FILE *fin, uLong *pX)
{
int v;

fread( &v, sizeof(v), 1, fin );
if (fread(&v, sizeof(v), 1, fin) != sizeof(v))
{
perror("Could not read data from compressed file.");
}

*pX = LittleLong( v);
return UNZ_OK;
Expand Down Expand Up @@ -1412,8 +1418,10 @@ extern int unzClose (unzFile file)
return UNZ_PARAMERROR;
s=(unz_s*)file;

if (s->pfile_in_zip_read!=NULL)
unzCloseCurrentFile(file);
if (s->pfile_in_zip_read != NULL)
{
unzCloseCurrentFile(file);
}

fclose(s->file);
TRYFREE(s);
Expand Down Expand Up @@ -1737,8 +1745,10 @@ extern int unzLocateFile (unzFile file, const char *szFileName, int iCaseSensiti
if (file==NULL)
return UNZ_PARAMERROR;

if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP)
return UNZ_PARAMERROR;
if (strlen(szFileName) >= UNZ_MAXFILENAMEINZIP)
{
return UNZ_PARAMERROR;
}

s=(unz_s*)file;
if (!s->current_file_ok)
Expand Down Expand Up @@ -1816,8 +1826,10 @@ static int unzlocal_CheckCurrentFileCoherencyHeader (unz_s* s, uInt* piSizeVar,
(s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;

if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
err=UNZ_ERRNO;
if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* date/time */
{
err = UNZ_ERRNO;
}

if (unzlocal_getLong(s->file,&uData) != UNZ_OK) /* crc */
err=UNZ_ERRNO;
Expand Down Expand Up @@ -1876,8 +1888,8 @@ extern int unzOpenCurrentFile (unzFile file)
if (!s->current_file_ok)
return UNZ_PARAMERROR;

if (s->pfile_in_zip_read != NULL)
unzCloseCurrentFile(file);
if (s->pfile_in_zip_read != NULL)
unzCloseCurrentFile(file);

if (unzlocal_CheckCurrentFileCoherencyHeader(s,&iSizeVar,
&offset_local_extrafield,&size_local_extrafield)!=UNZ_OK)
Expand Down Expand Up @@ -3196,6 +3208,7 @@ static int huft_build(uInt *b, uInt n, uInt s, const uInt *d, const uInt *e, inf

/* Return Z_BUF_ERROR if we were given an incomplete table */
return y != 0 && g != 1 ? Z_BUF_ERROR : Z_OK;
puts(inflate_copyright);
}


Expand Down
2 changes: 1 addition & 1 deletion l_bsp_hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ void HL_WriteBSPFile (char *filename)

//============================================================================

#define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
#define ENTRIES(a) ((&a)[1] - a)
#define ENTRYSIZE(a) (sizeof(*(a)))

unsigned ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
Expand Down
6 changes: 4 additions & 2 deletions l_bsp_q2.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,8 @@ void Q2_LoadBSPFileTexinfo (char *filename)
q2_header = GetMemory(sizeof(dheader_t));

f = fopen (filename, "rb");
fread (q2_header, sizeof(dheader_t), 1, f);
if (fread(q2_header, sizeof(dheader_t), 1, f) != sizeof(dheader_t))
Error("Failed to read data from IBSP file", filename);

// swap the header
for (i=0 ; i< sizeof(dheader_t)/4 ; i++)
Expand All @@ -938,7 +939,8 @@ void Q2_LoadBSPFileTexinfo (char *filename)
ofs = q2_header->lumps[LUMP_TEXINFO].fileofs;

fseek (f, ofs, SEEK_SET);
fread (texinfo, length, 1, f);
if (fread(texinfo, length, 1, f) != length)
Error("Failed to read texture info from IBSP file", filename);
fclose (f);

numtexinfo = length / sizeof(texinfo_t);
Expand Down
5 changes: 3 additions & 2 deletions l_bsp_q3.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "l_qfiles.h"
#include "l_bsp_q3.h"
#include "l_bsp_ent.h"
#include <stdint.h>

void Q3_ParseEntities (void);
void Q3_PrintBSPFileSizes(void);
Expand Down Expand Up @@ -523,8 +524,8 @@ void Q3_SwapBSPFile( void ) {
Q3_SwapBlock( (int *)q3_dbrushsides, q3_numbrushsides * sizeof( q3_dbrushsides[0] ) );

// vis
((int *)&q3_visBytes)[0] = LittleLong( ((int *)&q3_visBytes)[0] );
((int *)&q3_visBytes)[1] = LittleLong( ((int *)&q3_visBytes)[1] );
((int32_t *)q3_visBytes)[0] = LittleLong(((int32_t *)q3_visBytes)[0]);
((int32_t *)q3_visBytes)[1] = LittleLong(((int32_t *)q3_visBytes)[1]);

// drawverts (don't swap colors )
for ( i = 0 ; i < q3_numDrawVerts ; i++ ) {
Expand Down
6 changes: 4 additions & 2 deletions l_bsp_sin.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,8 @@ void Sin_LoadBSPFileTexinfo (char *filename)
sin_header = GetMemory(sizeof(sin_dheader_t));

f = fopen (filename, "rb");
fread (sin_header, sizeof(sin_dheader_t), 1, f);
if (fread(sin_header, sizeof(sin_dheader_t), 1, f) != sizeof(sin_dheader_t))
Error("Failed to read data from IBSP file", filename);

// swap the header
for (i=0 ; i< sizeof(sin_dheader_t)/4 ; i++)
Expand All @@ -932,7 +933,8 @@ void Sin_LoadBSPFileTexinfo (char *filename)
ofs = sin_header->lumps[SIN_LUMP_TEXINFO].fileofs;

fseek (f, ofs, SEEK_SET);
fread (sin_texinfo, length, 1, f);
if (fread(sin_texinfo, length, 1, f) != length)
Error("Failed to read texture info from IBSP file", filename);
fclose (f);

sin_numtexinfo = length / sizeof(sin_texinfo_t);
Expand Down
2 changes: 1 addition & 1 deletion l_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ char *ExpandPath (char *path)
char *ExpandPathAndArchive (char *path)
{
char *expanded;
char archivename[1024];
char archivename[2048];

expanded = ExpandPath (path);

Expand Down
2 changes: 1 addition & 1 deletion l_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void Log_Open(char *filename)
printf("can't open the log file %s\n", filename);
return;
} //end if
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE);
strncpy(logfile.filename, filename, MAX_LOGFILENAMESIZE-1);
printf("Opened log %s\n", logfile.filename);
} //end of the function Log_Create
//===========================================================================
Expand Down
3 changes: 2 additions & 1 deletion l_mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

#include "qbsp.h"
#include "l_log.h"
#include <stdint.h>

int allocedmemory;

Expand Down Expand Up @@ -410,7 +411,7 @@ void *Hunk_Alloc(int size)
{
memhunk_t *h;

if (!size) return (void *) memhunk_high_size;
if (!size) return (void *) (intptr_t)memhunk_high_size;
//
h = GetClearedMemory(size + sizeof(memhunk_t));
h->ptr = (char *) h + sizeof(memhunk_t);
Expand Down
6 changes: 3 additions & 3 deletions leakfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void LeakFile (tree_t *tree)
{
vec3_t mid;
FILE *linefile;
char filename[1024];
char filename[2048];
node_t *node;
int count;

Expand All @@ -68,8 +68,8 @@ void LeakFile (tree_t *tree)
while (node->occupied > 1)
{
int next;
portal_t *p, *nextportal;
node_t *nextnode;
portal_t *p, *nextportal = NULL;
node_t *nextnode = NULL;
int s;

// find the best portal exit
Expand Down
2 changes: 1 addition & 1 deletion map_hl.c
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ bspbrush_t *HL_SplitBrushWithFace(bspbrush_t *brush, hl_dface_t *face)
hl_dplane_t plane;
vec_t *v1, *v2;
vec3_t normal, edgevec;
bspbrush_t *front, *back, *brushlist;
bspbrush_t *front = NULL, *back, *brushlist;

memcpy(&plane, &hl_dplanes[face->planenum], sizeof(hl_dplane_t));
//check on which side of the plane the face is
Expand Down
2 changes: 1 addition & 1 deletion map_q1.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ bspbrush_t *Q1_SplitBrushWithFace(bspbrush_t *brush, q1_dface_t *face)
q1_dplane_t plane;
vec_t *v1, *v2;
vec3_t normal, edgevec;
bspbrush_t *front, *back, *brushlist;
bspbrush_t *front = NULL, *back, *brushlist;

memcpy(&plane, &q1_dplanes[face->planenum], sizeof(q1_dplane_t));
//check on which side of the plane the face is
Expand Down
8 changes: 4 additions & 4 deletions portals.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,13 @@ void MakeNodePortal (node_t *node)
portal_t *new_portal, *p;
winding_t *w;
vec3_t normal;
float dist;
int side;
float dist = 0.0f;
int side = 0;

w = BaseWindingForNode (node);

// clip the portal by all the other portals in the node
for (p = node->portals; p && w; p = p->next[side])
for (p = node->portals; p && w; p = p->next[side])
{
if (p->nodes[0] == node)
{
Expand Down Expand Up @@ -482,7 +482,7 @@ void SplitNodePortals (node_t *node)
{
portal_t *p, *next_portal, *new_portal;
node_t *f, *b, *other_node;
int side;
int side = 0;
plane_t *plane;
winding_t *frontwinding, *backwinding;

Expand Down
Loading