Skip to content

Commit fd3b199

Browse files
committed
Fixup some warnings pointed out by gcc
Disable Q_strnlen until its needed due to warnings even though standard library version of strnlen does exactly this style of return.
1 parent 856edf8 commit fd3b199

4 files changed

Lines changed: 34 additions & 33 deletions

File tree

code/api/shared/q_string.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ void Q_strcat_fn( char *dest, const int size, const char *src, const char *func,
433433
Q_strncpyz_fn( dest + l1, src, size - l1, func, file, line );
434434
}
435435

436-
size_t Q_strnlen_fn(const char *str, size_t strsz, const char *func, const char *file, const int line ) {
436+
/*size_t Q_strnlen_fn(const char* str, size_t strsz, const char* func, const char* file, const int line) {
437437
const char *p;
438438
if (!str) {
439439
Lib_Error("Q_strnlen: NULL str (%s, %s:%i)", func, file, line);
@@ -442,7 +442,7 @@ size_t Q_strnlen_fn(const char *str, size_t strsz, const char *func, const char
442442
443443
p = memchr(str, 0, strsz);
444444
return p ? p - str : strsz;
445-
}
445+
}*/
446446

447447
char *Q_stradd( char *dst, const char *src )
448448
{

code/api/shared/q_string.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If you have questions concerning this license or the applicable additional terms
3838
#pragma once
3939

4040
#include "q_primitives.h"
41-
#include <stddef.h>
41+
#include <stddef.h> // Q_vsnprintf or Q_strnlen needs size_t
4242

4343
#if defined(__cplusplus)
4444
extern "C" {
@@ -72,10 +72,10 @@ char *Q_strupr( char *s1 );
7272
// buffer size safe library replacements
7373
#define Q_strncpyz(dest, src, destsize) Q_strncpyz_fn(dest, src, destsize, __func__, RELATIVE_FILENAME, __LINE__)
7474
#define Q_strcat(dest, size, src) Q_strcat_fn(dest, size, src, __func__, RELATIVE_FILENAME, __LINE__)
75-
#define Q_strnlen(str, strsz ) Q_strnlen_fn(str, strsz, __func__, RELATIVE_FILENAME, __LINE__)
75+
//#define Q_strnlen(str, strsz ) Q_strnlen_fn(str, strsz, __func__, RELATIVE_FILENAME, __LINE__)
7676
void Q_strncpyz_fn( char *dest, const char *src, const int destsize, const char *func, const char *file, int line );
7777
void Q_strcat_fn( char *dest, const int size, const char *src, const char *func, const char *file, int line );
78-
size_t Q_strnlen_fn(const char *str, size_t strsz, const char *func, const char *file, int line );
78+
//size_t Q_strnlen_fn(const char *str, size_t strsz, const char *func, const char *file, int line );
7979

8080
const char *Q_stristr( const char *s, const char *find);
8181

code/cgame/cg_ents.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ static void CG_InterpolateEntityPosition( centity_t *cent ) {
15711571
CG_InterpolateEntityPosition
15721572
=============================
15731573
*/
1574-
static void CG_InterpolateEntityAngle( centity_t *cent ) {
1574+
/*static void CG_InterpolateEntityAngle(centity_t* cent) {
15751575
vec3_t current, next;
15761576
float f;
15771577
@@ -1583,7 +1583,7 @@ static void CG_InterpolateEntityAngle( centity_t *cent ) {
15831583
cent->lerpAngles[0] = LerpAngle( current[0], next[0], f );
15841584
cent->lerpAngles[1] = LerpAngle( current[1], next[1], f );
15851585
cent->lerpAngles[2] = LerpAngle( current[2], next[2], f );
1586-
}
1586+
}*/
15871587

15881588

15891589
/*

code/game/g_main.c

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,34 +2227,35 @@ void G_RunEntities(void) {
22272227
continue;
22282228

22292229
switch (ent->s.eType) {
2230-
case ET_MISSILE: {
2231-
if (ent->antilag_time) {
2232-
int snap_ms = 1000 / sv_fps.integer;
2233-
int prestep = ent->s.pos.trTime - projectile_now;
2234-
int steps = (projectile_now - ent->antilag_time) / snap_ms, rs = 0;
2235-
int ot = ent->s.pos.trTime - prestep;
2236-
ent->s.pos.trTime = ent->antilag_time + prestep;
2237-
2238-
while (steps > 0) {
2239-
int now = projectile_now - steps * snap_ms;
2240-
G_TimeShiftAllClients(now, ent->parent);
2241-
G_RunMissile(ent, now);
2242-
2243-
if (!ent->inuse)
2244-
break;
2245-
2246-
rs = 1;
2247-
steps--;
2230+
case ET_MISSILE:
2231+
{
2232+
if (ent->antilag_time) {
2233+
int snap_ms = 1000 / sv_fps.integer;
2234+
int prestep = ent->s.pos.trTime - projectile_now;
2235+
int steps = (projectile_now - ent->antilag_time) / snap_ms, rs = 0;
2236+
//int ot = ent->s.pos.trTime - prestep;
2237+
ent->s.pos.trTime = ent->antilag_time + prestep;
2238+
2239+
while (steps > 0) {
2240+
int now = projectile_now - steps * snap_ms;
2241+
G_TimeShiftAllClients(now, ent->parent);
2242+
G_RunMissile(ent, now);
2243+
2244+
if (!ent->inuse)
2245+
break;
2246+
2247+
rs = 1;
2248+
steps--;
2249+
}
2250+
ent->antilag_time = 0;
2251+
if (rs)
2252+
G_TimeShiftAllClients( projectile_now, NULL );
22482253
}
2249-
ent->antilag_time = 0;
2250-
if (rs)
2251-
G_TimeShiftAllClients( projectile_now, NULL );
2252-
}
22532254

2254-
if (ent->inuse)
2255-
G_RunMissile( ent, level.time );
2256-
break;
2257-
}
2255+
if (ent->inuse)
2256+
G_RunMissile( ent, level.time );
2257+
break;
2258+
}
22582259
}
22592260
}
22602261

0 commit comments

Comments
 (0)