From: Flavio Cruz <flaviocruz@gmail.com>
To: gdb-patches <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH] Hurd: remove VLA usage.
Date: Wed, 18 Dec 2024 01:27:19 -0500 [thread overview]
Message-ID: <t434vaztj3daruoeik5p63xhfpoobrf2nmxvbcldx6n6fgooqh@t7muqodl2hbv> (raw)
Compilation will fail with -Werror=vla, which seems to be the default.
Note that we can allocate just an array of num_threads pointers,
hence the change.
---
gdb/gnu-nat.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index a8a4da1c..60819695 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -1016,14 +1016,14 @@ gnu_nat_target::inf_validate_procs (struct inf *inf)
{
/* Make things normally linear. */
mach_msg_type_number_t search_start = 0;
- /* Which thread in PROCS corresponds to each task thread, & the task. */
- struct proc *matched[num_threads + 1];
+ /* Which thread in PROCS corresponds to each task thread. */
+ struct proc **matched = XNEWVEC (struct proc *, num_threads);
/* The last thread in INF->threads, so we can add to the end. */
struct proc *last = 0;
/* The current thread we're considering. */
struct proc *thread = inf->threads;
- memset (matched, 0, sizeof (matched));
+ memset (matched, 0, sizeof (struct proc *) * num_threads);
while (thread)
{
@@ -1090,6 +1090,7 @@ gnu_nat_target::inf_validate_procs (struct inf *inf)
}
}
+ xfree (matched);
vm_deallocate (mach_task_self (),
(vm_address_t) threads, (num_threads * sizeof (thread_t)));
}
--
2.45.2
next reply other threads:[~2024-12-18 6:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-18 6:27 Flavio Cruz [this message]
2024-12-18 15:14 ` 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=t434vaztj3daruoeik5p63xhfpoobrf2nmxvbcldx6n6fgooqh@t7muqodl2hbv \
--to=flaviocruz@gmail.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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