From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 13B023858D20 for ; Wed, 17 Apr 2024 23:01:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 13B023858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 13B023858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713394885; cv=none; b=aC/thkUv3J/ZS5cugN3Au6p9t0qjT6hPC4xWDW/y0s5a20wNNI1e8pfghB9i5Pqw7qGf5JWg2DItBA40bWQwM/IyVuHt8sq7dwGXd1vz/QKbO++7v6K02qxKCgB4rgxOkW2HFDSZDWABh1jbYzldG8vOggaTzM7BzQnOQoy/ODo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1713394885; c=relaxed/simple; bh=xTpF6rp/Cmffm/DIMkQSHT7c2Pfnk8ph64SBZEKiyOw=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=pZrC+vbUQY9mjiHmtBRmvCsF6AdWicvtbyoxfSYTMiOE2GPjTOMIfe6hf518j3pZg60P9wwDT5MIsqmcBFijJ2nN2GDQyExEU+YIPZ/Vm3qHY6l6WoPOzwiOjZbDqKMrmH/3PYRzHPi/jlbhblraJyhAaxpFkubPm8FJMx9Xw+k= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5007a.ext.cloudfilter.net ([10.0.29.141]) by cmsmtp with ESMTPS id x8wqrJUcLtf2QxEHLrYTJp; Wed, 17 Apr 2024 23:01:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id xEHKrZK3oWqfjxEHKr4iZX; Wed, 17 Apr 2024 23:01:22 +0000 X-Authority-Analysis: v=2.4 cv=GsNE+F1C c=1 sm=1 tr=0 ts=662054c2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=raytVjVEu-sA:10 a=Qbun_eYptAEA:10 a=iS6VsuB3Eg6dx4kjnqwA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject: Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tSW4FMr8lJs/5guchgMxFX2lxXomf67CA2hsVE5CYXY=; b=ig6J++ICKYaYOQSJECnnXEhORt DVS9CoZc/swnBGc5bYx1jBkoRizLW4b/mq6qzLTFsBwiCAra2qj0T+gkDSakalJWmODc7EVubcquX LbspTxfuEWmnJCz97P89t2rMb; Received: from 97-122-82-115.hlrn.qwest.net ([97.122.82.115]:58478 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rxEHJ-000J1y-2Y; Wed, 17 Apr 2024 17:01:21 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH] Remove a couple of VLAs Date: Wed, 17 Apr 2024 17:01:12 -0600 Message-ID: <20240417230112.1791762-1-tom@tromey.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.82.115 X-Source-L: No X-Exim-ID: 1rxEHJ-000J1y-2Y X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-82-115.hlrn.qwest.net (localhost.localdomain) [97.122.82.115]:58478 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNsMXhkGk8mkd94nDxJbOsxyOWpoLsCNg6S3DPDRp0QyJiKIzV27BltlWEvKYzV11zLawaTHSEb6CgXT9VMjdRYYAodnIOIcZhk7zzw1IxWtNAwR+ZWE xzdxJNw/4iW/1Ekh8pzNYHD/An/cECvAKComgMrkFLP/1HBGJOneWdGlzYTvSnVTUbwEBpNb8Lw04biq8ius/as3KgnHHll2JlE= X-Spam-Status: No, score=-3021.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: I found a couple of spots where VLAs are in use but where they can easily be removed. In one spot, adding 'const' is enough -- and is already done in similar code elsewhere in the file. In another spot, one of two arrays will be used, so making the buffer large enough for both works. --- gdb/aarch64-tdep.c | 2 +- gdb/arc-linux-tdep.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 545ec872fd8..06eda102468 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -5713,7 +5713,7 @@ aarch64_process_record (struct gdbarch *gdbarch, struct regcache *regcache, CORE_ADDR insn_addr) { uint32_t rec_no = 0; - uint8_t insn_size = 4; + const uint8_t insn_size = 4; uint32_t ret = 0; gdb_byte buf[insn_size]; aarch64_insn_decode_record aarch64_record; diff --git a/gdb/arc-linux-tdep.c b/gdb/arc-linux-tdep.c index 54406ac5b90..30bd40c8027 100644 --- a/gdb/arc-linux-tdep.c +++ b/gdb/arc-linux-tdep.c @@ -174,6 +174,9 @@ arc_linux_is_sigtramp (const frame_info_ptr &this_frame) 0x22, 0x6f, 0x00, 0x3f /* swi */ }; + constexpr size_t max_insn_sz = std::max (sizeof (insns_be_hs), + sizeof (insns_be_700)); + gdb_byte arc_sigtramp_insns[sizeof (insns_be_700)]; size_t insns_sz; if (arc_mach_is_arcv2 (gdbarch)) @@ -200,7 +203,8 @@ arc_linux_is_sigtramp (const frame_info_ptr &this_frame) std::swap (arc_sigtramp_insns[i], arc_sigtramp_insns[i+1]); } - gdb_byte buf[insns_sz]; + gdb_assert (insns_sz <= max_insn_sz); + gdb_byte buf[max_insn_sz]; /* Read the memory at the PC. Since we are stopped, any breakpoint must have been removed. */ -- 2.44.0