| Message ID | 20250914195345.366186-4-andrew@andrewhanson.dev |
|---|---|
| State | New |
| Headers |
Return-Path: <binutils-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 B254D3857C67 for <patchwork@sourceware.org>; Sun, 14 Sep 2025 20:00:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B254D3857C67 X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-43171.protonmail.ch (mail-43171.protonmail.ch [185.70.43.171]) by sourceware.org (Postfix) with ESMTPS id BA6233857C67 for <binutils@sourceware.org>; Sun, 14 Sep 2025 19:54:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BA6233857C67 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=andrewhanson.dev Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=andrewhanson.dev ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BA6233857C67 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=185.70.43.171 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757879653; cv=none; b=aM6mQO4bPwY0ncUR2OiJQwPiOqQug8SEtzvVf7V0VWrtBwEfCEZkNZJgJywuo5AUfm5U1TmryFmx+GYlFRcVD5Q08L4smQWCdU9ALvQKDM3QLJOCv4BgsUbhixMCejwDSiaRSh+SjMF16hXHSrMxlSkfEd/v5HZG3HVjCkKiCSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1757879653; c=relaxed/simple; bh=sOo5N6UC/Q8lPNBsM+pKFnDEv4X5r48QU2rwrHVrDbo=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=EsfQ8wZAZPKTK1jB1gmzivraaVknAjJo8E8gDZrDBr3QyGma5GNwPDAgdbRAMt5PzOm6iC5HfTlJb7nFaYqLpciR0W1UoY5SuALaZk3hVgNA8ap3wyCtL+elq0rz98PKw6xLz0Q6kGPzNWskpNBHlaNsmS6SiNwz4TRP2SijOf4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA6233857C67 X-Pm-Submission-Id: 4cPzPs1Bzxz1DDBs From: Andrew Hanson <andrew@andrewhanson.dev> To: binutils@sourceware.org Cc: Andrew Hanson <andrew@andrewhanson.dev> Subject: [PATCH 3/3] include/aout/aout64.h: guard ARCH_SIZE with defined() Date: Sun, 14 Sep 2025 15:52:47 -0400 Message-ID: <20250914195345.366186-4-andrew@andrewhanson.dev> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250914195345.366186-1-andrew@andrewhanson.dev> References: <20250914195345.366186-1-andrew@andrewhanson.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list <binutils.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/binutils>, <mailto:binutils-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/binutils/> List-Post: <mailto:binutils@sourceware.org> List-Help: <mailto:binutils-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/binutils>, <mailto:binutils-request@sourceware.org?subject=subscribe> Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org |
| Series |
Fix -Wundef warnings in include/ and bfd/
|
|
Commit Message
Andrew Hanson
Sept. 14, 2025, 7:52 p.m. UTC
Silence -Wundef when ARCH_SIZE is not defined by checking that it is
defined before comparing its value.
Signed-off-by: Andrew Hanson <andrew@andrewhanson.dev>
---
include/aout/aout64.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 14.09.2025 21:52, Andrew Hanson wrote: > Silence -Wundef when ARCH_SIZE is not defined by checking that it is > defined before comparing its value. > > Signed-off-by: Andrew Hanson <andrew@andrewhanson.dev> Oh, interesting - there is an S-o-b here. Why not on the earlier two patches? > --- a/include/aout/aout64.h > +++ b/include/aout/aout64.h > @@ -43,7 +43,7 @@ struct external_exec > > /* Magic numbers for a.out files. */ > > -#if ARCH_SIZE==64 > +#if defined(ARCH_SIZE) && ARCH_SIZE == 64 > #define OMAGIC 0x1001 /* Code indicating object file. */ > #define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */ > #define NMAGIC 0x1003 /* Code indicating pure executable. */ I'm not quite sure here. Yes, what you do fits what happens if the compiler silently uses 0 as value when it's undefined. I wonder though whether the #else not kicking in when ARCH_SIZE isn't defined wouldn't be better. Largely depends on how the file is used right now, i.e. how much fallout there would be. Jan
On Mon, Sep 15, 2025 at 05:03:15AM +0200, Jan Beulich wrote: > Yes, what you do fits what happens if the > compiler silently uses 0 as value when it's undefined. It must. See ISO/IEC 9899:1999 (E) 6.10.1 para 3. Correct programs do not need to write "#if defined(X) && X" except to silence the warning. Plain "#if X" is fine. This isn't to say I oppose the patch. Fussing over warnings is OK too. ;-)
On 15.09.2025 06:26, Andrew Hanson wrote: > Sorry about the missing sign-offs on the first two patches. I'm still getting used to the tooling. Btw, please also don't reply privately; keep the list in Cc. > I agree the question about if the else block should trigger or not is complicated. I would be tempted to just keep the previous behavior regarding the else statement because I don't know enough about the project to know the downstream effects. > > It would almost certainly be worth adding a warning for the user if ARCH_SIZE is undefined. It might also make sense to discuss deprecating the “undefined -> 32-bit” fallback but I don’t feel comfortable making that call. Okay, so let's go with what you had sent. Jan
> Okay, so let's go with what you had sent. That sounds good, thanks. I did do a bit of digging regarding that else block. Atleast these four files (bfd/aout-ns32k.c, bfd/aout-target.h, bfd/aoutx.h, bfd/ecoff.c) include aout/aout64.h and use the 32 magic numbers (OMAGIC 0407, NMAGIC 0410, IMAGIC 0411, ZMAGIC 0413, QMAGIC 0314, BMAGIC 0415) without checking ARCH_SIZE, so they likely depend on the current behavior. Just FYI. On Monday, September 15th, 2025 at 10:21 AM, Jan Beulich <jbeulich@suse.com> wrote: > On 15.09.2025 06:26, Andrew Hanson wrote: > > > Sorry about the missing sign-offs on the first two patches. I'm still getting used to the tooling. > > > Btw, please also don't reply privately; keep the list in Cc. > > > I agree the question about if the else block should trigger or not is complicated. I would be tempted to just keep the previous behavior regarding the else statement because I don't know enough about the project to know the downstream effects. > > > > It would almost certainly be worth adding a warning for the user if ARCH_SIZE is undefined. It might also make sense to discuss deprecating the “undefined -> 32-bit” fallback but I don’t feel comfortable making that call. > > > Okay, so let's go with what you had sent. > > Jan
diff --git a/include/aout/aout64.h b/include/aout/aout64.h index a85a801a2d7..dbe25efd752 100644 --- a/include/aout/aout64.h +++ b/include/aout/aout64.h @@ -43,7 +43,7 @@ struct external_exec /* Magic numbers for a.out files. */ -#if ARCH_SIZE==64 +#if defined(ARCH_SIZE) && ARCH_SIZE == 64 #define OMAGIC 0x1001 /* Code indicating object file. */ #define ZMAGIC 0x1002 /* Code indicating demand-paged executable. */ #define NMAGIC 0x1003 /* Code indicating pure executable. */