From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4HAQOs18RWPT3QkAWB0awg (envelope-from ) for ; Tue, 11 Oct 2022 10:25:17 -0400 Received: by simark.ca (Postfix, from userid 112) id EBB931E112; Tue, 11 Oct 2022 10:25:17 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=kEvFCE4j; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from 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 RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 8B5AE1E0D5 for ; Tue, 11 Oct 2022 10:25:17 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3C4253851164 for ; Tue, 11 Oct 2022 14:25:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3C4253851164 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665498317; bh=9qSv+6hmIzh/4Ve2HZOJz6ipOUVRDXJ6TWPyUoXS4u8=; h=To:Subject:In-Reply-To:References:Date:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=kEvFCE4j+62KM97DmhgMx95zIC7gtoxb4K/AMGGeiqlsaZihVcaZizl4TfTPvwOFh vZzySgykveLSxIhpjiksBE1uM3VhKWnOu5rIlTu4OlvfXMRG/b8y/34GIXRrYzibCP U1BdoBNq2OdOLwTRLFids/4WIaH5MmqRjlAJX3dI= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 1CE60385277D for ; Tue, 11 Oct 2022 14:24:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1CE60385277D Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-144-47KwVYjhPZSod5sguNlUOQ-1; Tue, 11 Oct 2022 10:24:40 -0400 X-MC-Unique: 47KwVYjhPZSod5sguNlUOQ-1 Received: by mail-wr1-f70.google.com with SMTP id l16-20020adfc790000000b00230c2505f96so1732514wrg.4 for ; Tue, 11 Oct 2022 07:24:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9qSv+6hmIzh/4Ve2HZOJz6ipOUVRDXJ6TWPyUoXS4u8=; b=NNZos72fhdyLm2tVCp81/ZvQeILVi7psVkkISIPF+ku2H3yDYoRvRkPGH1FHAEEiz4 vPKZ08VgAuCi/neCLSxI1/IP8+dTSkI34l2Uj3ZGNK47qPJxi0T8uF/mUK9KkucG6eqT ZRILJB+S+XLH4L4pZEo5odRUEZG53GFn3+Sdwv1CKUuVsO5jtikOfcVXbcPh8VeU7NYm l2s/kF+dwHxzgV6yXE9iqMNz2PfvmDGOyI+J2XVYqn+70tMx9PYmKtvGLZ1T/gTBALFh FksJq31zdPibxsOtLbp+9Nvav4yKMIHK57Er5DgoaphXrnW19YH6aU/uLEjWmFoMb+qV 1fHA== X-Gm-Message-State: ACrzQf1MbR5vEE+MoQBjVt/dmTnmfQrxWWfPaOOn5wBt1YDE+qAWcmmi 2LQ9X0wPDUtl3MRNxKNJ+uOhfmRxGMLWTzOfCt+xg5rgO9Rrj171s/xhOJkMrXuLcInT8pvvrsr Mm8b3ahfyrjbmHkItnQvJeg== X-Received: by 2002:a05:600c:4e52:b0:3b4:a828:1d84 with SMTP id e18-20020a05600c4e5200b003b4a8281d84mr22807632wmq.143.1665498279373; Tue, 11 Oct 2022 07:24:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tlOMWQ3FgmJb+q/3eNpvW9ePrNwHxFC8sGQC+5U6KfNZWYxMghpkf0mrJ8b9M86U3elJULA== X-Received: by 2002:a05:600c:4e52:b0:3b4:a828:1d84 with SMTP id e18-20020a05600c4e5200b003b4a8281d84mr22807623wmq.143.1665498279213; Tue, 11 Oct 2022 07:24:39 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id v127-20020a1cac85000000b003b505d26776sm18280464wme.5.2022.10.11.07.24.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 07:24:38 -0700 (PDT) To: Tsukasa OI , Tsukasa OI , Mike Frysinger , Stephane Carrez , "Frank Ch . Eigler" Subject: Re: [PATCH v2 1/7] sim: Add ATTRIBUTE_PRINTF In-Reply-To: <7188b6a895ad46fba60e0f8ffa1a985e6dbe6eed.1665038133.git.research_trasio@irq.a4lg.com> References: <7188b6a895ad46fba60e0f8ffa1a985e6dbe6eed.1665038133.git.research_trasio@irq.a4lg.com> Date: Tue, 11 Oct 2022 15:24:38 +0100 Message-ID: <878rlmcuah.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Andrew Burgess via Gdb-patches Reply-To: Andrew Burgess Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" Tsukasa OI 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 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))