Address some const-disregarding casts missed in r5540 due to conditional compilation settings and platforms.

git-svn-id: https://svn.eduke32.com/eduke32@5551 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2016-01-12 10:30:48 +00:00
parent da1081112c
commit 98ebda94ec
21 changed files with 67 additions and 60 deletions

View file

@ -80,11 +80,11 @@ void clearbufbyte(void *D, int32_t c, int32_t a);
void copybufbyte(const void *S, void *D, int32_t c); void copybufbyte(const void *S, void *D, int32_t c);
void copybufreverse(const void *S, void *D, int32_t c); void copybufreverse(const void *S, void *D, int32_t c);
static inline int32_t krecipasm(int32_t const i) static inline int32_t krecipasm(int32_t i)
{ {
// Ken did this // Ken did this
float f = (float const)i; float const f = (float const)i;
i = *(int32_t *)&f; i = *(int32_t const *)&f;
return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31)); return ((reciptable[(i >> 12) & 2047] >> (((i - 0x3f800000) >> 23) & 31)) ^ (i >> 31));
} }
#endif #endif

View file

@ -245,7 +245,8 @@ static inline void swap64bit(void *a, void *b)
static inline int32_t krecipasm(int32_t i) static inline int32_t krecipasm(int32_t i)
{ {
// Ken did this // Ken did this
float f = (float) i; i = *(int32_t *) &f; float const f = (float const)i;
i = *(int32_t const *)&f;
return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31)); return((reciptable[(i>>12)&2047]>>(((i-0x3f800000)>>23)&31))^(i>>31));
} }

View file

