From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id +BNmAVM2ZGcxtCIAWB0awg (envelope-from ) for ; Thu, 19 Dec 2024 10:05:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1734620755; bh=zTFDpCSM03JNg1H5grDs072sPdbICptWD+lKFENwVR8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=dMx5+TRIi26/WVyZ1iu+PV+NKhUAS5lanBZY082tqFduttx/hPlg+l0xEXnhO7Kxc WpMoAM3/SpZpdwEr7PPnAUZ63KZHpe9M79T0dSR5hMH/qjnl6CK7ZCvrFUbw+Zn3Lc wEJ7e9e3njeNPmwQL/70YnzHq8a1EmWvbKw7fTqY= Received: by simark.ca (Postfix, from userid 112) id 0131E1E097; Thu, 19 Dec 2024 10:05:55 -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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=unavailable autolearn_force=no version=4.0.0 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Zp4eljcc; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Zp4eljcc; dkim-atps=neutral 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 99D751E091 for ; Thu, 19 Dec 2024 10:05:54 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 29F9D3858C66 for ; Thu, 19 Dec 2024 15:05:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 29F9D3858C66 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Zp4eljcc; dkim=pass (1024-bit key) header.d=simark.ca header.i=@simark.ca header.a=rsa-sha256 header.s=mail header.b=Zp4eljcc Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id BC34A3858D21 for ; Thu, 19 Dec 2024 15:05:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC34A3858D21 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark.ca ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BC34A3858D21 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=158.69.221.121 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734620717; cv=none; b=UhSBmDwOG/pPNh99xrNC++ELaUO9wzRA4MrQnDlD3tlD3f8EPZJ7MhAxN+jPOSoXEiIRg+y9SotaKAmOWoN+SDhhUOCJgmWzyNmJ5H64SyV6s4GVm7kamxfyuy7R1RVZomiQROPkG7iwygwZWT7InQEyedYc/SiAzlUv+diaB88= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1734620717; c=relaxed/simple; bh=zTFDpCSM03JNg1H5grDs072sPdbICptWD+lKFENwVR8=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:To:From; b=HZuI/UvzyxEmKT62ra5qDy8JTJI2llC1RtnyGD8XS0HobF074oqUfEoV9D/CZyVmzOYumw8Wki8K2wb0xeZlzStIZ5vech7oO9l6dgQ7MyCaG+7WFVWEDSkj6WBRAfJ1RnQjV++4dx9CIKaqmqYm/FvLzftTRH+LkEH9uNNr4Uk= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC34A3858D21 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1734620716; bh=zTFDpCSM03JNg1H5grDs072sPdbICptWD+lKFENwVR8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Zp4eljccrCaVrj9VF+Mq9AXBY/CpvT75VDUCrDkEP3lddF09lh3eTOnzIeCUiuH3G 4hvjFSEORcIdQ7wddsC8KlJ0OzhUMdjVb7dpA9OSLI6+26Pqeo7c+zOMJk696GdMJa lTMtFbBllkm0le8BMOin9iUsMmfI/YQbw2wP7zbM= Received: by simark.ca (Postfix, from userid 112) id DD76C1E097; Thu, 19 Dec 2024 10:05:16 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=simark.ca; s=mail; t=1734620716; bh=zTFDpCSM03JNg1H5grDs072sPdbICptWD+lKFENwVR8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Zp4eljccrCaVrj9VF+Mq9AXBY/CpvT75VDUCrDkEP3lddF09lh3eTOnzIeCUiuH3G 4hvjFSEORcIdQ7wddsC8KlJ0OzhUMdjVb7dpA9OSLI6+26Pqeo7c+zOMJk696GdMJa lTMtFbBllkm0le8BMOin9iUsMmfI/YQbw2wP7zbM= Received: from [10.0.0.11] (modemcable238.237-201-24.mc.videotron.ca [24.201.237.238]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 0F9C91E091; Thu, 19 Dec 2024 10:05:16 -0500 (EST) Message-ID: <009b3d1c-9852-49bc-bcb5-f25d418310ad@simark.ca> Date: Thu, 19 Dec 2024 10:05:15 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] Hurd: remove VLA usage. To: Flavio Cruz , gdb-patches Cc: Tom Tromey References: Content-Language: en-US From: Simon Marchi In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 On 2024-12-19 00:28, 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. 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 = 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. LGTM with that fixed. Approved-By: Simon Marchi Do you have push access? Simon