Message ID | 7188b6a895ad46fba60e0f8ffa1a985e6dbe6eed.1665038133.git.research_trasio@irq.a4lg.com |
---|---|
State | Committed |
Headers |
Return-Path: <gdb-patches-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 F0496384B835 for <patchwork@sourceware.org>; Thu, 6 Oct 2022 06:37:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0496384B835 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665038232; bh=VDvPrj6FKP2SGvMaKJFZdyoBRv/jCFS3SVISv8jjvj8=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=YZwuIenkSDH4wyct/PLgVtw4H8MBSyCZXlQRZ9I5nVDjM6g7sC0Tj99Z6WqQxkbcY qViRoW6XL/zIWxSmxdGO9WzD5ZoW/Sdz2AKx1w3Kc7A1l07uYEMukve+qgjbzKwCO7 Ov6TU7eAzICRUbkFeBvo7u+1OhGQhw8i60uImZw8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id B2453384D17A for <gdb-patches@sourceware.org>; Thu, 6 Oct 2022 06:36:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2453384D17A Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id 8FFD8300089; Thu, 6 Oct 2022 06:36:46 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Andrew Burgess <aburgess@redhat.com>, Mike Frysinger <vapier@gentoo.org>, Stephane Carrez <Stephane.Carrez@gmail.com>, "Frank Ch . Eigler" <fche@redhat.com> Subject: [PATCH v2 1/7] sim: Add ATTRIBUTE_PRINTF Date: Thu, 6 Oct 2022 06:36:27 +0000 Message-Id: <7188b6a895ad46fba60e0f8ffa1a985e6dbe6eed.1665038133.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1665038133.git.research_trasio@irq.a4lg.com> References: <cover.1664095452.git.research_trasio@irq.a4lg.com> <cover.1665038133.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, 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: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> From: Tsukasa OI via Gdb-patches <gdb-patches@sourceware.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" <gdb-patches-bounces+patchwork=sourceware.org@sourceware.org> |
Series |
sim, sim/ARCH: Add ATTRIBUTE_PRINTF
|
|
Commit Message
Tsukasa OI
Oct. 6, 2022, 6:36 a.m. UTC
Clang generates a warning if the format string of a printf-like function is not a literal ("-Wformat-nonliteral"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). To avoid warnings on the printf-like wrapper, it requires proper __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason. This commit adds ATTRIBUTE_PRINTF to a printf-like function. --- sim/common/sim-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Tsukasa OI <research_trasio@irq.a4lg.com> writes: > Clang generates a warning if the format string of a printf-like function is > not a literal ("-Wformat-nonliteral"). On the default configuration, it > causes a build failure (unless "--disable-werror" is specified). > > To avoid warnings on the printf-like wrapper, it requires proper > __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason. > > This commit adds ATTRIBUTE_PRINTF to a printf-like function. > --- > sim/common/sim-utils.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c > index 259b14cce29..f079bb3f330 100644 > --- a/sim/common/sim-utils.c > +++ b/sim/common/sim-utils.c > @@ -146,7 +146,7 @@ sim_cpu_msg_prefix (sim_cpu *cpu) > > /* Cover fn to sim_io_eprintf. */ > > -void > +void ATTRIBUTE_PRINTF (2, 3) > sim_io_eprintf_cpu (sim_cpu *cpu, const char *fmt, ...) > { > SIM_DESC sd = CPU_STATE (cpu); I've pushed this patch, but I moved the ATTRIBUTE_PRINTF to the function declaration. Thanks, Andrew --- commit 7aaf9c03d143802302c49ed70d05766c9cf3cb5b Author: Tsukasa OI <research_trasio@irq.a4lg.com> Date: Thu Oct 6 06:36:27 2022 +0000 sim/common: Add ATTRIBUTE_PRINTF Clang generates a warning if the format string of a printf-like function is not a literal ("-Wformat-nonliteral"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). To avoid warnings on the printf-like wrapper, it requires proper __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason. This commit adds ATTRIBUTE_PRINTF to a printf-like function. diff --git a/sim/common/sim-cpu.h b/sim/common/sim-cpu.h index d8b2b9c494a..9e09a55bf81 100644 --- a/sim/common/sim-cpu.h +++ b/sim/common/sim-cpu.h @@ -137,7 +137,8 @@ extern sim_cpu *sim_cpu_lookup (SIM_DESC, const char *); /* Return prefix to use in cpu specific messages. */ extern const char *sim_cpu_msg_prefix (sim_cpu *); /* Cover fn to sim_io_eprintf. */ -extern void sim_io_eprintf_cpu (sim_cpu *, const char *, ...); +extern void sim_io_eprintf_cpu (sim_cpu *, const char *, ...) + ATTRIBUTE_PRINTF (2, 3); /* Get/set a pc value. */ #define CPU_PC_GET(cpu) ((* CPU_PC_FETCH (cpu)) (cpu))
diff --git a/sim/common/sim-utils.c b/sim/common/sim-utils.c index 259b14cce29..f079bb3f330 100644 --- a/sim/common/sim-utils.c +++ b/sim/common/sim-utils.c @@ -146,7 +146,7 @@ sim_cpu_msg_prefix (sim_cpu *cpu) /* Cover fn to sim_io_eprintf. */ -void +void ATTRIBUTE_PRINTF (2, 3) sim_io_eprintf_cpu (sim_cpu *cpu, const char *fmt, ...) { SIM_DESC sd = CPU_STATE (cpu);