@ -10915,7 +10915,6 @@ void test_map(int32_t mode)
if ((!mode && cursectnum >= 0) || (mode && startsectnum >= 0)) if ((!mode && cursectnum >= 0) || (mode && startsectnum >= 0))
{ {
char const *param = " -map " PLAYTEST_MAPNAME " -noinstancechecking"; char const *param = " -map " PLAYTEST_MAPNAME " -noinstancechecking";
char *fullparam;
char current_cwd[BMAX_PATH]; char current_cwd[BMAX_PATH];
int32_t slen = 0; int32_t slen = 0;
BFILE *fp; BFILE *fp;
@ -10930,14 +10929,14 @@ void test_map(int32_t mode)
fclose(fp); fclose(fp);
else else
{ {
char const * lastslash = (char const *)Bstrrchr(mapster32_fullpath, '/');
#ifdef _WIN32 #ifdef _WIN32
fullparam = (char *)Bstrrchr(mapster32_fullpath, '\\'); char const * lastbackslash = (char const *)Bstrrchr(mapster32_fullpath, '\\');
#else lastslash = max(lastslash, lastbackslash);
fullparam = (char *)Bstrrchr(mapster32_fullpath, '/');
#endif #endif
if (fullparam) if (lastslash)
{ {
slen = fullparam-mapster32_fullpath+1; slen = lastslash-mapster32_fullpath+1;
Bstrncpy(game_executable, mapster32_fullpath, slen); Bstrncpy(game_executable, mapster32_fullpath, slen);
Bstrncpy(game_executable+slen, DefaultGameExec, sizeof(game_executable)-slen); Bstrncpy(game_executable+slen, DefaultGameExec, sizeof(game_executable)-slen);
} }
@ -10955,7 +10954,7 @@ void test_map(int32_t mode)
// and a possible extra space not in testplay_addparam, // and a possible extra space not in testplay_addparam,
// the length should be Bstrlen(game_executable)+Bstrlen(param)+(slen+1)+2+1. // the length should be Bstrlen(game_executable)+Bstrlen(param)+(slen+1)+2+1.
fullparam = (char *)Xmalloc(Bstrlen(game_executable)+Bstrlen(param)+slen+4); char *fullparam = (char *)Xmalloc(Bstrlen(game_executable)+Bstrlen(param)+slen+4);
Bsprintf(fullparam,"\"%s\"",game_executable); Bsprintf(fullparam,"\"%s\"",game_executable);
if (testplay_addparam) if (testplay_addparam)

View file

@ -2955,7 +2955,7 @@ jwzgles_glTexImage2D (GLenum target,
GLenum type, GLenum type,
const GLvoid *data) const GLvoid *data)
{ {
GLvoid *d2 = (GLvoid *) data; GLvoid *d2 = NULL;
Assert (!state->compiling_verts, "glTexImage2D not allowed inside glBegin"); Assert (!state->compiling_verts, "glTexImage2D not allowed inside glBegin");
Assert (!state->compiling_list, /* technically legal, but stupid! */ Assert (!state->compiling_list, /* technically legal, but stupid! */
"glTexImage2D not allowed inside glNewList"); "glTexImage2D not allowed inside glNewList");
@ -2974,7 +2974,7 @@ jwzgles_glTexImage2D (GLenum target,
/* GLES does not let us omit the data pointer to create a blank texture. */ /* GLES does not let us omit the data pointer to create a blank texture. */
if (! data) if (! data)
{ {
d2 = (GLvoid *) calloc (1, width * height * sizeof(GLfloat) * 4); data = d2 = (GLvoid *) calloc (1, width * height * sizeof(GLfloat) * 4);
Assert (d2, "out of memory"); Assert (d2, "out of memory");
} }
@ -2987,12 +2987,12 @@ jwzgles_glTexImage2D (GLenum target,
LOG10 ("direct %-12s %s %d %s %d %d %d %s %s 0x%lX", "glTexImage2D", LOG10 ("direct %-12s %s %d %s %d %d %d %s %s 0x%lX", "glTexImage2D",
mode_desc(target), level, mode_desc(internalFormat), mode_desc(target), level, mode_desc(internalFormat),
width, height, border, mode_desc(format), mode_desc(type), width, height, border, mode_desc(format), mode_desc(type),
(unsigned long) d2); (unsigned long) data);
glTexImage2D (target, level, internalFormat, width, height, border, glTexImage2D (target, level, internalFormat, width, height, border,
format, type, d2); /* the real one */ format, type, data); /* the real one */
CHECK("glTexImage2D"); CHECK("glTexImage2D");
if (d2 != data) free (d2); free (d2);
} }
void void
@ -3258,7 +3258,7 @@ jwzgles_gluBuild2DMipmaps (GLenum target,
int w2 = to_pow2(width); int w2 = to_pow2(width);
int h2 = to_pow2(height); int h2 = to_pow2(height);
void *d2 = (void *) data; void *d2 = NULL;
/* OpenGLES no longer supports "4" as a synonym for "RGBA". */ /* OpenGLES no longer supports "4" as a synonym for "RGBA". */
switch (internalFormat) { switch (internalFormat) {
@ -3283,10 +3283,10 @@ jwzgles_gluBuild2DMipmaps (GLenum target,
int ibpl = istride * width; int ibpl = istride * width;
int obpl = ostride * w2; int obpl = ostride * w2;
int oy; int oy;
const unsigned char *in = (unsigned char *) data; const unsigned char *in = (const unsigned char *) data;
unsigned char *out = (unsigned char *) malloc (h2 * obpl); unsigned char *out = (unsigned char *) malloc (h2 * obpl);
Assert (out, "out of memory"); Assert (out, "out of memory");
d2 = out; data = d2 = out;
for (oy = 0; oy < h2; oy++) for (oy = 0; oy < h2; oy++)
{ {
@ -3312,8 +3312,8 @@ jwzgles_gluBuild2DMipmaps (GLenum target,
} }
jwzgles_glTexImage2D (target, 0, internalFormat, w2, h2, 0, jwzgles_glTexImage2D (target, 0, internalFormat, w2, h2, 0,
format, type, d2); format, type, data);
if (d2 != data) free (d2); free (d2);
return 0; return 0;
} }

View file

@ -2745,7 +2745,7 @@ int32_t kzfindfile(char *filnam)
#else #else
if (!hfind) if (!hfind)
{ {
char *s = "."; char const *s = ".";
if (wildstpathleng > 0) if (wildstpathleng > 0)
{ {
filnam[wildstpathleng] = 0; filnam[wildstpathleng] = 0;

View file

@ -714,9 +714,10 @@ int32_t initinput(void)
#endif #endif
#if defined EDUKE32_OSX #if defined EDUKE32_OSX
static char sdl_has3buttonmouse[] = "SDL_HAS3BUTTONMOUSE=1";
// force OS X to operate in >1 button mouse mode so that LMB isn't adulterated // force OS X to operate in >1 button mouse mode so that LMB isn't adulterated
if (!getenv("SDL_HAS3BUTTONMOUSE")) if (!getenv("SDL_HAS3BUTTONMOUSE"))
putenv("SDL_HAS3BUTTONMOUSE=1"); putenv(sdl_has3buttonmouse);
#endif #endif
if (!keyremapinit) if (!keyremapinit)

View file

@ -136,7 +136,7 @@ static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpo
static GdkPixbuf *load_banner(void) static GdkPixbuf *load_banner(void)
{ {
return gdk_pixbuf_from_pixdata((GdkPixdata*)&startbanner_pixdata, FALSE, NULL); return gdk_pixbuf_from_pixdata((GdkPixdata const *)&startbanner_pixdata, FALSE, NULL);
} }
static void SetPage(int32_t n) static void SetPage(int32_t n)

View file

@ -234,13 +234,13 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
ZeroMemory(&tab, sizeof(tab)); ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = Bstrdup(TEXT("Setup")); static char textSetup[] = TEXT("Setup");
tab.pszText = textSetup;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab);
Bfree(tab.pszText);
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = Bstrdup(TEXT("Message Log")); static char textMessageLog[] = TEXT("Message Log");
tab.pszText = textMessageLog;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab);
Bfree(tab.pszText);
// Work out the position and size of the area inside the tab control for the pages // Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r)); ZeroMemory(&r, sizeof(r));
GetClientRect(hwnd, &r); GetClientRect(hwnd, &r);

View file

@ -185,7 +185,7 @@ static int32_t joyblast=0;
static struct static struct
{ {
char *name; char const *name;
LPDIRECTINPUTDEVICE7A *did; LPDIRECTINPUTDEVICE7A *did;
LPCDIDATAFORMAT df; LPCDIDATAFORMAT df;
} devicedef = { "joystick", &lpDID, &c_dfDIJoystick }; } devicedef = { "joystick", &lpDID, &c_dfDIJoystick };
@ -731,7 +731,7 @@ int32_t handleevents(void)
} }
void switchlayout(char * layout) void switchlayout(char const * layout)
{ {
char layoutname[KL_NAMELENGTH]; char layoutname[KL_NAMELENGTH];
@ -2802,10 +2802,10 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp)
GLubyte *p,*p2,*p3; GLubyte *p,*p2,*p3;
int32_t err = 0; int32_t err = 0;
glinfo.vendor = (char *)bglGetString(GL_VENDOR); glinfo.vendor = (char const *)bglGetString(GL_VENDOR);
glinfo.renderer = (char *)bglGetString(GL_RENDERER); glinfo.renderer = (char const *)bglGetString(GL_RENDERER);
glinfo.version = (char *)bglGetString(GL_VERSION); glinfo.version = (char const *)bglGetString(GL_VERSION);
glinfo.extensions = (char *)bglGetString(GL_EXTENSIONS); glinfo.extensions = (char const *)bglGetString(GL_EXTENSIONS);
// GL driver blacklist // GL driver blacklist

View file

@ -139,7 +139,7 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL
#ifdef HAS_INET_NTOP #ifdef HAS_INET_NTOP
if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL)
#else #else
char * addr = inet_ntoa (* (struct in_addr *) & address -> host); char * addr = inet_ntoa (* (struct in_addr const *) & address -> host);
if (addr != NULL) if (addr != NULL)
{ {
size_t addrLen = strlen(addr); size_t addrLen = strlen(addr);

View file

@ -9889,10 +9889,11 @@ const char **g_elModules;
static void G_AddDemo(const char* param) static void G_AddDemo(const char* param)
{ {
char * colon = (char *)Bstrchr(param, ':'); Bstrncpy(tempbuf, param, sizeof(tempbuf));
char * colon = (char *)Bstrchr(tempbuf, ':');
int32_t framespertic=-1, numrepeats=1; int32_t framespertic=-1, numrepeats=1;
if (colon && colon != param) if (colon && colon != tempbuf)
{ {
// -d<filename>:<num>[,<num>] // -d<filename>:<num>[,<num>]
// profiling options // profiling options
@ -9900,7 +9901,7 @@ static void G_AddDemo(const char* param)
Bsscanf(colon, "%u,%u", &framespertic, &numrepeats); Bsscanf(colon, "%u,%u", &framespertic, &numrepeats);
} }
Demo_SetFirst(param); Demo_SetFirst(tempbuf);
if (framespertic < 0) if (framespertic < 0)
{ {

View file

@ -318,7 +318,7 @@ static playbackstatus MV_GetNextVorbisBlock(VoiceNode *voice)
#ifdef GEKKO #ifdef GEKKO
// If libtremor had the three additional ov_read() parameters that libvorbis has, // If libtremor had the three additional ov_read() parameters that libvorbis has,
// this would be better handled using the endianness parameter. // this would be better handled using the endianness parameter.
int16_t *data = (int16_t *)(voice->sound); // assumes signed 16-bit int16_t *data = (int16_t *)(vd->block); // assumes signed 16-bit
for (bytesread = 0; bytesread < BLOCKSIZE / 2; ++bytesread) for (bytesread = 0; bytesread < BLOCKSIZE / 2; ++bytesread)
data[bytesread] = (data[bytesread] & 0xff) << 8 | ((data[bytesread] & 0xff00) >> 8); data[bytesread] = (data[bytesread] & 0xff) << 8 | ((data[bytesread] & 0xff00) >> 8);
#endif #endif

View file

@ -55,9 +55,9 @@ static int8_t external_midi_restart=0;
#endif #endif
#ifdef __ANDROID__ //TODO fix #ifdef __ANDROID__ //TODO fix
static char *external_midi_tempfn = "eduke32-music.mid"; static char const *external_midi_tempfn = "eduke32-music.mid";
#else #else
static char *external_midi_tempfn = "/tmp/eduke32-music.mid"; static char const *external_midi_tempfn = "/tmp/eduke32-music.mid";
#endif #endif
static int32_t external_midi = 0; static int32_t external_midi = 0;

View file

@ -258,7 +258,7 @@ static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpo
static GdkPixbuf *load_banner(void) static GdkPixbuf *load_banner(void)
{ {
return gdk_pixbuf_from_pixdata((GdkPixdata*)&startbanner_pixdata, FALSE, NULL); return gdk_pixbuf_from_pixdata((GdkPixdata const *)&startbanner_pixdata, FALSE, NULL);
} }
static void SetPage(int32_t n) static void SetPage(int32_t n)
@ -444,7 +444,7 @@ static void PopulateForm(unsigned char pgs)
for (grpfile_t const * fg = foundgrps; fg; fg=fg->next) for (grpfile_t const * fg = foundgrps; fg; fg=fg->next)
{ {
gtk_list_store_append(list, &iter); gtk_list_store_append(list, &iter);
gtk_list_store_set(list, &iter, 0, fg->type->name, 1, fg->filename, 2, (gpointer)fg, -1); gtk_list_store_set(list, &iter, 0, fg->type->name, 1, fg->filename, 2, (void const *)fg, -1);
if (settings.grp == fg) if (settings.grp == fg)
{ {
GtkTreeSelection *sel = gtk_tree_view_get_selection(gamelist); GtkTreeSelection *sel = gtk_tree_view_get_selection(gamelist);

View file

@ -499,13 +499,13 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
ZeroMemory(&tab, sizeof(tab)); ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = Bstrdup(TEXT("Setup")); static char textSetup[] = TEXT("Setup");
tab.pszText = textSetup;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
Bfree(tab.pszText);
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = Bstrdup(TEXT("Message Log")); static char textMessageLog[] = TEXT("Message Log");
tab.pszText = textMessageLog;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
Bfree(tab.pszText);
// Work out the position and size of the area inside the tab control for the pages // Work out the position and size of the area inside the tab control for the pages
ZeroMemory(&r, sizeof(r)); ZeroMemory(&r, sizeof(r));

View file

@ -61,7 +61,7 @@ static int retval = -1, mode = TAB_MESSAGES;
static GdkPixbuf *load_banner(void) static GdkPixbuf *load_banner(void)
{ {
extern const GdkPixdata startbanner_pixdata; extern const GdkPixdata startbanner_pixdata;
return gdk_pixbuf_from_pixdata(&startbanner_pixdata, FALSE, NULL); return gdk_pixbuf_from_pixdata((GdkPixdata const *)&startbanner_pixdata, FALSE, NULL);
} }
static void SetPage(int n) static void SetPage(int n)

View file

@ -353,13 +353,16 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
ZeroMemory(&tab, sizeof(tab)); ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Configuration"); static char textConfiguration[] = TEXT("Configuration")
tab.pszText = textConfiguration;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_CONFIG, (LPARAM)&tab);
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Game"); static char textGame[] = TEXT("Game")
tab.pszText = textGame;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_GAME, (LPARAM)&tab);
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Messages"); static char textMessages[] = TEXT("Messages");
tab.pszText = textMessages;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)TAB_MESSAGES, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages // Work out the position and size of the area inside the tab control for the pages

View file

@ -46,10 +46,10 @@ static int32_t setsprite_eyeheight(int16_t spritenum, const vec3_t *pos)
void initsb(char,char,int,char,char,char,char); void initsb(char,char,int,char,char,char,char);
void uninitsb(void); void uninitsb(void);
void setears(int,int,int,int); void setears(int,int,int,int);
void wsayfollow(char *,int,int,int *,int *,char); void wsayfollow(char const *,int,int,int *,int *,char);
void wsay(char *,int,int,int); void wsay(char const *,int,int,int);
void loadwaves(void); void loadwaves(void);
void loadsong(char *); void loadsong(char const *);
void musicon(void); void musicon(void);
void musicoff(void); void musicoff(void);
void refreshaudio(void); void refreshaudio(void);

View file

@ -24,7 +24,7 @@ void setears(int daposx, int daposy, int daxvect, int dayvect)
UNREFERENCED_PARAMETER(dayvect); UNREFERENCED_PARAMETER(dayvect);
} }
void wsayfollow(char *dafilename, int dafreq, int davol, int *daxplc, int *dayplc, char followstat) void wsayfollow(char const *dafilename, int dafreq, int davol, int *daxplc, int *dayplc, char followstat)
{ {
UNREFERENCED_PARAMETER(dafilename); UNREFERENCED_PARAMETER(dafilename);
UNREFERENCED_PARAMETER(dafreq); UNREFERENCED_PARAMETER(dafreq);
@ -34,7 +34,7 @@ void wsayfollow(char *dafilename, int dafreq, int davol, int *daxplc, int *daypl
UNREFERENCED_PARAMETER(followstat); UNREFERENCED_PARAMETER(followstat);
} }
void wsay(char *dafilename, int dafreq, int volume1, int volume2) void wsay(char const *dafilename, int dafreq, int volume1, int volume2)
{ {
UNREFERENCED_PARAMETER(dafilename); UNREFERENCED_PARAMETER(dafilename);
UNREFERENCED_PARAMETER(dafreq); UNREFERENCED_PARAMETER(dafreq);
@ -46,7 +46,7 @@ void loadwaves(void)
{ {
} }
void loadsong(char *filename) void loadsong(char const *filename)
{ {
UNREFERENCED_PARAMETER(filename); UNREFERENCED_PARAMETER(filename);
} }

View file

@ -53,7 +53,7 @@ static int retval = -1, mode = TAB_MESSAGES;
static GdkPixbuf *load_banner(void) static GdkPixbuf *load_banner(void)
{ {
return gdk_pixbuf_from_pixdata((GdkPixdata *)&startbanner_pixdata, FALSE, NULL); return gdk_pixbuf_from_pixdata((GdkPixdata const *)&startbanner_pixdata, FALSE, NULL);
} }
static void SetPage(int n) static void SetPage(int n)

View file

@ -203,10 +203,12 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam,
ZeroMemory(&tab, sizeof(tab)); ZeroMemory(&tab, sizeof(tab));
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Configuration"); static char textConfiguration[] = TEXT("Configuration");
tab.pszText = textConfiguration;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab);
tab.mask = TCIF_TEXT; tab.mask = TCIF_TEXT;
tab.pszText = TEXT("Messages"); static char textMessages[] = TEXT("Messages");
tab.pszText = textMessages;
SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab); SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab);
// Work out the position and size of the area inside the tab control for the pages // Work out the position and size of the area inside the tab control for the pages