From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id ek4uC7J9RWOt3gkAWB0awg (envelope-from ) for ; Tue, 11 Oct 2022 10:29:06 -0400 Received: by simark.ca (Postfix, from userid 112) id 1EBB71E112; Tue, 11 Oct 2022 10:29:06 -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=KuT56u8C; 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 C4FF11E0D5 for ; Tue, 11 Oct 2022 10:29:05 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7007F385381B for ; Tue, 11 Oct 2022 14:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7007F385381B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665498545; bh=jreLz11yTeNb5BtRZ/Npf8qux+1hNDJc1rJoZJJ+qZw=; 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=KuT56u8C9ffFbZPX3dy0L4iL00jmXdxPBK7XFc7K+ssyVHzHKnsGFJBEpVVep9ylF Lu0qMB7cSAgSyIevu4RdKyEBG2QDkrGE3M876q/6cBDm7jGIhb9dXhhlTBmH0aGE+z 3XM6mKYBiTo1EavDWRhKaLMWDLfPqo6e6PgmWEDA= 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 187C43853839 for ; Tue, 11 Oct 2022 14:27:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 187C43853839 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-204-0290P4GHNeSChyQVF0nLgg-1; Tue, 11 Oct 2022 10:27:33 -0400 X-MC-Unique: 0290P4GHNeSChyQVF0nLgg-1 Received: by mail-wm1-f70.google.com with SMTP id n19-20020a7bcbd3000000b003c4a72334e7so1959386wmi.8 for ; Tue, 11 Oct 2022 07:27:33 -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=jreLz11yTeNb5BtRZ/Npf8qux+1hNDJc1rJoZJJ+qZw=; b=8L3n37dUHHcTArdWIDdg2vMKOztOw4k2Af+VVvYQU6PRYY6lXSic6OoQ7CRTsgWTfu lHqucd4TjhEpgFltaMagXZq86ct4p/YpELs9FmfmuDAzAIj+yD6WkUhesSWXaMgFHxr3 tQNVnvUGEXHsnRC0pvU8KYGfkRk5FlDrkKj8Vj5LOpXeB4LzeWSSrCUD0jP/IRQ0w8lF ICJTpoL/jkAMUqWlW9JDq6fomzXCPqoGhhCf50jjMfgeVTEV3YbJ8oBJzVL+nuDAHMvR WTbavRDE8hMpeHg2JsJ9Daj+dTBb2TvcOy2PFrXVZZlST8/pp0pnBDsHMkVksJnjnC2z LMgQ== X-Gm-Message-State: ACrzQf0ybdpIwjfY579HN1NrsInk+dBYOdLN1LFjbc57q0xt/6YmEIHz cyaY5AgXOt1yskSg1dfaoywZICC7dQPnyO9+tWFoNsiglOPD2xbyioWhxOAHq66O4K5pFKDzjWa AGlIt4/VgjEFfZclo6EByDA== X-Received: by 2002:a05:600c:348c:b0:3b4:85b6:e7c5 with SMTP id a12-20020a05600c348c00b003b485b6e7c5mr16776612wmq.45.1665498451828; Tue, 11 Oct 2022 07:27:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6JJyMpkA6lj4FVbM2Trx9zq3nsCdF+YKIxMeGK0Wswgrg6A60uIx/3/xEB9csVgbz+Qjzl1Q== X-Received: by 2002:a05:600c:348c:b0:3b4:85b6:e7c5 with SMTP id a12-20020a05600c348c00b003b485b6e7c5mr16776595wmq.45.1665498451633; Tue, 11 Oct 2022 07:27:31 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id bh11-20020a05600c3d0b00b003b49ab8ff53sm13479973wmb.8.2022.10.11.07.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 07:27:31 -0700 (PDT) To: Tsukasa OI , Tsukasa OI , Mike Frysinger , Stephane Carrez , "Frank Ch . Eigler" Subject: Re: [PATCH v2 6/7] sim/ppc: Add ATTRIBUTE_PRINTF In-Reply-To: <9ee0350e33400397851bb55c129a675519e5f174.1665038133.git.research_trasio@irq.a4lg.com> References: <9ee0350e33400397851bb55c129a675519e5f174.1665038133.git.research_trasio@irq.a4lg.com> Date: Tue, 11 Oct 2022 15:27:30 +0100 Message-ID: <8735bucu5p.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 the printf-like functions. I've pushed this patch, but I moved all the ATTRIBUTE_PRINTF attributes to the function declarations. Also, one of the definitions already had an ATTRIBUTE_NORETURN, I moved this to the declaration too. Thanks, Andrew --- commit 3efe5b4d9e431f58a17e38d17419d6bcc3a4dd11 Author: Tsukasa OI Date: Thu Oct 6 06:36:32 2022 +0000 sim/ppc: 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 the printf-like functions. For the error function defined in sim_calls.c, the ATTRIBUTE_NORETURN has been moved to the function declaration. diff --git a/sim/ppc/misc.h b/sim/ppc/misc.h index 784ccfdd37b..08309134337 100644 --- a/sim/ppc/misc.h +++ b/sim/ppc/misc.h @@ -30,8 +30,8 @@ #include "ansidecl.h" #include "filter_filename.h" -extern void error -(const char *msg, ...); +extern void error (const char *msg, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); #define ASSERT(EXPRESSION) \ do { \ @@ -47,8 +47,8 @@ do { \ extern void *zalloc (long size); -extern void dumpf -(int indent, const char *msg, ...); +extern void dumpf (int indent, const char *msg, ...) + ATTRIBUTE_PRINTF (2, 3); extern unsigned target_a2i (int ms_bit_nr, diff --git a/sim/ppc/sim_callbacks.h b/sim/ppc/sim_callbacks.h index 08ccd258569..c5f23bf8d64 100644 --- a/sim/ppc/sim_callbacks.h +++ b/sim/ppc/sim_callbacks.h @@ -31,9 +31,8 @@ void sim_io_printf_filtered (const char *msg, ...) ATTRIBUTE_PRINTF_1; -void ATTRIBUTE_NORETURN error -(const char *msg, ...); - +extern void error (const char *msg, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); /* External environment: diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c index fbc327c94e0..729f6dcb6f3 100644 --- a/sim/ppc/sim_calls.c +++ b/sim/ppc/sim_calls.c @@ -388,7 +388,7 @@ sim_io_error (SIM_DESC sd, const char *fmt, ...) /****/ -void ATTRIBUTE_NORETURN +void error (const char *msg, ...) { va_list ap;