From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eMs7K3+lZ2eOyCgAWB0awg (envelope-from ) for ; Sun, 22 Dec 2024 00:37:03 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Avo50QG4; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id AE12C1E097; Sun, 22 Dec 2024 00:37:03 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5F5F21E05C for ; Sun, 22 Dec 2024 00:37:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ECBA9385840F for ; Sun, 22 Dec 2024 05:37:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ECBA9385840F Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=Avo50QG4 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by sourceware.org (Postfix) with ESMTPS id 0FA5A3858D3C for ; Sun, 22 Dec 2024 05:36:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0FA5A3858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0FA5A3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::830 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734845791; cv=none; b=sm1QZ9BdrsAxvwvK0Gzc2p0DSyHdNCrWm8te53xzo/k1+qDQYyvzqMa3AB6zrj5rfGbiUukHdMLc8q+5490B0hxkmYwIPMtqMWi/XHvrLovrDr1FOhiKw600EVjU2YQtSw7iZsgVq5/OPNvD9yWTbtesRojAJtOD/w/1i4S1egI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734845791; c=relaxed/simple; bh=9+BYivuiMsHd2OSSOwOvUj+VmHd66DYwe+9NwaxtyBE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=BUCfydCAS4O1nHQKkp+S1uPp+mVtsx3/d8LZGJlMg/39tiyWvlBcfCWo87zLz+vHgGmkq6Uo3aHsZqBQHIRXtyYZuRIoOLUqAqwXQO+XccrTy1H7pWRkpl0QGUAALuNkNfhxEz4eCnH5/OfMtU1XNjxb04JeA4/X0MbhqTDsv8I= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0FA5A3858D3C Received: by mail-qt1-x830.google.com with SMTP id d75a77b69052e-4678664e22fso28605611cf.2 for ; Sat, 21 Dec 2024 21:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734845790; x=1735450590; darn=sourceware.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=fRi9rRN50WFKF+id9HLyuxp6CaT8i75eIHNQ3c0awxc=; b=Avo50QG4jY3x+WRVN3NjbxTCbEtwUSpnDEDM+/k+bR+JtoDBFMsZIqDcQESzM7TF+1 IwdZdbDt8I/mrFX1lKYKwLYLTG+7neQQYfFjhGEL0dViST2W9pRMeNYTS76NAfdIIVWW 1NqjG8PHeIwxk9aimfckmGS9o0+gzj72zDQzxd1SZx3b46YXJ4O/C+2QboQaVImOkeUG CSq0wv2kYwx/yuDAiqxSK4S9k8gT6FWenBAqVnbf2MZhhr1yvlkVlJlQ4fevgJrSP/GW ffWAPwSALm8ybnvxFwGKb4IyRK7ih/WCYZda/K6/GeelqElPRUp62vnk7Z+5xRCdoOJ9 rdXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734845790; x=1735450590; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fRi9rRN50WFKF+id9HLyuxp6CaT8i75eIHNQ3c0awxc=; b=UTAWIlZ38yZEu7XvP7V5Fk4urDy1k71G/DRzD8wZ7xh3z3IDIV7tNMyxtvK7D3ED7D vs2g0aJMr0xY5/0Sr8qQzsWGjhCPsG57sha9J0mFLXOaFWg6ni24gm//gjZ9D/bzY5jX kHzj7Qqz+ct1eUZK0uf5Kc7Jr3pSjXvlLsqq1Zueu7GqHYTMyeqSmTebYIfOG4XGvvd7 lMsLkbwFHglzFqsk5nn8HJk3sPtmuWLuwQRJT3dnWsks0OTsPJez/laK+1wgNEWM9hxR Fv1clMGNN+A6JSN5nxzYS5RzYISmTz/lbcZ6lOT5yTCnaNK1i9xHXE7Sm8XreFizjLVK FvLg== X-Gm-Message-State: AOJu0Yxnz/NJepdJgU08MdDp/jMbQgOTIMKTOzomaWV5PVq3hI4Zhy/j Ky5ESCIK0VwyFWGGbXRXZuqujOESMgC+YgCQXIfVTGBCvjU4rwcBWmHLB3gSem7sR3bxnFm3WaB koY9mRD75pmTspQ4Y5bfXntvAOgb6ZwY= X-Gm-Gg: ASbGncu742XtcSD2IqZXmi6qii7nCkDI+WuPEQqk6XoyhCUFYufnAUp/AQ6yB35Pqf5 ZCNOflwciEuj1ETMpb4lmtjWE5jtKLi6IEmEBQQ== X-Google-Smtp-Source: AGHT+IEpYXy7BxSNpMK1LtiG2otjKqn9ua8IlMgwYPilODkcFHZCnGGPNju96mMBlHtDZvZpPDnT8grEfMAijP4nFL4= X-Received: by 2002:ac8:7e87:0:b0:467:45b7:c495 with SMTP id d75a77b69052e-46a4a8cdc04mr127215951cf.15.1734845790350; Sat, 21 Dec 2024 21:36:30 -0800 (PST) MIME-Version: 1.0 References: <009b3d1c-9852-49bc-bcb5-f25d418310ad@simark.ca> In-Reply-To: <009b3d1c-9852-49bc-bcb5-f25d418310ad@simark.ca> From: =?UTF-8?B?RmzDoXZpbyBDcnV6?= Date: Sun, 22 Dec 2024 00:36:19 -0500 Message-ID: Subject: Re: [PATCH v2] Hurd: remove VLA usage. To: Simon Marchi Cc: gdb-patches , Tom Tromey Content-Type: multipart/alternative; boundary="00000000000012f3a80629d54388" X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org --00000000000012f3a80629d54388 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Dec 19, 2024 at 10:05=E2=80=AFAM Simon Marchi wr= ote: > > > On 2024-12-19 00:28, Flavio Cruz wrote: > > Compilation will fail with -Werror=3Dvla, 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. > > I don't fully understand the algorithm, but I see that `matched` only > gets indexed using `i`, and `i` is always less than `num_threads`, so > this seems fine to me. > > > --- > > 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..be6fa879 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 =3D 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 matched (num_threads, nullptr); > > It's not necessary to specify nullptr here, because the pointers will be > default initialized, which means nullptr for pointers. > Good point, I've sent a new patch. > > LGTM with that fixed. > > Approved-By: Simon Marchi > > Do you have push access? > No, I don't. Thanks for the review. > > Simon > --00000000000012f3a80629d54388 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Thu, Dec 19,= 2024 at 10:05=E2=80=AFAM Simon Marchi <simark@simark.ca> wrote:


