diff --git a/polymer/eduke32/build/include/pragmas_arm.h b/polymer/eduke32/build/include/pragmas_arm.h index 78ddc9bf1..bdab85add 100644 --- a/polymer/eduke32/build/include/pragmas_arm.h +++ b/polymer/eduke32/build/include/pragmas_arm.h @@ -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 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 - float f = (float const)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)); } #endif diff --git a/polymer/eduke32/build/include/pragmas_ppc.h b/polymer/eduke32/build/include/pragmas_ppc.h index 8bb9025dc..0b9c2f870 100644 --- a/polymer/eduke32/build/include/pragmas_ppc.h +++ b/polymer/eduke32/build/include/pragmas_ppc.h @@ -245,7 +245,8 @@ static inline void swap64bit(void *a, void *b) static inline int32_t krecipasm(int32_t i) { // 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)); } diff --git a/polymer/eduke32/build/src/build.c b/polymer/eduke32/build/src/build.c index 19894652b..6cfd8f9e9 100644 --- a/polymer/eduke32/build/src/build.c +++ b/polymer/eduke32/build/src/build.c @@ -10915,7 +10915,6 @@ void test_map(int32_t mode) if ((!mode && cursectnum >= 0) || (mode && startsectnum >= 0)) { char const *param = " -map " PLAYTEST_MAPNAME " -noinstancechecking"; - char *fullparam; char current_cwd[BMAX_PATH]; int32_t slen = 0; BFILE *fp; @@ -10930,14 +10929,14 @@ void test_map(int32_t mode) fclose(fp); else { + char const * lastslash = (char const *)Bstrrchr(mapster32_fullpath, '/'); #ifdef _WIN32 - fullparam = (char *)Bstrrchr(mapster32_fullpath, '\\'); -#else - fullparam = (char *)Bstrrchr(mapster32_fullpath, '/'); + char const * lastbackslash = (char const *)Bstrrchr(mapster32_fullpath, '\\'); + lastslash = max(lastslash, lastbackslash); #endif - if (fullparam) + if (lastslash) { - slen = fullparam-mapster32_fullpath+1; + slen = lastslash-mapster32_fullpath+1; Bstrncpy(game_executable, mapster32_fullpath, 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, // 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); if (testplay_addparam) diff --git a/polymer/eduke32/build/src/jwzgles.c b/polymer/eduke32/build/src/jwzgles.c index bfed5f181..3819576a6 100644 --- a/polymer/eduke32/build/src/jwzgles.c +++ b/polymer/eduke32/build/src/jwzgles.c @@ -2955,7 +2955,7 @@ jwzgles_glTexImage2D (GLenum target, GLenum type, const GLvoid *data) { - GLvoid *d2 = (GLvoid *) data; + GLvoid *d2 = NULL; Assert (!state->compiling_verts, "glTexImage2D not allowed inside glBegin"); Assert (!state->compiling_list, /* technically legal, but stupid! */ "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. */ 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"); } @@ -2987,12 +2987,12 @@ jwzgles_glTexImage2D (GLenum target, LOG10 ("direct %-12s %s %d %s %d %d %d %s %s 0x%lX", "glTexImage2D", mode_desc(target), level, mode_desc(internalFormat), width, height, border, mode_desc(format), mode_desc(type), - (unsigned long) d2); + (unsigned long) data); glTexImage2D (target, level, internalFormat, width, height, border, - format, type, d2); /* the real one */ + format, type, data); /* the real one */ CHECK("glTexImage2D"); - if (d2 != data) free (d2); + free (d2); } void @@ -3258,7 +3258,7 @@ jwzgles_gluBuild2DMipmaps (GLenum target, int w2 = to_pow2(width); int h2 = to_pow2(height); - void *d2 = (void *) data; + void *d2 = NULL; /* OpenGLES no longer supports "4" as a synonym for "RGBA". */ switch (internalFormat) { @@ -3283,10 +3283,10 @@ jwzgles_gluBuild2DMipmaps (GLenum target, int ibpl = istride * width; int obpl = ostride * w2; 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); Assert (out, "out of memory"); - d2 = out; + data = d2 = out; for (oy = 0; oy < h2; oy++) { @@ -3312,8 +3312,8 @@ jwzgles_gluBuild2DMipmaps (GLenum target, } jwzgles_glTexImage2D (target, 0, internalFormat, w2, h2, 0, - format, type, d2); - if (d2 != data) free (d2); + format, type, data); + free (d2); return 0; } diff --git a/polymer/eduke32/build/src/kplib.c b/polymer/eduke32/build/src/kplib.c index 067cf4293..985c32654 100644 --- a/polymer/eduke32/build/src/kplib.c +++ b/polymer/eduke32/build/src/kplib.c @@ -2745,7 +2745,7 @@ int32_t kzfindfile(char *filnam) #else if (!hfind) { - char *s = "."; + char const *s = "."; if (wildstpathleng > 0) { filnam[wildstpathleng] = 0; diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 1016ad32a..76b1fa789 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -714,9 +714,10 @@ int32_t initinput(void) #endif #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 if (!getenv("SDL_HAS3BUTTONMOUSE")) - putenv("SDL_HAS3BUTTONMOUSE=1"); + putenv(sdl_has3buttonmouse); #endif if (!keyremapinit) diff --git a/polymer/eduke32/build/src/startgtk.editor.c b/polymer/eduke32/build/src/startgtk.editor.c index eed4a7f4e..3d6200714 100644 --- a/polymer/eduke32/build/src/startgtk.editor.c +++ b/polymer/eduke32/build/src/startgtk.editor.c @@ -136,7 +136,7 @@ static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpo 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) diff --git a/polymer/eduke32/build/src/startwin.editor.c b/polymer/eduke32/build/src/startwin.editor.c index e983d0928..2b89b6fe4 100644 --- a/polymer/eduke32/build/src/startwin.editor.c +++ b/polymer/eduke32/build/src/startwin.editor.c @@ -234,13 +234,13 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, ZeroMemory(&tab, sizeof(tab)); 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); - Bfree(tab.pszText); 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); - Bfree(tab.pszText); // Work out the position and size of the area inside the tab control for the pages ZeroMemory(&r, sizeof(r)); GetClientRect(hwnd, &r); diff --git a/polymer/eduke32/build/src/winlayer.c b/polymer/eduke32/build/src/winlayer.c index ea0249715..fbd60828d 100644 --- a/polymer/eduke32/build/src/winlayer.c +++ b/polymer/eduke32/build/src/winlayer.c @@ -185,7 +185,7 @@ static int32_t joyblast=0; static struct { - char *name; + char const *name; LPDIRECTINPUTDEVICE7A *did; LPCDIDATAFORMAT df; } 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]; @@ -2802,10 +2802,10 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp) GLubyte *p,*p2,*p3; int32_t err = 0; - glinfo.vendor = (char *)bglGetString(GL_VENDOR); - glinfo.renderer = (char *)bglGetString(GL_RENDERER); - glinfo.version = (char *)bglGetString(GL_VERSION); - glinfo.extensions = (char *)bglGetString(GL_EXTENSIONS); + glinfo.vendor = (char const *)bglGetString(GL_VENDOR); + glinfo.renderer = (char const *)bglGetString(GL_RENDERER); + glinfo.version = (char const *)bglGetString(GL_VERSION); + glinfo.extensions = (char const *)bglGetString(GL_EXTENSIONS); // GL driver blacklist diff --git a/polymer/eduke32/source/enet/src/unix.c b/polymer/eduke32/source/enet/src/unix.c index 771a4abd6..e91dc15e4 100644 --- a/polymer/eduke32/source/enet/src/unix.c +++ b/polymer/eduke32/source/enet/src/unix.c @@ -139,7 +139,7 @@ enet_address_get_host_ip (const ENetAddress * address, char * name, size_t nameL #ifdef HAS_INET_NTOP if (inet_ntop (AF_INET, & address -> host, name, nameLength) == NULL) #else - char * addr = inet_ntoa (* (struct in_addr *) & address -> host); + char * addr = inet_ntoa (* (struct in_addr const *) & address -> host); if (addr != NULL) { size_t addrLen = strlen(addr); diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index df6186d7a..46165befe 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -9889,10 +9889,11 @@ const char **g_elModules; 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; - if (colon && colon != param) + if (colon && colon != tempbuf) { // -d:[,] // profiling options @@ -9900,7 +9901,7 @@ static void G_AddDemo(const char* param) Bsscanf(colon, "%u,%u", &framespertic, &numrepeats); } - Demo_SetFirst(param); + Demo_SetFirst(tempbuf); if (framespertic < 0) { diff --git a/polymer/eduke32/source/jaudiolib/src/vorbis.c b/polymer/eduke32/source/jaudiolib/src/vorbis.c index ced829f47..68b615dae 100644 --- a/polymer/eduke32/source/jaudiolib/src/vorbis.c +++ b/polymer/eduke32/source/jaudiolib/src/vorbis.c @@ -318,7 +318,7 @@ static playbackstatus MV_GetNextVorbisBlock(VoiceNode *voice) #ifdef GEKKO // If libtremor had the three additional ov_read() parameters that libvorbis has, // 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) data[bytesread] = (data[bytesread] & 0xff) << 8 | ((data[bytesread] & 0xff00) >> 8); #endif diff --git a/polymer/eduke32/source/sdlmusic.c b/polymer/eduke32/source/sdlmusic.c index 477de1454..faa66fc30 100644 --- a/polymer/eduke32/source/sdlmusic.c +++ b/polymer/eduke32/source/sdlmusic.c @@ -55,9 +55,9 @@ static int8_t external_midi_restart=0; #endif #ifdef __ANDROID__ //TODO fix -static char *external_midi_tempfn = "eduke32-music.mid"; +static char const *external_midi_tempfn = "eduke32-music.mid"; #else -static char *external_midi_tempfn = "/tmp/eduke32-music.mid"; +static char const *external_midi_tempfn = "/tmp/eduke32-music.mid"; #endif static int32_t external_midi = 0; diff --git a/polymer/eduke32/source/startgtk.game.c b/polymer/eduke32/source/startgtk.game.c index 1657dc986..d9fa6edc6 100644 --- a/polymer/eduke32/source/startgtk.game.c +++ b/polymer/eduke32/source/startgtk.game.c @@ -258,7 +258,7 @@ static gboolean on_startwin_delete_event(GtkWidget *widget, GdkEvent *event, gpo 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) @@ -444,7 +444,7 @@ static void PopulateForm(unsigned char pgs) for (grpfile_t const * fg = foundgrps; fg; fg=fg->next) { 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) { GtkTreeSelection *sel = gtk_tree_view_get_selection(gamelist); diff --git a/polymer/eduke32/source/startwin.game.c b/polymer/eduke32/source/startwin.game.c index 3b9914ee4..44f938563 100644 --- a/polymer/eduke32/source/startwin.game.c +++ b/polymer/eduke32/source/startwin.game.c @@ -499,13 +499,13 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, ZeroMemory(&tab, sizeof(tab)); 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); - Bfree(tab.pszText); 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); - Bfree(tab.pszText); // Work out the position and size of the area inside the tab control for the pages ZeroMemory(&r, sizeof(r)); diff --git a/polymer/eduke32/source/sw/src/startgtk.game.c b/polymer/eduke32/source/sw/src/startgtk.game.c index 2c729919f..5ff43df37 100644 --- a/polymer/eduke32/source/sw/src/startgtk.game.c +++ b/polymer/eduke32/source/sw/src/startgtk.game.c @@ -61,7 +61,7 @@ static int retval = -1, mode = TAB_MESSAGES; static GdkPixbuf *load_banner(void) { 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) diff --git a/polymer/eduke32/source/sw/src/startwin.game.c b/polymer/eduke32/source/sw/src/startwin.game.c index 67e519b86..024f2f599 100644 --- a/polymer/eduke32/source/sw/src/startwin.game.c +++ b/polymer/eduke32/source/sw/src/startwin.game.c @@ -353,13 +353,16 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, ZeroMemory(&tab, sizeof(tab)); 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); 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); 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); // Work out the position and size of the area inside the tab control for the pages diff --git a/polymer/eduke32/source/testgame/src/game.c b/polymer/eduke32/source/testgame/src/game.c index 4d0989f2b..b1564404d 100644 --- a/polymer/eduke32/source/testgame/src/game.c +++ b/polymer/eduke32/source/testgame/src/game.c @@ -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 uninitsb(void); void setears(int,int,int,int); -void wsayfollow(char *,int,int,int *,int *,char); -void wsay(char *,int,int,int); +void wsayfollow(char const *,int,int,int *,int *,char); +void wsay(char const *,int,int,int); void loadwaves(void); -void loadsong(char *); +void loadsong(char const *); void musicon(void); void musicoff(void); void refreshaudio(void); diff --git a/polymer/eduke32/source/testgame/src/sound_stub.c b/polymer/eduke32/source/testgame/src/sound_stub.c index b32d36de3..8e2c3dd40 100644 --- a/polymer/eduke32/source/testgame/src/sound_stub.c +++ b/polymer/eduke32/source/testgame/src/sound_stub.c @@ -24,7 +24,7 @@ void setears(int daposx, int daposy, int daxvect, int 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(dafreq); @@ -34,7 +34,7 @@ void wsayfollow(char *dafilename, int dafreq, int davol, int *daxplc, int *daypl 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(dafreq); @@ -46,7 +46,7 @@ void loadwaves(void) { } -void loadsong(char *filename) +void loadsong(char const *filename) { UNREFERENCED_PARAMETER(filename); } diff --git a/polymer/eduke32/source/testgame/src/startgtk.game.c b/polymer/eduke32/source/testgame/src/startgtk.game.c index 90689cb20..4c19f71ed 100644 --- a/polymer/eduke32/source/testgame/src/startgtk.game.c +++ b/polymer/eduke32/source/testgame/src/startgtk.game.c @@ -53,7 +53,7 @@ static int retval = -1, mode = TAB_MESSAGES; 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) diff --git a/polymer/eduke32/source/testgame/src/startwin.game.c b/polymer/eduke32/source/testgame/src/startwin.game.c index 918b9316a..5ea8e8bd0 100644 --- a/polymer/eduke32/source/testgame/src/startwin.game.c +++ b/polymer/eduke32/source/testgame/src/startwin.game.c @@ -203,10 +203,12 @@ static INT_PTR CALLBACK startup_dlgproc(HWND hwndDlg, UINT uMsg, WPARAM wParam, ZeroMemory(&tab, sizeof(tab)); tab.mask = TCIF_TEXT; - tab.pszText = TEXT("Configuration"); + static char textConfiguration[] = TEXT("Configuration"); + tab.pszText = textConfiguration; SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)0, (LPARAM)&tab); tab.mask = TCIF_TEXT; - tab.pszText = TEXT("Messages"); + static char textMessages[] = TEXT("Messages"); + tab.pszText = textMessages; SendMessage(hwnd, TCM_INSERTITEM, (WPARAM)1, (LPARAM)&tab); // Work out the position and size of the area inside the tab control for the pages