-Wwrite-strings: Constify macroexp.c:init_shared_buffer
There's one call in the file that passes a string literal, like: init_shared_buffer (&va_arg_name, "__VA_ARGS__", strlen ("__VA_ARGS__")); Instead of adding a cast here, make init_shared_buffer take a 'const char *', and remove the several casts in the file that are made obsolete. gdb/ChangeLog: 2017-04-05 Pedro Alves <palves@redhat.com> * macroexp.c (macro_buffer::shared): Now a bool. (init_buffer): Update. (init_shared_buffer): Constify 'addr' parameter. (substitute_args, expand, macro_expand, macro_expand_next): Remove casts.
This commit is contained in:
parent
f995bbe8e6
commit
b38ef47f47
|
@ -1,3 +1,11 @@
|
||||||
|
2017-04-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
|
* macroexp.c (macro_buffer::shared): Now a bool.
|
||||||
|
(init_buffer): Update.
|
||||||
|
(init_shared_buffer): Constify 'addr' parameter.
|
||||||
|
(substitute_args, expand, macro_expand, macro_expand_next): Remove
|
||||||
|
casts.
|
||||||
|
|
||||||
2017-04-05 Pedro Alves <palves@redhat.com>
|
2017-04-05 Pedro Alves <palves@redhat.com>
|
||||||
|
|
||||||
* arm-tdep.c (show_disassembly_style_sfunc): Constify local.
|
* arm-tdep.c (show_disassembly_style_sfunc): Constify local.
|
||||||
|
|
|
@ -53,8 +53,9 @@ struct macro_buffer
|
||||||
|
|
||||||
/* Zero if TEXT can be safely realloc'ed (i.e., it's its own malloc
|
/* Zero if TEXT can be safely realloc'ed (i.e., it's its own malloc
|
||||||
block). Non-zero if TEXT is actually pointing into the middle of
|
block). Non-zero if TEXT is actually pointing into the middle of
|
||||||
some other block, and we shouldn't reallocate it. */
|
some other block, or to a string literal, and we shouldn't
|
||||||
int shared;
|
reallocate it. */
|
||||||
|
bool shared;
|
||||||
|
|
||||||
/* For detecting token splicing.
|
/* For detecting token splicing.
|
||||||
|
|
||||||
|
@ -85,19 +86,22 @@ init_buffer (struct macro_buffer *b, int n)
|
||||||
else
|
else
|
||||||
b->text = NULL;
|
b->text = NULL;
|
||||||
b->len = 0;
|
b->len = 0;
|
||||||
b->shared = 0;
|
b->shared = false;
|
||||||
b->last_token = -1;
|
b->last_token = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Set the macro buffer *BUF to refer to the LEN bytes at ADDR, as a
|
/* Set the macro buffer *BUF to refer to the LEN bytes at ADDR, as a
|
||||||
shared substring. */
|
shared substring. */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_shared_buffer (struct macro_buffer *buf, char *addr, int len)
|
init_shared_buffer (struct macro_buffer *buf, const char *addr, int len)
|
||||||
{
|
{
|
||||||
buf->text = addr;
|
/* The function accept a "const char *" addr so that clients can
|
||||||
|
pass in string literals without casts. */
|
||||||
|
buf->text = (char *) addr;
|
||||||
buf->len = len;
|
buf->len = len;
|
||||||
buf->shared = 1;
|
buf->shared = true;
|
||||||
buf->size = 0;
|
buf->size = 0;
|
||||||
buf->last_token = -1;
|
buf->last_token = -1;
|
||||||
}
|
}
|
||||||
|
@ -980,7 +984,7 @@ substitute_args (struct macro_buffer *dest,
|
||||||
lexed. */
|
lexed. */
|
||||||
char *lookahead_rl_start;
|
char *lookahead_rl_start;
|
||||||
|
|
||||||
init_shared_buffer (&replacement_list, (char *) def->replacement,
|
init_shared_buffer (&replacement_list, def->replacement,
|
||||||
strlen (def->replacement));
|
strlen (def->replacement));
|
||||||
|
|
||||||
gdb_assert (dest->len == 0);
|
gdb_assert (dest->len == 0);
|
||||||
|
@ -1199,7 +1203,7 @@ expand (const char *id,
|
||||||
{
|
{
|
||||||
struct macro_buffer replacement_list;
|
struct macro_buffer replacement_list;
|
||||||
|
|
||||||
init_shared_buffer (&replacement_list, (char *) def->replacement,
|
init_shared_buffer (&replacement_list, def->replacement,
|
||||||
strlen (def->replacement));
|
strlen (def->replacement));
|
||||||
|
|
||||||
scan (dest, &replacement_list, &new_no_loop, lookup_func, lookup_baton);
|
scan (dest, &replacement_list, &new_no_loop, lookup_func, lookup_baton);
|
||||||
|
@ -1236,7 +1240,7 @@ expand (const char *id,
|
||||||
substitution parameter is the name of the formal
|
substitution parameter is the name of the formal
|
||||||
argument without the "...". */
|
argument without the "...". */
|
||||||
init_shared_buffer (&va_arg_name,
|
init_shared_buffer (&va_arg_name,
|
||||||
(char *) def->argv[def->argc - 1],
|
def->argv[def->argc - 1],
|
||||||
len - 3);
|
len - 3);
|
||||||
is_varargs = 1;
|
is_varargs = 1;
|
||||||
}
|
}
|
||||||
|
@ -1415,7 +1419,7 @@ macro_expand (const char *source,
|
||||||
struct macro_buffer src, dest;
|
struct macro_buffer src, dest;
|
||||||
struct cleanup *back_to;
|
struct cleanup *back_to;
|
||||||
|
|
||||||
init_shared_buffer (&src, (char *) source, strlen (source));
|
init_shared_buffer (&src, source, strlen (source));
|
||||||
|
|
||||||
init_buffer (&dest, 0);
|
init_buffer (&dest, 0);
|
||||||
dest.last_token = 0;
|
dest.last_token = 0;
|
||||||
|
@ -1448,7 +1452,7 @@ macro_expand_next (const char **lexptr,
|
||||||
struct cleanup *back_to;
|
struct cleanup *back_to;
|
||||||
|
|
||||||
/* Set up SRC to refer to the input text, pointed to by *lexptr. */
|
/* Set up SRC to refer to the input text, pointed to by *lexptr. */
|
||||||
init_shared_buffer (&src, (char *) *lexptr, strlen (*lexptr));
|
init_shared_buffer (&src, *lexptr, strlen (*lexptr));
|
||||||
|
|
||||||
/* Set up DEST to receive the expansion, if there is one. */
|
/* Set up DEST to receive the expansion, if there is one. */
|
||||||
init_buffer (&dest, 0);
|
init_buffer (&dest, 0);
|
||||||
|
|
Loading…
Reference in New Issue