stomped various lint warnings:
- /* */ -> // - clarified expressions - add casts - func() -> func(void) - signed/unsigned This was SVN commit r1773.
This commit is contained in:
parent
a43205148b
commit
e332d876f8
@ -166,7 +166,7 @@ static int z_find_ecdr(const u8* file, size_t size, const u8*& ecdr_)
|
||||
// scan the last 66000 bytes of file for ecdr_id signature
|
||||
// (the Zip archive comment field, up to 64k, may follow ECDR).
|
||||
// if the zip file is < 66000 bytes, scan the whole file.
|
||||
const u8* start = file + size - MIN(66000, size);
|
||||
const u8* start = file + size - MIN(66000u, size);
|
||||
ecdr = z_find_id(file, size, start, ecdr_id, ECDR_SIZE);
|
||||
if(!ecdr)
|
||||
return ERR_CORRUPTED;
|
||||
@ -432,7 +432,7 @@ static void copy_lower_case(char* dst, const char* src, size_t buf_size)
|
||||
// loop will exit below after writing 0-terminator.
|
||||
if(--buf_size == 0)
|
||||
c = '\0';
|
||||
*dst++ = tolower(c);
|
||||
*dst++ = (char)tolower(c);
|
||||
}
|
||||
while(c != '\0');
|
||||
}
|
||||
@ -460,7 +460,7 @@ static int lookup_add_file_cb(uintptr_t user, i32 idx,
|
||||
// both arrays in one allocation (more efficient)
|
||||
const size_t ents_size = (num_entries * sizeof(ZEnt));
|
||||
const size_t array_size = ents_size + (num_entries * sizeof(FnHash));
|
||||
void* p = mem_alloc(array_size, 4*KB);
|
||||
void* p = mem_alloc(array_size, 4*KiB);
|
||||
if(!p)
|
||||
return ERR_NO_MEM;
|
||||
|
||||
@ -762,7 +762,7 @@ static uintptr_t inf_init_ctx(bool compressed)
|
||||
// allocate ZLib stream
|
||||
const size_t size = round_up(sizeof(InfCtx), 32);
|
||||
// be nice to allocator
|
||||
InfCtx* ctx = (InfCtx*)calloc(size, 1);
|
||||
InfCtx* ctx = (InfCtx*)calloc(1, size);
|
||||
if(inflateInit2(&ctx->zs, -MAX_WBITS) != Z_OK)
|
||||
// -MAX_WBITS indicates no zlib header present
|
||||
return 0;
|
||||
@ -834,7 +834,7 @@ ssize_t inf_inflate(uintptr_t _ctx, void* in, size_t in_size, bool free_in_buf =
|
||||
else
|
||||
{
|
||||
memcpy(zs->next_out, zs->next_in, zs->avail_in);
|
||||
uInt size = min(zs->avail_in, zs->avail_out);
|
||||
uInt size = MIN(zs->avail_in, zs->avail_out);
|
||||
zs->avail_out -= size;
|
||||
zs->avail_in -= size; // => = 0
|
||||
zs->next_in += size;
|
||||
@ -1040,7 +1040,7 @@ int zip_close(ZFile* zf)
|
||||
// which is already compressed.
|
||||
|
||||
|
||||
static const size_t CHUNK_SIZE = 16*KB;
|
||||
static const size_t CHUNK_SIZE = 16*KiB;
|
||||
|
||||
// begin transferring <size> bytes, starting at <ofs>. get result
|
||||
// with zip_wait_io; when no longer needed, free via zip_discard_io.
|
||||
@ -1074,7 +1074,7 @@ int zip_start_io(ZFile* zf, off_t user_ofs, size_t max_output_size, void* user_b
|
||||
CHECK_ERR(inf_set_dest(io->inf_ctx, io->user_buf, io->max_output_size));
|
||||
ssize_t bytes_inflated = inf_inflate(io->inf_ctx, 0, 0);
|
||||
CHECK_ERR(bytes_inflated);
|
||||
if(bytes_inflated == max_output_size)
|
||||
if(bytes_inflated == (ssize_t)max_output_size)
|
||||
{
|
||||
io->already_inflated = true;
|
||||
io->max_output_size = bytes_inflated;
|
||||
@ -1089,7 +1089,7 @@ int zip_start_io(ZFile* zf, off_t user_ofs, size_t max_output_size, void* user_b
|
||||
|
||||
// note: only need to clamp if compressed
|
||||
|
||||
buf = mem_alloc(size, 4*KB);
|
||||
buf = mem_alloc(size, 4*KiB);
|
||||
}
|
||||
// else: not compressed; we'll just read directly from the archive file.
|
||||
// no need to clamp to EOF - that's done already by the VFS.
|
||||
@ -1188,9 +1188,6 @@ static ssize_t read_cb(uintptr_t ctx, void* buf, size_t size)
|
||||
return ucsize;
|
||||
}
|
||||
|
||||
#include "timer.h"
|
||||
|
||||
|
||||
|
||||
// read from the (possibly compressed) file <zf> as if it were a normal file.
|
||||
// starting at the beginning of the logical (decompressed) file,
|
||||
@ -1245,7 +1242,7 @@ ssize_t zip_read(ZFile* zf, off_t ofs, size_t size, void* p, FileIOCB cb, uintpt
|
||||
double t1 = get_time();
|
||||
file_io(&za->f,0, xsize, 0, io_cb, (uintptr_t)&xparams);
|
||||
double t2 = get_time();
|
||||
debug_out("\n\ntime to load whole archive %f\nthroughput %f MB/s\n", t2-t1, xsize / (t2-t1) / 1e6);
|
||||
debug_out("\n\ntime to load whole archive %f\nthroughput %f MiB/s\n", t2-t1, xsize / (t2-t1) / 1e6);
|
||||
mem_free(xbuf);
|
||||
}
|
||||
*/
|
||||
|
@ -41,8 +41,10 @@ void debug_check_heap()
|
||||
}
|
||||
|
||||
|
||||
int get_executable_name(char* /*n_path*/, size_t /*buf_size*/)
|
||||
int get_executable_name(char* n_path, size_t buf_size)
|
||||
{
|
||||
UNUSED(n_path);
|
||||
UNUSED(buf_size);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
@ -64,9 +66,9 @@ void debug_break()
|
||||
}
|
||||
|
||||
|
||||
const int MICROLOG_SIZE = 16384;
|
||||
const size_t MICROLOG_SIZE = 16384;
|
||||
wchar_t MicroBuffer[MICROLOG_SIZE];
|
||||
int MicroBuffer_off = 0;
|
||||
size_t MicroBuffer_off = 0;
|
||||
|
||||
void debug_microlog(const wchar_t *fmt, ...)
|
||||
{
|
||||
|
@ -28,7 +28,7 @@ extern void wdisplay_msg(const wchar_t* caption, const wchar_t* msg);
|
||||
|
||||
|
||||
extern int clipboard_set(const wchar_t* text);
|
||||
extern wchar_t* clipboard_get();
|
||||
extern wchar_t* clipboard_get(void);
|
||||
extern int clipboard_free(wchar_t* copy);
|
||||
|
||||
|
||||
|
@ -75,9 +75,9 @@ static void check_speedstep()
|
||||
// definitely speedstep if a CPU has thermal throttling active.
|
||||
// note that we don't care about user-defined throttles
|
||||
// (see ppi.CurrentMhz) - they don't change often.
|
||||
ULONG ppi_buf_size = cpus * sizeof(PROCESSOR_POWER_INFORMATION);
|
||||
const size_t ppi_buf_size = cpus * sizeof(PROCESSOR_POWER_INFORMATION);
|
||||
void* ppi_buf = malloc(ppi_buf_size);
|
||||
if(pCNPI(ProcessorInformation, 0, 0, ppi_buf, ppi_buf_size) == STATUS_SUCCESS)
|
||||
if(pCNPI(ProcessorInformation, 0, 0, ppi_buf, (ULONG)ppi_buf_size) == STATUS_SUCCESS)
|
||||
{
|
||||
PROCESSOR_POWER_INFORMATION* ppi = (PROCESSOR_POWER_INFORMATION*)ppi_buf;
|
||||
for(int i = 0; i < cpus; i++)
|
||||
@ -120,7 +120,7 @@ int win_get_cpu_info()
|
||||
// get number of CPUs (can't fail)
|
||||
SYSTEM_INFO si;
|
||||
GetSystemInfo(&si);
|
||||
cpus = si.dwNumberOfProcessors;
|
||||
cpus = (int)si.dwNumberOfProcessors;
|
||||
|
||||
// read CPU frequency from registry
|
||||
HKEY hKey;
|
||||
|
@ -147,13 +147,13 @@ int get_cur_vmode(int* xres, int* yres, int* bpp, int* freq)
|
||||
if(!EnumDisplaySettingsA(0, ENUM_CURRENT_SETTINGS, &dm))
|
||||
return -1;
|
||||
|
||||
if(dm.dmFields & DM_PELSWIDTH && xres)
|
||||
if(dm.dmFields & (DWORD)DM_PELSWIDTH && xres)
|
||||
*xres = (int)dm.dmPelsWidth;
|
||||
if(dm.dmFields & DM_PELSHEIGHT && yres)
|
||||
if(dm.dmFields & (DWORD)DM_PELSHEIGHT && yres)
|
||||
*yres = (int)dm.dmPelsHeight;
|
||||
if(dm.dmFields & DM_BITSPERPEL && bpp)
|
||||
if(dm.dmFields & (DWORD)DM_BITSPERPEL && bpp)
|
||||
*bpp = (int)dm.dmBitsPerPel;
|
||||
if(dm.dmFields & DM_DISPLAYFREQUENCY && freq)
|
||||
if(dm.dmFields & (DWORD)DM_DISPLAYFREQUENCY && freq)
|
||||
*freq = (int)dm.dmDisplayFrequency;
|
||||
|
||||
return 0;
|
||||
@ -307,14 +307,14 @@ static void list_add_dll(const char* dll_path)
|
||||
if(get_ver(dll_path, dll_ver, sizeof(dll_ver)) < 0)
|
||||
strcpy(dll_ver, "unknown version");
|
||||
|
||||
// get filename for "already added" check.
|
||||
const char* dll_fn = strrchr(dll_path, '\\')+1;
|
||||
|
||||
if(dll_fn == (const char*)1) // if dll_path was a filename
|
||||
// extract filename component for "already added" check.
|
||||
const char* slash = strrchr(dll_path, '\\');
|
||||
if(!slash) // dll_path was a filename
|
||||
{
|
||||
debug_warn("list_add_dll: invalid path");
|
||||
debug_warn("list_add_dll: full path not given");
|
||||
return;
|
||||
}
|
||||
const char* dll_fn = slash+1;
|
||||
|
||||
// make sure it hasn't been added yet.
|
||||
if(dlls_already_added.find(dll_fn) != dlls_already_added.end())
|
||||
@ -342,6 +342,8 @@ struct PathInfo
|
||||
// (match "*oal.dll" and "*OpenAL*", as with OpenAL router's search).
|
||||
static int check_if_oal_dll(const char* fn, const struct stat* s, const uintptr_t user)
|
||||
{
|
||||
UNUSED(s);
|
||||
|
||||
PathInfo* pi = (PathInfo*)user;
|
||||
strncpy(pi->end, fn, pi->remaining);
|
||||
|
||||
@ -390,6 +392,9 @@ static char ds_drv_name[MAX_PATH+1];
|
||||
// called for each DirectSound driver, but aborts after first valid driver.
|
||||
static BOOL CALLBACK ds_enum(void* guid, const char* description, const char* module, void* ctx)
|
||||
{
|
||||
UNUSED(guid);
|
||||
UNUSED(ctx);
|
||||
|
||||
// skip first (dummy) entry, where description == "Primary Sound Driver".
|
||||
if(module[0] == '\0')
|
||||
return TRUE; // continue calling
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define __WSDL_H__
|
||||
|
||||
|
||||
#include "types.h"
|
||||
#include "lib/types.h"
|
||||
#include "SDL_keysym.h"
|
||||
|
||||
/* allow apps to override window name */
|
||||
@ -24,7 +24,7 @@ extern "C" {
|
||||
|
||||
extern int SDL_Init(Uint32 flags);
|
||||
|
||||
extern void SDL_Quit();
|
||||
extern void SDL_Quit(void);
|
||||
|
||||
|
||||
typedef enum
|
||||
@ -50,7 +50,7 @@ typedef struct
|
||||
}
|
||||
SDL_Surface;
|
||||
|
||||
extern SDL_Surface* SDL_GetVideoSurface();
|
||||
extern SDL_Surface* SDL_GetVideoSurface(void);
|
||||
|
||||
|
||||
typedef struct
|
||||
@ -59,7 +59,7 @@ typedef struct
|
||||
}
|
||||
SDL_VideoInfo;
|
||||
|
||||
extern SDL_VideoInfo* SDL_GetVideoInfo();
|
||||
extern SDL_VideoInfo* SDL_GetVideoInfo(void);
|
||||
|
||||
|
||||
/*
|
||||
@ -71,9 +71,9 @@ typedef void SDL_Thread;
|
||||
|
||||
extern void* SDL_GL_GetProcAddress(const char*);
|
||||
|
||||
extern void SDL_GL_SwapBuffers();
|
||||
extern void SDL_GL_SwapBuffers(void);
|
||||
|
||||
extern u32 SDL_GetTicks();
|
||||
extern u32 SDL_GetTicks(void);
|
||||
extern void SDL_Delay(u32 ms);
|
||||
|
||||
extern SDL_sem* SDL_CreateSemaphore(int cnt);
|
||||
@ -324,10 +324,10 @@ extern int glutGameModeString(const char* str);
|
||||
|
||||
extern void glutInit(int* argc, char* argv[]);
|
||||
extern int glutGet(int arg);
|
||||
extern int glutEnterGameMode();
|
||||
extern void glutMainLoop();
|
||||
extern int glutEnterGameMode(void);
|
||||
extern void glutMainLoop(void);
|
||||
|
||||
extern void glutPostRedisplay();
|
||||
extern void glutPostRedisplay(void);
|
||||
|
||||
extern void glutSetCursor(int);
|
||||
|
||||
|
@ -75,7 +75,7 @@ extern int clock_getres(clockid_t clock, struct timespec* res);
|
||||
// provide a routine that makes the choice when called,
|
||||
// so app code isn't surprised by a timer change, although the HRT
|
||||
// does try to keep the timer continuous.
|
||||
extern void wtime_reset_impl();
|
||||
extern void wtime_reset_impl(void);
|
||||
|
||||
|
||||
#endif // #ifndef WTIME_H__
|
||||
|
@ -37,13 +37,13 @@ double get_time()
|
||||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
|
||||
static struct timespec start;
|
||||
static struct timespec start = {0};
|
||||
struct timespec ts;
|
||||
|
||||
if(!start.tv_sec)
|
||||
clock_gettime(CLOCK_REALTIME, &start);
|
||||
(void)clock_gettime(CLOCK_REALTIME, &start);
|
||||
|
||||
clock_gettime(CLOCK_REALTIME, &ts);
|
||||
(void)clock_gettime(CLOCK_REALTIME, &ts);
|
||||
t = (ts.tv_sec - start.tv_sec) + (ts.tv_nsec - start.tv_nsec)*1e-9;
|
||||
|
||||
#elif defined(HAVE_GETTIMEOFDAY)
|
||||
@ -64,7 +64,7 @@ double get_time()
|
||||
#endif
|
||||
|
||||
// make sure time is monotonic (never goes backwards)
|
||||
static double t_last;
|
||||
static double t_last = 0.0;
|
||||
if(t < t_last)
|
||||
t = t_last;
|
||||
t_last = t;
|
||||
@ -76,17 +76,17 @@ double get_time()
|
||||
double timer_res()
|
||||
{
|
||||
// may take a while to determine, so cache it
|
||||
static double cached_res;
|
||||
static double cached_res = 0.0;
|
||||
if(cached_res != 0.0)
|
||||
return cached_res;
|
||||
|
||||
double res;
|
||||
double res = 0.0;
|
||||
|
||||
#ifdef HAVE_CLOCK_GETTIME
|
||||
|
||||
struct timespec ts;
|
||||
clock_getres(CLOCK_REALTIME, &ts);
|
||||
res = ts.tv_nsec * 1e-9;
|
||||
if(clock_getres(CLOCK_REALTIME, &ts) == 0)
|
||||
res = ts.tv_nsec * 1e-9;
|
||||
|
||||
#else
|
||||
|
||||
@ -136,7 +136,7 @@ void calc_fps()
|
||||
// dt is big enough => we will update.
|
||||
// calculate approximate current FPS (= 1 / elapsed time per frame).
|
||||
last_t = t;
|
||||
cur_fps = 1.0 / dt * num_frames;
|
||||
cur_fps = (1.0 / dt) * num_frames;
|
||||
num_frames = 1; // reset for next time
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ void calc_fps()
|
||||
// cur_fps history and changes over past few frames
|
||||
static double h2, h1 = 30.0, h0 = 30.0;
|
||||
h2 = h1; h1 = h0; h0 = cur_fps;
|
||||
const double d21 = h1 - h2, d10 = h0 - h1, d20 = h0 - h2;
|
||||
const double d21 = h1 - h2, d10 = h0 - h1;
|
||||
const double e20 = REL_ERR(h2, h0), e10 = REL_ERR(h1, h0);
|
||||
const double e0 = REL_ERR(avg_fps, h0);
|
||||
|
||||
@ -172,7 +172,7 @@ void calc_fps()
|
||||
// /\ or \/
|
||||
const bool jumped = e10 > 0.30;
|
||||
// large change (have seen semi-legitimate changes of 25%)
|
||||
const bool close = e0 < 0.02;
|
||||
const bool is_close = e0 < 0.02;
|
||||
// cur_fps - avg_fps is "small"
|
||||
|
||||
// "same-side" check for rapid tracking of the function.
|
||||
@ -184,7 +184,7 @@ void calc_fps()
|
||||
same_side = 0; // reset counter
|
||||
// (only increase if not too close to average,
|
||||
// so that this isn't triggered by jitter alone)
|
||||
if(!close)
|
||||
if(!is_close)
|
||||
same_side++;
|
||||
|
||||
|
||||
@ -208,8 +208,8 @@ void calc_fps()
|
||||
// note: check close again so we aren't too loose if the function
|
||||
// comes closer to the average again (meaning it probably
|
||||
// wasn't really changing).
|
||||
if(same_side >= 2 && !close)
|
||||
bias += min(same_side, 4);
|
||||
if(same_side >= 2 && !is_close)
|
||||
bias += MIN(same_side, 4);
|
||||
}
|
||||
|
||||
// bias = 0: no change. > 0: increase (n-th root). < 0: decrease (^n)
|
||||
|
@ -19,6 +19,8 @@
|
||||
#ifndef TIMER_H
|
||||
#define TIMER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "sysdep/debug.h" // debug_out
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -26,9 +28,9 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// high resolution (> 1 µs) timestamp [s], starting at or near 0 s.
|
||||
extern double get_time();
|
||||
extern double get_time(void);
|
||||
|
||||
extern double timer_res();
|
||||
extern double timer_res(void);
|
||||
|
||||
// calculate fps (call once per frame)
|
||||
// several smooth filters (tuned for ~100 FPS)
|
||||
@ -36,13 +38,13 @@ extern double timer_res();
|
||||
|
||||
extern int fps;
|
||||
|
||||
extern void calc_fps();
|
||||
extern void calc_fps(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
class ScopedTimer
|
||||
{
|
||||
@ -71,8 +73,12 @@ public:
|
||||
|
||||
debug_out("TIMER %s: %g %cs\n", name.c_str(), dt*scale, unit);
|
||||
}
|
||||
|
||||
// no copy ctor, since some members are const
|
||||
private:
|
||||
ScopedTimer& operator=(const ScopedTimer&);
|
||||
};
|
||||
|
||||
#define TIMER(name) ScopedTimer name(#name);
|
||||
#define TIMER(name) ScopedTimer st##name##instance(#name);
|
||||
|
||||
#endif // #ifndef TIMER_H
|
||||
|
Loading…
Reference in New Issue
Block a user