[PATCH 02/11] [C++/mingw] Misc alloca casts

Pedro Alves
2015-11-02T19:36:20Z

gdb/ChangeLog:
2015-11-01 Pedro Alves <palves@redhat.com>

* exec.c (exec_file_attach, symfile_bfd_open) [__GO32__ || _WIN32
|| __CYGWIN__]: Add casts.
* utils.c (gdb_filename_fnmatch): Add cast.
* windows-nat.c (windows_create_inferior): Add cast.
---
gdb/exec.c | 2 +-
gdb/symfile.c | 2 +-
gdb/utils.c | 4 ++--
gdb/windows-nat.c | 8 ++++----
4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gdb/exec.c b/gdb/exec.c
index 3089bb4..2433019 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -254,7 +254,7 @@ exec_file_attach (const char *filename, int from_tty)
#if defined(__GO32__) || defined(_WIN32) || defined(__CYGWIN__)
if (scratch_chan < 0)
{
- char *exename = alloca (strlen (filename) + 5);
+ char *exename = (char *) alloca (strlen (filename) + 5);

strcat (strcpy (exename, filename), ".exe");
scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST,
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 55a9f5c..58c4ff9 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1738,7 +1738,7 @@ symfile_bfd_open (const char *name)
#if defined(__GO32__) || defined(_WIN32) || defined (__CYGWIN__)
if (desc < 0)
{
- char *exename = alloca (strlen (expanded_name) + 5);
+ char *exename = (char *) alloca (strlen (expanded_name) + 5);

strcat (strcpy (exename, expanded_name), ".exe");
desc = openp (getenv ("PATH"),
diff --git a/gdb/utils.c b/gdb/utils.c
index bb13522..284fbbb 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -3356,14 +3356,14 @@ gdb_filename_fnmatch (const char *pattern, const char *string, int flags)

/* Replace '\' by '/' in both strings. */

- pattern_slash = alloca (strlen (pattern) + 1);
+ pattern_slash = (char *) alloca (strlen (pattern) + 1);
strcpy (pattern_slash, pattern);
pattern = pattern_slash;
for (; *pattern_slash != 0; pattern_slash++)
if (IS_DIR_SEPARATOR (*pattern_slash))
*pattern_slash = '/';

- string_slash = alloca (strlen (string) + 1);
+ string_slash = (char *) alloca (strlen (string) + 1);
strcpy (string_slash, string);
string = string_slash;
for (; *string_slash != 0; string_slash++)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index e6c396b..8dfe211 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2209,7 +2209,7 @@ windows_create_inferior (struct target_ops *ops, char *exec_file,
To avoid ambiguities introduced by spaces in the module name,
we quote it. */
args_len = strlen (toexec) + 2 /* quotes */ + strlen (allargs) + 2;
- args = alloca (args_len);
+ args = (char *) alloca (args_len);
xsnprintf (args, args_len, "\"%s\" %s", toexec, allargs);

flags |= DEBUG_ONLY_THIS_PROCESS;
@@ -2249,7 +2249,7 @@ windows_create_inferior (struct target_ops *ops, char *exec_file,
/* Windows programs expect the environment block to be sorted. */
qsort (env, i, sizeof (char *), envvar_cmp);

- w32env = alloca (envlen + 1);
+ w32env = (char *) alloca (envlen + 1);

/* Copy env strings into new buffer. */
for (temp = w32env, i = 0; env[i] && *env[i]; i++)
@@ -2421,7 +2421,7 @@ windows_xfer_shared_libraries (struct target_ops *ops,
target_gdbarch (), &obstack);
obstack_grow_str0 (&obstack, "</library-list>\n");

- buf = obstack_finish (&obstack);
+ buf = (const char *) obstack_finish (&obstack);
len_avail = strlen (buf);
if (offset >= len_avail)
len= 0;
@@ -2700,7 +2700,7 @@ _initialize_check_for_gdb_ini (void)
if (access (oldini, 0) == 0)
{
int len = strlen (oldini);
- char *newini = alloca (len + 1);
+ char *newini = (char *) alloca (len + 1);

xsnprintf (newini, len + 1, "%.*s.gdbinit",
(int) (len - (sizeof ("gdb.ini") - 1)), oldini);
--
1.9.3