Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Flavio Cruz <flaviocruz@gmail.com>,
	gdb-patches <gdb-patches@sourceware.org>
Subject: Re: [PATCH v2] Hurd: remove VLA usage.
Date: Sun, 22 Dec 2024 09:26:40 -0500	[thread overview]
Message-ID: <e5a263ab-8887-4f24-822f-eaf18ae2e9b5@simark.ca> (raw)
In-Reply-To: <aj4yb3tl24xtqrfuxciapl5loamna73cy7k2724gzwaccc6lyk@heqjutt4r6g5>



On 2024-12-22 00:34, Flavio Cruz wrote:
> Compilation will fail with -Werror=vla, which seems to be the default.
> 
> Note that we don't need to allocate num_threads + 1 since the matching
> algorithm works only on the num_threads as returned by task_threads.
> ---
>  gdb/gnu-nat.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
> index a8a4da1c..ab157094 100644
> --- a/gdb/gnu-nat.c
> +++ b/gdb/gnu-nat.c
> @@ -1016,15 +1016,13 @@ 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.  */
> +    std::vector<struct proc *> matched (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));
> -
>      while (thread)
>        {
>  	mach_msg_type_number_t left;

Thanks, I pushed that for you.  I made a minor modification, adding
newlines before the comments between the declarations.

Simon

  reply	other threads:[~2024-12-22 14:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-19  5:28 Flavio Cruz
2024-12-19 15:05 ` Simon Marchi
2024-12-22  5:34   ` Flavio Cruz
2024-12-22 14:26     ` Simon Marchi [this message]
2024-12-22  5:36   ` Flávio Cruz

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=e5a263ab-8887-4f24-822f-eaf18ae2e9b5@simark.ca \
    --to=simark@simark.ca \
    --cc=flaviocruz@gmail.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