| Message ID | 20240717220334.2887552-1-slyich@gmail.com |
|---|---|
| State | Committed |
| Headers |
Return-Path: <elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4E415385E82D for <patchwork@sourceware.org>; Wed, 17 Jul 2024 22:03:58 +0000 (GMT) X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by sourceware.org (Postfix) with ESMTPS id C9153385841D for <elfutils-devel@sourceware.org>; Wed, 17 Jul 2024 22:03:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C9153385841D 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 C9153385841D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::334 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721253829; cv=none; b=suBuFtcC2mfe/xNFV1U8NjVp09wmQ5AOyG7R8xjptV6HKTtg+ED16WP8lHDrJjVoFhLXVPYdt3ZjtY0i7SNx0vHBaMCVyE0bHZuobGnXZGUG/eFJQlR467TZL853OhqRcU80L7+NwAIpDRx4UjKSi6wQEQTxGon1EBY50aFn6cQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1721253829; c=relaxed/simple; bh=ocMfP00z7sabTyfMBA8dOeubBcSf+iaTnmGkg2Opy10=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=aC9DX5gM61EC4x9ptyE1XRwFtxyTaLe2wT9hu8AMsYtissf/og65O2/zL0bmJTtN4f++a0T5eZ14DbHzW5NKyr4gqovC+aYaECdQsntVgyWirfBSj/w71NGYkI9rIcc0ZcIi1L50rtAIx74C7YXxXNM3C9wWeQr2FdOBso/yGJs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-426526d30aaso1131325e9.0 for <elfutils-devel@sourceware.org>; Wed, 17 Jul 2024 15:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721253826; x=1721858626; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dnlFMCPr/PLhDu+kw+xckgKJGwuz8nOdQnyGDFjKGas=; b=isQT3WQwQ8xRc/LWw+9LtlnNFfQWUeG8QH1vvLGL8QHJEtORHTM0D/W9UG9g7Jtqct Yxz+4RBnSuzQzyU07n2Wq7zNyOH89rFHlss8l7QMv0YLRzOW596iXPvMVtStHhqwEsmP qbdQemRPKXK7prn8Q7muEQlJXZqAToy2seRmZIfP0jVMgT0BOO9JqEAducWE6tTxz4H5 GqOPBx+60EwCO1LlI0recze22kXvuIK8NjU12LsYQXpGs3NZjB9Gg4v2p8lI//KsWg1y uIZ6OV4DpE7fOMuLldOdDtpyRQTl710EOz5O75V3to5fFULD6SLj0+iSth6AwLCjnC2Y ZftQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721253826; x=1721858626; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dnlFMCPr/PLhDu+kw+xckgKJGwuz8nOdQnyGDFjKGas=; b=nXRx7wISIZk2CDsB/6qrFN9cs3wRO22A20XphEvxI3Oz36VS01nfMXw/yJBT+L0FRu i/AiSjDVG+yluks5EW5bgVP2neFICp4kHgswq1eueYt66Uu3Xo5VoyetXHzoCRC64A2d 7Fs1sRW/mRa5Ceq0kbiN7mSo38p0luBHWFK9xRGJTOdS77JRjqfaR82feiwM17WzWcFp S4zAU4z9Zb7/A+6daZsHFd54eLiEfCF7xOhmyJ1jLIQuwJuuQEtUaE3vFXmO4TC6IIfc f2alRKlcgjhTui30rb37KJfFn0zlE6F9I5C4uIBasvVOVYUM474TyOdzZEIkJj/Ci3p/ MF+A== X-Gm-Message-State: AOJu0Yymg1O7Rz/E7g21w9mbKZ5MfQpAbQFuo3mJDHnjxhRGzs04OUhX NJ5Kg3fXi2g1caNEZ4tCY5neWNYUnPlmIgcNfvGsfDNkQvENrvvw X-Google-Smtp-Source: AGHT+IES4+nJuTREfdjsZLHzD2WgxbdB+5X3MU8XbG7Ezr3YqvZ/Q11jq7/3HAyl98xqePh4/CPXUA== X-Received: by 2002:a05:600c:3ca6:b0:426:5c9b:dee6 with SMTP id 5b1f17b1804b1-427c2d2dc98mr19677335e9.26.1721253826323; Wed, 17 Jul 2024 15:03:46 -0700 (PDT) Received: from nz.home (host86-152-202-149.range86-152.btcentralplus.com. [86.152.202.149]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3680dabf3bdsm12648284f8f.30.2024.07.17.15.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jul 2024 15:03:45 -0700 (PDT) Received: by nz.home (Postfix, from userid 1000) id E4BA41D9D5CB63; Wed, 17 Jul 2024 23:03:44 +0100 (BST) From: Sergei Trofimovich <slyich@gmail.com> To: elfutils-devel@sourceware.org Cc: Mark Wielaard <mark@klomp.org>, Sergei Trofimovich <slyich@gmail.com> Subject: [PATCH v2] backends: allocate enough stace for null terminator Date: Wed, 17 Jul 2024 23:03:34 +0100 Message-ID: <20240717220334.2887552-1-slyich@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <08740f22f78b079fe86ae3a7a6ad849391120b66.camel@klomp.org> References: <08740f22f78b079fe86ae3a7a6ad849391120b66.camel@klomp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, 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 X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list <elfutils-devel.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/elfutils-devel/> List-Post: <mailto:elfutils-devel@sourceware.org> List-Help: <mailto:elfutils-devel-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/elfutils-devel>, <mailto:elfutils-devel-request@sourceware.org?subject=subscribe> Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
[v2] backends: allocate enough stace for null terminator
|
|
Commit Message
Sergei Trofimovich
July 17, 2024, 10:03 p.m. UTC
`gcc-15` added a new warning in https://gcc.gnu.org/PR115185:
i386_regs.c:88:11: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization]
88 | "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip"
| ^~~~
`elfutils` does not need to store '\0'. We could either initialize the
arrays with individual bytes or allocate extra byte for null.
This change initializes the array bytewise.
* backends/i386_regs.c (i386_register_info): Initialize the
array bytewise to fix gcc-15 warning.
* backends/x86_64_regs.c (x86_64_register_info): Ditto.
Signed-off-by: Sergei Trofimovich <slyich@gmail.com>
---
backends/i386_regs.c | 10 +++++++++-
backends/x86_64_regs.c | 9 ++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
Comments
Hi Sergei, On Wed, 2024-07-17 at 23:03 +0100, Sergei Trofimovich wrote: > `gcc-15` added a new warning in https://gcc.gnu.org/PR115185: > > i386_regs.c:88:11: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization] > 88 | "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip" > | ^~~~ > > `elfutils` does not need to store '\0'. We could either initialize the > arrays with individual bytes or allocate extra byte for null. > > This change initializes the array bytewise. > > * backends/i386_regs.c (i386_register_info): Initialize the > array bytewise to fix gcc-15 warning. > * backends/x86_64_regs.c (x86_64_register_info): Ditto. This looks good. I have pushed it to main. Will this warning be enabled by -Wall or -Wextra (both of which are enabled by default for elfutils builds)? Or would be need to enable it explicitly? Thanks, Mark
On Thu, 18 Jul 2024 18:49:54 +0200 Mark Wielaard <mark@klomp.org> wrote: > Hi Sergei, > > On Wed, 2024-07-17 at 23:03 +0100, Sergei Trofimovich wrote: > > `gcc-15` added a new warning in https://gcc.gnu.org/PR115185: > > > > i386_regs.c:88:11: error: initializer-string for array of 'char' is too long [-Werror=unterminated-string-initialization] > > 88 | "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip" > > | ^~~~ > > > > `elfutils` does not need to store '\0'. We could either initialize the > > arrays with individual bytes or allocate extra byte for null. > > > > This change initializes the array bytewise. > > > > * backends/i386_regs.c (i386_register_info): Initialize the > > array bytewise to fix gcc-15 warning. > > * backends/x86_64_regs.c (x86_64_register_info): Ditto. > > This looks good. I have pushed it to main. > > Will this warning be enabled by -Wall or -Wextra (both of which are > enabled by default for elfutils builds)? Or would be need to enable it > explicitly? Thank you! It's enabled only with `-Wextra` (and that's how I encountered on build failure in `elfutils`).
diff --git a/backends/i386_regs.c b/backends/i386_regs.c index 7ec93bb9..ead55ef7 100644 --- a/backends/i386_regs.c +++ b/backends/i386_regs.c @@ -85,7 +85,15 @@ i386_register_info (Ebl *ebl __attribute__ ((unused)), { static const char baseregs[][2] = { - "ax", "cx", "dx", "bx", "sp", "bp", "si", "di", "ip" + {'a', 'x'}, + {'c', 'x'}, + {'d', 'x'}, + {'b', 'x'}, + {'s', 'p'}, + {'b', 'p'}, + {'s', 'i'}, + {'d', 'i'}, + {'i', 'p'}, }; case 4: diff --git a/backends/x86_64_regs.c b/backends/x86_64_regs.c index ef987daf..dab8f27f 100644 --- a/backends/x86_64_regs.c +++ b/backends/x86_64_regs.c @@ -82,7 +82,14 @@ x86_64_register_info (Ebl *ebl __attribute__ ((unused)), { static const char baseregs[][2] = { - "ax", "dx", "cx", "bx", "si", "di", "bp", "sp" + {'a', 'x'}, + {'d', 'x'}, + {'c', 'x'}, + {'b', 'x'}, + {'s', 'i'}, + {'d', 'i'}, + {'b', 'p'}, + {'s', 'p'}, }; case 6 ... 7: