From 8e5bb2054230342a362085604e786a1b2371e477 Mon Sep 17 00:00:00 2001 From: Daniel Marmier Date: Thu, 9 Oct 2003 04:39:01 +0000 Subject: [PATCH] Fixed warnings with gcc option "-Wwrite-strings". --- programs/wcmd/builtins.c | 8 ++++---- programs/wcmd/wcmd.h | 6 +++--- programs/wcmd/wcmdmain.c | 6 +++--- programs/winecfg/drive.c | 8 ++++---- programs/winecfg/winecfg.c | 22 +++++++++++----------- programs/winecfg/winecfg.h | 10 +++++----- programs/winedbg/db_disasm.c | 6 +++--- programs/winedbg/dbg.y | 4 ++-- programs/winedbg/debugger.h | 2 +- programs/winedbg/gdbproxy.c | 12 ++++++------ programs/winedbg/hash.c | 5 +++-- programs/winedbg/info.c | 8 ++++---- programs/winedbg/types.c | 20 ++++++++++---------- 13 files changed, 59 insertions(+), 58 deletions(-) diff --git a/programs/wcmd/builtins.c b/programs/wcmd/builtins.c index 951599a54d..5394ebe070 100644 --- a/programs/wcmd/builtins.c +++ b/programs/wcmd/builtins.c @@ -101,7 +101,7 @@ DWORD count; WIN32_FIND_DATA fd; HANDLE hff; BOOL force, status; -static char *overwrite = "Overwrite file (Y/N)?"; +static const char *overwrite = "Overwrite file (Y/N)?"; char string[8], outpath[MAX_PATH], inpath[MAX_PATH], *infile; if ((strchr(param1,'*') != NULL) && (strchr(param1,'%') != NULL)) { @@ -207,9 +207,9 @@ char *p; * in DOS (try typing "ECHO ON AGAIN" for an example). */ -void WCMD_echo (char *command) { +void WCMD_echo (const char *command) { -static char *eon = "Echo is ON\n", *eoff = "Echo is OFF\n"; +static const char *eon = "Echo is ON\n", *eoff = "Echo is OFF\n"; int count; count = strlen(command); @@ -805,7 +805,7 @@ DWORD count; void WCMD_verify (char *command) { -static char *von = "Verify is ON\n", *voff = "Verify is OFF\n"; +static const char *von = "Verify is ON\n", *voff = "Verify is OFF\n"; int count; count = strlen(command); diff --git a/programs/wcmd/wcmd.h b/programs/wcmd/wcmd.h index 84082ee71b..1ed300a246 100644 --- a/programs/wcmd/wcmd.h +++ b/programs/wcmd/wcmd.h @@ -40,7 +40,7 @@ void WCMD_copy (void); void WCMD_create_dir (void); void WCMD_delete (int recurse); void WCMD_directory (void); -void WCMD_echo (char *); +void WCMD_echo (const char *); void WCMD_enter_paged_mode(void); void WCMD_for (char *); void WCMD_give_help (char *command); @@ -48,8 +48,8 @@ void WCMD_goto (void); void WCMD_if (char *); void WCMD_leave_paged_mode(void); void WCMD_move (void); -void WCMD_output (char *format, ...); -void WCMD_output_asis (char *message); +void WCMD_output (const char *format, ...); +void WCMD_output_asis (const char *message); void WCMD_parse (char *s, char *q, char *p1, char *p2); void WCMD_pause (void); void WCMD_pipe (char *command); diff --git a/programs/wcmd/wcmdmain.c b/programs/wcmd/wcmdmain.c index 1f8fc265c9..13b89e1b62 100644 --- a/programs/wcmd/wcmdmain.c +++ b/programs/wcmd/wcmdmain.c @@ -27,7 +27,7 @@ #include "ntstatus.h" #include "wcmd.h" -char *inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY", "CTTY", +const char *inbuilt[] = {"ATTRIB", "CALL", "CD", "CHDIR", "CLS", "COPY", "CTTY", "DATE", "DEL", "DIR", "ECHO", "ERASE", "FOR", "GOTO", "HELP", "IF", "LABEL", "MD", "MKDIR", "MOVE", "PATH", "PAUSE", "PROMPT", "REM", "REN", "RENAME", "RD", "RMDIR", "SET", "SHIFT", @@ -728,7 +728,7 @@ int p = 0; * */ -void WCMD_output (char *format, ...) { +void WCMD_output (const char *format, ...) { va_list ap; char string[1024]; @@ -766,7 +766,7 @@ void WCMD_leave_paged_mode(void) * without formatting eg. when message contains '%' */ -void WCMD_output_asis (char *message) { +void WCMD_output_asis (const char *message) { DWORD count; char* ptr; char string[1024]; diff --git a/programs/winecfg/drive.c b/programs/winecfg/drive.c index 243b0ab9bb..999f8c34c5 100644 --- a/programs/winecfg/drive.c +++ b/programs/winecfg/drive.c @@ -47,7 +47,7 @@ static int lastSel = 0; /* the last drive selected in the property sheet */ /* returns NULL on failure. caller is responsible for freeing result */ -char *getDriveValue(char letter, char *valueName) { +char *getDriveValue(char letter, const char *valueName) { HKEY hkDrive = 0; char *subKeyName; char *result = NULL; @@ -76,7 +76,7 @@ end: } /* call with newValue == NULL to remove a value */ -void setDriveValue(char letter, char *valueName, char *newValue) { +void setDriveValue(char letter, const char *valueName, const char *newValue) { char *driveSection = malloc(strlen("Drive X")+1); sprintf(driveSection, "Drive %c", letter); if (newValue) @@ -226,8 +226,8 @@ int refreshDriveDlg (HWND hDlg) #define DRIVE_MASK_BIT(B) 1<<(toupper(B)-'A') typedef struct { - char *sCode; - char *sDesc; + const char *sCode; + const char *sDesc; } code_desc_pair; static code_desc_pair type_pairs[] = { diff --git a/programs/winecfg/winecfg.c b/programs/winecfg/winecfg.c index 516440c837..8c2b78606d 100644 --- a/programs/winecfg/winecfg.c +++ b/programs/winecfg/winecfg.c @@ -68,14 +68,14 @@ int initialize(void) { /***************************************************************************** * getConfigValue: Retrieves a configuration value from the registry * - * char *subKey : the name of the config section - * char *valueName : the name of the config value - * char *defaultResult : if the key isn't found, return this value instead + * const char *subKey : the name of the config section + * const char *valueName : the name of the config value + * const char *defaultResult : if the key isn't found, return this value instead * * Returns a buffer holding the value if successful, NULL if not. Caller is responsible for freeing the result. * */ -char *getConfigValue (char *subkey, char *valueName, char *defaultResult) +char *getConfigValue (const char *subkey, const char *valueName, const char *defaultResult) { char *buffer = NULL; DWORD dataLength; @@ -129,14 +129,14 @@ end: * setConfigValue : Sets a configuration key in the registry. Section will be created if it doesn't already exist * * HKEY hCurrent : the registry key that the configuration is rooted at - * char *subKey : the name of the config section - * char *valueName : the name of the config value - * char *value : the value to set the configuration key to + * const char *subKey : the name of the config section + * const char *valueName : the name of the config value + * const char *value : the value to set the configuration key to * * Returns 0 on success, non-zero otherwise * */ -int setConfigValue (char *subkey, char *valueName, const char *value) { +int setConfigValue (const char *subkey, const char *valueName, const char *value) { DWORD res = 1; HKEY key = NULL; @@ -160,7 +160,7 @@ end: } /* returns 0 on success, an HRESULT from the registry funtions otherwise */ -HRESULT doesConfigValueExist(char *subkey, char *valueName) { +HRESULT doesConfigValueExist(const char *subkey, const char *valueName) { HRESULT hr; HKEY key; @@ -184,7 +184,7 @@ HRESULT doesConfigValueExist(char *subkey, char *valueName) { } /* removes the requested value from the registry, however, does not remove the section if empty. Returns S_OK (0) on success. */ -HRESULT removeConfigValue(char *subkey, char *valueName) { +HRESULT removeConfigValue(const char *subkey, const char *valueName) { HRESULT hr; HKEY key; WINE_TRACE("subkey=%s, valueName=%s\n", subkey, valueName); @@ -231,7 +231,7 @@ void destroyTransaction(struct transaction *trans) { free(trans); } -void addTransaction(char *section, char *key, enum transaction_action action, char *newValue) { +void addTransaction(const char *section, const char *key, enum transaction_action action, const char *newValue) { struct transaction *trans = calloc(sizeof(struct transaction),1); assert( section != NULL ); diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h index e4c05d707c..f1844e9a39 100644 --- a/programs/winecfg/winecfg.h +++ b/programs/winecfg/winecfg.h @@ -82,7 +82,7 @@ void processTransQueue(); * ACTION_SET -> this transaction will change a registry key, newValue is the replacement value * ACTION_REMOVE -> this transaction will remove a registry key. In this case, newValue is ignored. */ -void addTransaction(char *section, char *key, enum transaction_action action, char *newValue); +void addTransaction(const char *section, const char *key, enum transaction_action action, const char *newValue); /* frees the transaction structure, all fields, and removes it from the queue if in it */ void destroyTransaction(struct transaction *trans); @@ -91,10 +91,10 @@ void destroyTransaction(struct transaction *trans); int initialize(void); extern HKEY configKey; -int setConfigValue (char *subkey, char *valueName, const char *value); -char *getConfigValue (char *subkey, char *valueName, char *defaultResult); -HRESULT doesConfigValueExist (char *subkey, char *valueName); -HRESULT removeConfigValue (char *subkey, char *valueName); +int setConfigValue (const char *subkey, const char *valueName, const char *value); +char *getConfigValue (const char *subkey, const char *valueName, const char *defaultResult); +HRESULT doesConfigValueExist (const char *subkey, const char *valueName); +HRESULT removeConfigValue (const char *subkey, const char *valueName); /* X11DRV */ diff --git a/programs/winedbg/db_disasm.c b/programs/winedbg/db_disasm.c index 54f2d69777..02d86dca3c 100644 --- a/programs/winedbg/db_disasm.c +++ b/programs/winedbg/db_disasm.c @@ -1191,7 +1191,7 @@ static void db_task_printsym(unsigned int addr, int size) DEBUG_PrintAddress( &address, db_disasm_16 ? MODE_16 : MODE_32, TRUE ); } -void db_print_address(char *seg, int size, struct i_addr *addrp, int byref) +void db_print_address(const char *seg, int size, struct i_addr *addrp, int byref) { if (addrp->is_reg) { DEBUG_Printf(DBG_CHN_MESG,"%s", db_reg[size][addrp->disp]); @@ -1237,7 +1237,7 @@ void db_print_address(char *seg, int size, struct i_addr *addrp, int byref) * and return updated location. */ void db_disasm_esc( DBG_ADDR *addr, int inst, int short_addr, - int size, char *seg ) + int size, const char *seg ) { int regmodrm; const struct finst *fp; @@ -1327,7 +1327,7 @@ void DEBUG_Disasm( DBG_ADDR *addr, int display ) int inst; int size; int short_addr; - char * seg; + const char *seg; const struct inst *ip; const char *i_name; int i_size; diff --git a/programs/winedbg/dbg.y b/programs/winedbg/dbg.y index bc19a0cf5f..482e80ae0a 100644 --- a/programs/winedbg/dbg.y +++ b/programs/winedbg/dbg.y @@ -36,7 +36,7 @@ static void mode_command(int); int yylex(void); -int yyerror(char *); +int yyerror(const char *); %} @@ -479,7 +479,7 @@ void DEBUG_Parser(LPCSTR filename) set_default_channels(); } -int yyerror(char* s) +int yyerror(const char* s) { DEBUG_Printf(DBG_CHN_MESG, "%s\n", s); return 0; diff --git a/programs/winedbg/debugger.h b/programs/winedbg/debugger.h index edb99a0d6e..ef5b9c760f 100644 --- a/programs/winedbg/debugger.h +++ b/programs/winedbg/debugger.h @@ -503,7 +503,7 @@ extern int DEBUG_GetObjectSize(struct datatype * dt); extern unsigned int DEBUG_ArrayIndex(const DBG_VALUE * addr, DBG_VALUE * result, int index); extern struct datatype * DEBUG_FindOrMakePointerType(struct datatype * reftype); -extern long long int DEBUG_GetExprValue(const DBG_VALUE * addr, char ** format); +extern long long int DEBUG_GetExprValue(const DBG_VALUE * addr, const char ** format); extern int DEBUG_SetBitfieldParams(struct datatype * dt, int offset, int nbits, struct datatype * dt2); extern int DEBUG_CopyFieldlist(struct datatype * dt, struct datatype * dt2); diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c index eed611f698..bfecddc559 100644 --- a/programs/winedbg/gdbproxy.c +++ b/programs/winedbg/gdbproxy.c @@ -1406,8 +1406,8 @@ static void packet_query_monitor_mem(struct gdb_context* gdbctx, int len, const { MEMORY_BASIC_INFORMATION mbi; char* addr = 0; - char* state; - char* type; + const char* state; + const char* type; char prot[3+1]; char buffer[128]; @@ -2015,10 +2015,10 @@ static BOOL gdb_startup(struct gdb_context* gdbctx, DEBUG_EVENT* de, unsigned fl break; case 0: /* in child... and alive */ { - char buf[MAX_PATH]; - int fd; - char* gdb_path; - FILE* f; + char buf[MAX_PATH]; + int fd; + const char* gdb_path; + FILE* f; if (!(gdb_path = getenv("WINE_GDB"))) gdb_path = "gdb"; strcpy(buf,"/tmp/winegdb.XXXXXX"); diff --git a/programs/winedbg/hash.c b/programs/winedbg/hash.c index 24eaa15629..71105244ea 100644 --- a/programs/winedbg/hash.c +++ b/programs/winedbg/hash.c @@ -33,7 +33,7 @@ #endif #ifdef __i386__ -static char * reg_name[] = +static const char * reg_name[] = { "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi" }; @@ -523,7 +523,8 @@ const char * DEBUG_FindNearestSymbol( const DBG_ADDR *addr, int flag, int mid, high, low; unsigned int * ptr; int lineno; - char * lineinfo, *sourcefile; + const char * lineinfo; + char *sourcefile; int i; char linebuff[16]; unsigned val; diff --git a/programs/winedbg/info.c b/programs/winedbg/info.c index 40757ac4df..277cce49bc 100644 --- a/programs/winedbg/info.c +++ b/programs/winedbg/info.c @@ -40,7 +40,7 @@ */ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format ) { - char * default_format; + const char * default_format; long long int res; assert(value->cookie == DV_TARGET || value->cookie == DV_HOST); @@ -94,7 +94,7 @@ void DEBUG_PrintBasic( const DBG_VALUE* value, int count, char format ) if (strstr(default_format, "%S") != NULL) { - char* ptr; + const char* ptr; int state = 0; /* FIXME: simplistic implementation for default_format being @@ -631,8 +631,8 @@ void DEBUG_InfoVirtual(DWORD pid) { MEMORY_BASIC_INFORMATION mbi; char* addr = 0; - char* state; - char* type; + const char* state; + const char* type; char prot[3+1]; HANDLE hProc; diff --git a/programs/winedbg/types.c b/programs/winedbg/types.c index 2eb2ddd7c6..82154aa82d 100644 --- a/programs/winedbg/types.c +++ b/programs/winedbg/types.c @@ -60,15 +60,15 @@ struct datatype { enum debug_type type; struct datatype * next; - char * name; + const char * name; union { struct { - char basic_type; - char * output_format; - char basic_size; - unsigned b_signed:1; + char basic_type; + const char * output_format; + char basic_size; + unsigned b_signed:1; } basic; struct { @@ -133,8 +133,8 @@ static unsigned int type_hash( const char * name ) static struct datatype * -DEBUG_InitBasic(int type, char * name, int size, int b_signed, - char * output_format) +DEBUG_InitBasic(int type, const char * name, int size, int b_signed, + const char * output_format) { int hash; @@ -346,13 +346,13 @@ DEBUG_InitTypes(void) } long long int -DEBUG_GetExprValue(const DBG_VALUE* _value, char** format) +DEBUG_GetExprValue(const DBG_VALUE* _value, const char** format) { long long int rtn; unsigned int rtn2; struct datatype * type2 = NULL; struct en_values * e; - char * def_format = "0x%x"; + const char * def_format = "0x%x"; DBG_VALUE value = *_value; assert(_value->cookie == DV_TARGET || _value->cookie == DV_HOST); @@ -943,7 +943,7 @@ leave: static void DEBUG_DumpAType(struct datatype* dt, BOOL deep) { - char* name = (dt->name) ? dt->name : "--none--"; + const char* name = (dt->name) ? dt->name : "--none--"; /* EPP DEBUG_Printf(DBG_CHN_MESG, "0x%08lx ", (unsigned long)dt); */ switch (dt->type)