public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: [PATCH 02/13] gdb: remove use of alloca from auxv.c
Date: Mon, 27 Feb 2023 21:29:15 +0000	[thread overview]
Message-ID: <bc0bd1083fe2cc193552d0e754949b45e7cdddd4.1677533215.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1677533215.git.aburgess@redhat.com>

Remove the last use of alloca from auxv.c and replace it with
gdb::byte_vector.

There should be no user visible changes after this commit.
---
 gdb/auxv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gdb/auxv.c b/gdb/auxv.c
index 812b2807554..aea58807f4c 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -86,7 +86,6 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
   struct type *ptr_type = builtin_type (target_gdbarch ())->builtin_data_ptr;
   size_t ptr_size = ptr_type->length ();
   size_t auxv_pair_size = 2 * ptr_size;
-  gdb_byte *ptr_buf = (gdb_byte *) alloca (ptr_size);
   LONGEST retval;
   size_t block;
 
@@ -123,10 +122,11 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
      we might need a valgrind extension to make it work.  This is PR
      11440.  */
 
-  if (target_read_memory (pointer_address, ptr_buf, ptr_size) != 0)
+  gdb::byte_vector ptr_buf (ptr_size);
+  if (target_read_memory (pointer_address, ptr_buf.data (), ptr_size) != 0)
     return TARGET_XFER_E_IO;
 
-  data_address = extract_typed_address (ptr_buf, ptr_type);
+  data_address = extract_typed_address (ptr_buf.data (), ptr_type);
 
   /* Possibly still not initialized such as during an inferior
      startup.  */
@@ -151,11 +151,11 @@ ld_so_xfer_auxv (gdb_byte *readbuf,
 
   if (offset >= auxv_pair_size)
     {
-      if (target_read_memory (data_address - auxv_pair_size, ptr_buf,
+      if (target_read_memory (data_address - auxv_pair_size, ptr_buf.data (),
 			      ptr_size) != 0)
 	return TARGET_XFER_E_IO;
 
-      if (extract_typed_address (ptr_buf, ptr_type) == AT_NULL)
+      if (extract_typed_address (ptr_buf.data (), ptr_type) == AT_NULL)
 	return TARGET_XFER_EOF;
     }
 
-- 
2.25.4


  parent reply	other threads:[~2023-02-27 21:29 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 21:29 [PATCH 00/13] Remove a bunch of alloca uses Andrew Burgess
2023-02-27 21:29 ` [PATCH 01/13] gdb: remove uses of alloca from arch-utils.c Andrew Burgess
2023-02-27 21:29 ` Andrew Burgess [this message]
2023-02-27 21:29 ` [PATCH 03/13] gdb: remove use of alloca from c-lang.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 04/13] gdb: remove use of alloca from corefile.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 05/13] gdb: remove uses of alloca from dwarf2/expr.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 06/13] gdb: remove a use of alloca from elfread.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 07/13] gdb: remove use of alloca from findvar.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 08/13] gdb: remove use of alloca from linux-nat-trad.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 09/13] gdb: remove use of alloca from mem-break.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 10/13] gdb: remove some uses of alloca from printcmd.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 11/13] gdb: remove some uses of alloca from remote.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 12/13] gdb: remove uses of alloca from valprint.c Andrew Burgess
2023-02-27 21:29 ` [PATCH 13/13] gdb: remove a use of alloca from symfile.c Andrew Burgess
2023-02-28  2:47 ` [PATCH 00/13] Remove a bunch of alloca uses Simon Marchi
2023-03-07 21:57   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bc0bd1083fe2cc193552d0e754949b45e7cdddd4.1677533215.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).