From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7984D385828D for ; Wed, 5 Oct 2022 10:57:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7984D385828D Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-377-mpQ6Y2UpO9asnvQAbt_JqA-1; Wed, 05 Oct 2022 06:57:50 -0400 X-MC-Unique: mpQ6Y2UpO9asnvQAbt_JqA-1 Received: by mail-wr1-f72.google.com with SMTP id q10-20020adfaa4a000000b0022cd70377e4so5122804wrd.19 for ; Wed, 05 Oct 2022 03:57:50 -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=lNfXm2xmRflrYPOgnVLn/Qb6lkdXV5/FxSp7LYnLDw0=; b=rLn1OsVvXMtLokl1an+doNvhy0T9jZotkXlK6POs6HIFfwgFoik+z7yNAd3VTg+seo bX62RPl/N8eHrjNnfW9txfgKp5Hlbkya4Wl0rXJaJm7ls875zg2Kse6WWBccEhd/geci BO7QDZ+48dzB0RIsT16wavaegxJFxj/8Z0tQdeQb3eToGYMw/oFJ0SO9S2zs+jsw8erK 7yq0tqjaNUEEm8NUnQx50rDIV1jve338njYtMS+Ypd1l9lZJLiR4lYxUB9DaZQ2Gt2Or /xA1PJOk5h1r2I0Q533+fRMVDOAK9KvpMS8IB4HWhfWoZTnEXU3HUwVOVEB0cPWfFQer sfkg== X-Gm-Message-State: ACrzQf1rmBh+BfCH48JxzN1SpQMWWrbDNfnH4SRdaUc6aKuZr0zQkWKQ gczWr9Md99wL/mDYiu0vCLpXVcdkLzpGwvG9M9ATMXlHIlt1Z2bTdsq+Q8gWgDkiJNxBjyD6SpL NHLirAjs06OMBHkrn7SqQBQ== X-Received: by 2002:a5d:64e8:0:b0:22a:bbb0:fa with SMTP id g8-20020a5d64e8000000b0022abbb000famr20094067wri.372.1664967469348; Wed, 05 Oct 2022 03:57:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7znbd+YZuOo1ADw1uzM4qDhuh6dXCJK6Au+V0pkRRAZYoKav8qw8T5IQXlQgBXzq0XeZym3w== X-Received: by 2002:a5d:64e8:0:b0:22a:bbb0:fa with SMTP id g8-20020a5d64e8000000b0022abbb000famr20094053wri.372.1664967469072; Wed, 05 Oct 2022 03:57:49 -0700 (PDT) Received: from localhost (52.72.115.87.dyn.plus.net. [87.115.72.52]) by smtp.gmail.com with ESMTPSA id c5-20020a056000104500b0022a3a887ceasm1725058wrx.49.2022.10.05.03.57.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Oct 2022 03:57:48 -0700 (PDT) From: Andrew Burgess To: Tsukasa OI , Tsukasa OI , Mike Frysinger , Stephane Carrez , "Frank Ch . Eigler" Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 6/7] sim/ppc: Add ATTRIBUTE_PRINTF In-Reply-To: <924d86933d2e2b6da6940f13e64ef0ab5008a797.1664095452.git.research_trasio@irq.a4lg.com> References: <924d86933d2e2b6da6940f13e64ef0ab5008a797.1664095452.git.research_trasio@irq.a4lg.com> Date: Wed, 05 Oct 2022 11:57:47 +0100 Message-ID: <87mtaafsgk.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Oct 2022 10:57:53 -0000 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. > > sim/ChangeLog: > > * ppc/main.c (error): Add ATTRIBUTE_PRINTF. > * ppc/misc.c (error, dumpf): Likewise. > * ppc/sim_calls.c (error): Likewise. > --- > sim/ppc/main.c | 2 +- > sim/ppc/misc.c | 4 ++-- > sim/ppc/sim_calls.c | 2 +- > 3 files changed, 4 insertions(+), 4 deletions(-) > > diff --git a/sim/ppc/main.c b/sim/ppc/main.c > index 83b629ec14a..4a88166106f 100644 > --- a/sim/ppc/main.c > +++ b/sim/ppc/main.c > @@ -68,7 +68,7 @@ sim_io_printf_filtered(const char *msg, ...) > va_end(ap); > } > > -void > +void ATTRIBUTE_PRINTF(1, 2) > error (const char *msg, ...) I notice in this patch, and the previous one, you've added ATTRIBUTE_PRINTF to both the declaration, and the definition of some functions. Is this required? I thought we only needed the attribute on the declaration. In this case this difference is even more pronounced as you've added the ATTRIBUTE_PRINTF, but the declaration also has ATTRIBUTE_NORETURN, which you haven't added to the definition. My preference would be to only have the attributes on the declaration if that is sufficient. Could you test that change and see if your build issues are still resolved. Thanks, Andrew > { > va_list ap; > diff --git a/sim/ppc/misc.c b/sim/ppc/misc.c > index 8f2581e3ef3..71cda9fa298 100644 > --- a/sim/ppc/misc.c > +++ b/sim/ppc/misc.c > @@ -28,7 +28,7 @@ > #include > #include > > -void > +void ATTRIBUTE_PRINTF(1, 2) > error (const char *msg, ...) > { > va_list ap; > @@ -48,7 +48,7 @@ zalloc(long size) > return memory; > } > > -void > +void ATTRIBUTE_PRINTF(2, 3) > dumpf (int indent, const char *msg, ...) > { > va_list ap; > diff --git a/sim/ppc/sim_calls.c b/sim/ppc/sim_calls.c > index fbc327c94e0..b0ed3d4c3cc 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 ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF(1, 2) > error (const char *msg, ...) > { > va_list ap; > -- > 2.34.1