Cleaned up gcc compiler warning : ISO C++ forbids converting a string constant to ‘char*’ [-Wwrite-strings]

This commit is contained in:
Matthew Budd 2020-06-19 23:58:12 -04:00
parent 309e30bea6
commit 7919071a25
25 changed files with 54 additions and 50 deletions

View File

@ -40,7 +40,7 @@ typedef struct {
struct CHEATF {
struct CHEATF *next;
char *name = "";
char *name;
uint16 addr;
uint8 val;
int compare; /* -1 for no compare. */
@ -65,4 +65,4 @@ struct SEARCHPOSSIBLE {
#define FCEU_SEARCH_NEWVAL_GT_KNOWN 7
#define FCEU_SEARCH_NEWVAL_LT_KNOWN 8
#endif
#endif

View File

@ -23,7 +23,7 @@ ArchiveScanRecord FCEUD_ScanArchive(std::string fname);
const char *FCEUD_GetCompilerString();
//This makes me feel dirty for some reason.
void FCEU_printf(char *format, ...);
void FCEU_printf(const char *format, ...);
#define FCEUI_printf FCEU_printf
//Video interface
@ -183,7 +183,7 @@ void FCEUD_LuaRunFrom(void);
int32 FCEUI_GetDesiredFPS(void);
void FCEUI_SaveSnapshot(void);
void FCEUI_SaveSnapshotAs(void);
void FCEU_DispMessage(char *format, int disppos, ...);
void FCEU_DispMessage(const char *format, int disppos, ...);
#define FCEUI_DispMessage FCEU_DispMessage
int FCEUI_DecodePAR(const char *code, int *a, int *v, int *c, int *type);

View File

@ -176,7 +176,7 @@ int AddToList(char *text, uint32 id)
**/
typedef struct MENU {
char *text;
const char *text;
void *action;
int type; // 0 for menu, 1 for function.
} MENU;
@ -392,7 +392,7 @@ static void ShowRes(void)
}
}
static int ShowShortList(char *moe[], int n, int def)
static int ShowShortList(const char *moe[], int n, int def)
{
int x,c;
int baa; //mbg merge 7/17/06 made to normal int
@ -430,7 +430,7 @@ static void DoSearch(void)
{
static int v1=0,v2=0;
static int method=0;
char *m[9]={"O==V1 && C==V2",
const char *m[9]={"O==V1 && C==V2",
"O==V1 && |O-C|==V2",
"|O-C|==V2",
"O!=C",

View File

@ -102,7 +102,7 @@ LoadCPalette(const std::string &file)
static void
CreateDirs(const std::string &dir)
{
char *subs[8]={"fcs","snaps","gameinfo","sav","cheats","movies","cfg.d"};
const char *subs[8]={"fcs","snaps","gameinfo","sav","cheats","movies","cfg.d"};
std::string subdir;
int x;

View File

@ -1808,7 +1808,7 @@ void ConfigDevice (int which, int arg)
char buf[256];
int x;
std::string prefix;
char *str[10] =
const char *str[10] =
{ "A", "B", "SELECT", "START", "UP", "DOWN", "LEFT", "RIGHT", "Rapid A",
"Rapid B"
};

View File

@ -493,12 +493,12 @@ FILE *FCEUD_UTF8fopen(const char *fn, const char *mode)
return(fopen(fn,mode));
}
static char *s_linuxCompilerString = "g++ " __VERSION__;
static const char *s_linuxCompilerString = "g++ " __VERSION__;
/**
* Returns the compiler string.
*/
const char *FCEUD_GetCompilerString() {
return (const char *)s_linuxCompilerString;
return s_linuxCompilerString;
}
/**
@ -590,7 +590,7 @@ int main(int argc, char *argv[])
else if(strcmp(argv[i], "--nogui") == 0)
{
noGui = 1;
argv[i] = "";
//argv[i] = "";
}
#endif
}

View File

@ -117,7 +117,7 @@ FCEUD_NetworkConnect(void)
TSocket = socket(AF_INET, SOCK_STREAM, 0);
if(TSocket < 0) {
char* s = "Error creating stream socket.";
const char* s = "Error creating stream socket.";
puts(s);
FCEU_DispMessage(s,0);
FCEUD_NetworkClose();

View File

@ -980,7 +980,8 @@ void FCEU_ResetVidSys(void) {
FCEUS FSettings;
void FCEU_printf(char *format, ...) {
void FCEU_printf(const char *format, ...)
{
char temp[2048];
va_list ap;
@ -999,7 +1000,8 @@ void FCEU_printf(char *format, ...) {
va_end(ap);
}
void FCEU_PrintError(char *format, ...) {
void FCEU_PrintError(const char *format, ...)
{
char temp[2048];
va_list ap;

View File

@ -133,10 +133,10 @@ extern FCEUS FSettings;
bool CheckFileExists(const char* filename); //Receives a filename (fullpath) and checks to see if that file exists
void FCEU_PrintError(char *format, ...);
void FCEU_printf(char *format, ...);
void FCEU_DispMessage(char *format, int disppos, ...);
void FCEU_DispMessageOnMovie(char *format, ...);
void FCEU_PrintError(const char *format, ...);
void FCEU_printf(const char *format, ...);
void FCEU_DispMessage(const char *format, int disppos, ...);
void FCEU_DispMessageOnMovie(const char *format, ...);
void FCEU_TogglePPU();
void SetNESDeemph_OldHacky(uint8 d, int force);

View File

@ -260,7 +260,7 @@ zpfail:
return 0;
}
FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext, int index, const char** extensions, int* userCancel)
FCEUFILE * FCEU_fopen(const char *path, const char *ipsfn, const char *mode, char *ext, int index, const char** extensions, int* userCancel)
{
FILE *ipsfile=0;
FCEUFILE *fceufp=0;

View File

@ -122,7 +122,7 @@ struct ArchiveScanRecord
};
FCEUFILE *FCEU_fopen(const char *path, const char *ipsfn, char *mode, char *ext, int index=-1, const char** extensions = 0, int* userCancel = 0);
FCEUFILE *FCEU_fopen(const char *path, const char *ipsfn, const char *mode, char *ext, int index=-1, const char** extensions = 0, int* userCancel = 0);
bool FCEU_isFileInArchive(const char *path);
int FCEU_fclose(FCEUFILE*);
uint64 FCEU_fread(void *ptr, size_t size, size_t nmemb, FCEUFILE*);

View File

@ -233,7 +233,7 @@ static void SetInput(void) {
struct BADINF {
uint64 md5partial;
char *name;
const char *name;
uint32 type;
};
@ -417,7 +417,7 @@ static void CheckHInfo(void) {
if (tofix & 1)
sprintf(gigastr + strlen(gigastr), "The mapper number should be set to %d. ", MapperNo);
if (tofix & 2) {
char *mstr[3] = { "Horizontal", "Vertical", "Four-screen" };
const char *mstr[3] = { "Horizontal", "Vertical", "Four-screen" };
sprintf(gigastr + strlen(gigastr), "Mirroring should be set to \"%s\". ", mstr[Mirroring & 3]);
}
if (tofix & 4)
@ -839,7 +839,7 @@ int iNESLoad(const char *name, FCEUFILE *fp, int OverwriteVidMode) {
FCEU_printf("\n");
}
char* mappername = "Not Listed";
const char* mappername = "Not Listed";
for (int mappertest = 0; mappertest < (sizeof bmap / sizeof bmap[0]) - 1; mappertest++) {
if (bmap[mappertest].number == MapperNo) {

View File

@ -270,7 +270,7 @@ void Mapper254_Init(CartInfo *);
void Mapper406_Init(CartInfo *);
typedef struct {
char *name;
const char *name;
int32 number;
void (*init)(CartInfo *);
} BMAPPINGLocal;

View File

@ -295,7 +295,7 @@ struct EMUCMDTABLE
EMUCMDFN* fn_on;
EMUCMDFN* fn_off;
int state;
char* name;
const char* name;
int flags; //EMUCMDFLAG
};

View File

@ -515,6 +515,7 @@ static int emu_getdir(lua_State *L) {
return 1;
#endif
return 0;
}
@ -545,6 +546,7 @@ static int emu_loadrom(lua_State *L) {
return 1;
}
#endif
return 1;
}
@ -5227,7 +5229,7 @@ static int doPopup(lua_State *L, const char* deftype, const char* deficon) {
return 1;
#else
char *t;
const char *t;
#ifdef __linux
int pid; // appease compiler
@ -5285,9 +5287,9 @@ static int doPopup(lua_State *L, const char* deftype, const char* deficon) {
// I'm gonna be dead in a matter of microseconds anyways, so wasted memory doesn't matter to me.
// Go ahead and abuse strdup.
char * parameters[] = {"xmessage", "-buttons", t, strdup(str), NULL};
const char * parameters[] = {"xmessage", "-buttons", t, strdup(str), NULL};
execvp("xmessage", parameters);
execvp("xmessage", (char* const*)parameters);
// Aw shitty
perror("exec xmessage");

View File

@ -2000,7 +2000,7 @@ void ProcessSubtitles(void)
}
}
void FCEU_DisplaySubtitles(char *format, ...)
void FCEU_DisplaySubtitles(const char *format, ...)
{
va_list ap;

View File

@ -309,7 +309,7 @@ void FCEUI_ToggleInputDisplay(void);
void LoadSubtitles(MovieData &);
void ProcessSubtitles(void);
void FCEU_DisplaySubtitles(char *format, ...);
void FCEU_DisplaySubtitles(const char *format, ...);
void poweron(bool shouldDisableBatteryLoading);

View File

@ -262,7 +262,7 @@ int NSFLoad(const char *name, FCEUFILE *fp)
FCEU_printf(" Name: %s\n Artist: %s\n Copyright: %s\n\n",NSFHeader.SongName,NSFHeader.Artist,NSFHeader.Copyright);
if(NSFHeader.SoundChip)
{
static char *tab[6]={"Konami VRCVI","Konami VRCVII","Nintendo FDS","Nintendo MMC5","Namco 106","Sunsoft FME-07"};
static const char *tab[6]={"Konami VRCVI","Konami VRCVII","Nintendo FDS","Nintendo MMC5","Namco 106","Sunsoft FME-07"};
for(x=0;x<6;x++)
if(NSFHeader.SoundChip&(1<<x))

View File

@ -848,7 +848,7 @@ void ResetExState(void (*PreSave)(void), void (*PostSave)(void))
for(x=0;x<SFEXINDEX;x++)
{
if(SFMDATA[x].desc)
free(SFMDATA[x].desc);
free( (void*)SFMDATA[x].desc);
}
// adelikat, 3/14/09: had to add this to clear out the size parameter. NROM(mapper 0) games were having savestate crashes if loaded after a non NROM game because the size variable was carrying over and causing savestates to save too much data
SFMDATA[0].s = 0;
@ -858,7 +858,7 @@ void ResetExState(void (*PreSave)(void), void (*PostSave)(void))
SFEXINDEX=0;
}
void AddExState(void *v, uint32 s, int type, char *desc)
void AddExState(void *v, uint32 s, int type, const char *desc)
{
if(s==~0)
{
@ -885,8 +885,8 @@ void AddExState(void *v, uint32 s, int type, char *desc)
if(desc)
{
SFMDATA[SFEXINDEX].desc=(char *)FCEU_malloc(strlen(desc)+1);
strcpy(SFMDATA[SFEXINDEX].desc,desc);
SFMDATA[SFEXINDEX].desc=(const char *)FCEU_malloc(strlen(desc)+1);
strcpy( (char*)SFMDATA[SFEXINDEX].desc,desc);
}
else
SFMDATA[SFEXINDEX].desc=0;

View File

@ -44,11 +44,11 @@ struct SFORMAT
uint32 s;
//a string description of the element
char *desc;
const char *desc;
};
void ResetExState(void (*PreSave)(void),void (*PostSave)(void));
void AddExState(void *v, uint32 s, int type, char *desc);
void AddExState(void *v, uint32 s, int type, const char *desc);
//indicates that the value is a multibyte integer that needs to be put in the correct byte order
#define FCEUSTATE_RLSB 0x80000000

View File

@ -45,13 +45,13 @@ typedef struct {
} UNIF_HEADER;
typedef struct {
char *name;
const char *name;
void (*init)(CartInfo *);
int flags;
} BMAPPING;
typedef struct {
char *name;
const char *name;
int (*init)(FCEUFILE *fp);
} BFMAPPING;
@ -129,7 +129,7 @@ static int DoMirroring(FCEUFILE *fp) {
return(0);
mirrortodo = t;
{
static char *stuffo[6] = { "Horizontal", "Vertical", "$2000", "$2400", "\"Four-screen\"", "Controlled by Mapper Hardware" };
static const char *stuffo[6] = { "Horizontal", "Vertical", "$2000", "$2400", "\"Four-screen\"", "Controlled by Mapper Hardware" };
if (t < 6)
FCEU_printf(" Name/Attribute Table Mirroring: %s\n", stuffo[t]);
}
@ -190,7 +190,7 @@ static int DINF(FCEUFILE *fp) {
FCEU_printf(" Dumped by: %s\n", name);
FCEU_printf(" Dumped with: %s\n", method);
{
char *months[12] = {
const char *months[12] = {
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
};
@ -232,7 +232,7 @@ static int TVCI(FCEUFILE *fp) {
if ((t = FCEU_fgetc(fp)) == EOF)
return(0);
if (t <= 2) {
char *stuffo[3] = { "NTSC", "PAL", "NTSC and PAL" };
const char *stuffo[3] = { "NTSC", "PAL", "NTSC and PAL" };
if (t == 0) {
GameInfo->vidsys = GIV_NTSC;
FCEUI_SetVidSystem(0);

View File

@ -157,7 +157,7 @@ int chr_replace(char *str, char search, char replace) {
///Replaces all instances of 'search' with 'replace'
///Returns number of sub-strings modified, or -1 on error
int str_replace(char *str, char *search, char *replace) {
int str_replace(char *str, const char *search, const char *replace) {
unsigned int i=0,j=0; //mbg merge 7/17/06 changed to unsigned int
int searchlen,replacelen;
char *astr;

View File

@ -43,7 +43,7 @@ int str_ltrim(char *str, int flags);
int str_rtrim(char *str, int flags);
int str_strip(char *str, int flags);
int chr_replace(char *str, char search, char replace);
int str_replace(char *str, char *search, char *replace);
int str_replace(char *str, const char *search, const char *replace);
int HexStringToBytesLength(const std::string& str);
int Base64StringToBytesLength(const std::string& str);
@ -129,4 +129,4 @@ std::string wcstombs(std::wstring str);
std::string getExtension(const char* input);
std::string StripExtension(std::string filename);
std::string StripPath(std::string filename);
std::string StripPath(std::string filename);

View File

@ -398,7 +398,7 @@ void snapAVI()
FCEUI_AviVideoUpdate(XBuf);
}
void FCEU_DispMessageOnMovie(char *format, ...)
void FCEU_DispMessageOnMovie(const char *format, ...)
{
va_list ap;
@ -414,7 +414,7 @@ void FCEU_DispMessageOnMovie(char *format, ...)
guiMessage.howlong = 0;
}
void FCEU_DispMessage(char *format, int disppos=0, ...)
void FCEU_DispMessage(const char *format, int disppos=0, ...)
{
va_list ap;
@ -455,7 +455,7 @@ void FCEU_ResetMessages()
}
static int WritePNGChunk(FILE *fp, uint32 size, char *type, uint8 *data)
static int WritePNGChunk(FILE *fp, uint32 size, const char *type, uint8 *data)
{
uint32 crc;

View File

@ -35,7 +35,7 @@
#define IOPTION_PREDIP 0x10
typedef struct {
char *name;
const char *name;
uint64 md5partial;
int mapper;
int mirroring;