On 2024-12-19 00:28, Flavio Cruz wrote:
> Compilation will fail with -Werror=3Dvla, which seems to be the defaul= t.
>
> Note that we don't need to allocate num_threads + 1 since the matc= hing
> algorithm works only on the num_threads as returned by task_threads.
I don't fully understand the algorithm, but I see that `matched` only gets indexed using `i`, and `i` is always less than `num_threads`, so
this seems fine to me.

> ---
>=C2=A0 gdb/gnu-nat.c | 6 ++----
>=C2=A0 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
> index a8a4da1c..be6fa879 100644
> --- a/gdb/gnu-nat.c
> +++ b/gdb/gnu-nat.c
> @@ -1016,15 +1016,13 @@ gnu_nat_target::inf_validate_procs (struct inf= *inf)
>=C2=A0 =C2=A0 {
>=C2=A0 =C2=A0 =C2=A0 /* Make things normally linear.=C2=A0 */
>=C2=A0 =C2=A0 =C2=A0 mach_msg_type_number_t search_start =3D 0;
> -=C2=A0 =C2=A0 /* Which thread in PROCS corresponds to each task threa= d, & the task.=C2=A0 */
> -=C2=A0 =C2=A0 struct proc *matched[num_threads + 1];
> +=C2=A0 =C2=A0 /* Which thread in PROCS corresponds to each task threa= d.=C2=A0 */
> +=C2=A0 =C2=A0 std::vector<struct proc *> matched (num_threads, = nullptr);

It's not necessary to specify nullptr here, because the pointers will b= e
default initialized, which means nullptr for pointers.

Good point, I've sent a new patch.
=C2=A0
=

LGTM with that fixed.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Do you have push access?

No, I don'= t. Thanks for the review.
=C2=A0

Simon
--00000000000012f3a80629d54388--