g++ complains on console(char *fmt, ...) interface when called from C++ code,
where constant string fmt get converted into non-constant char *:
symtab.c:7137:51: warning: deprecated conversion from string constant to ‘char*’
[-Wwrite-strings]
console("gdb_get_datatype [%s] (a)\n", req->name);
^
symtab.c:7163:51: warning: deprecated conversion from string constant to ‘char*’
[-Wwrite-strings]
console("gdb_get_datatype [%s] (b)\n", req->name);
^
symtab.c:7172:57: warning: deprecated conversion from string constant to ‘char*’
[-Wwrite-strings]
console("expr->elts[0].opcode: OP_VAR_VALUE\n");
Changing fmt type to const char *
Signed-off-by: Alexey Makhalov <amakhalov(a)vmware.com>
Reported-by: Kazuhito Hagio <k-hagio-ab(a)nec.com>
---
defs.h | 4 ++--
tools.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/defs.h b/defs.h
index 4434453..3f83756 100644
--- a/defs.h
+++ b/defs.h
@@ -4732,7 +4732,7 @@ struct gnu_request {
/*
* function prototypes required by modified gdb source files.
*/
-extern "C" int console(char *, ...);
+extern "C" int console(const char *, ...);
extern "C" int gdb_CRASHDEBUG(ulong);
int gdb_readmem_callback(ulong, void *, int, int);
void patch_load_module(struct objfile *objfile, struct minimal_symbol *msymbol);
@@ -5029,7 +5029,7 @@ void exec_args_input_file(struct command_table_entry *, struct
args_input_file *
FILE *set_error(char *);
int __error(int, char *, ...);
#define error __error /* avoid conflict with gdb error() */
-int console(char *, ...);
+int console(const char *, ...);
void create_console_device(char *);
int console_off(void);
int console_on(int);
diff --git a/tools.c b/tools.c
index a26b101..0bb9c04 100644
--- a/tools.c
+++ b/tools.c
@@ -6213,7 +6213,7 @@ drop_core(char *s)
* The first time it's called, the device will be opened.
*/
int
-console(char *fmt, ...)
+console(const char *fmt, ...)
{
char output[BUFSIZE*2];
va_list ap;
--
2.11.0