From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id 906313858401; Tue, 11 Oct 2022 14:19:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 906313858401 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1665497946; bh=IAkLmdh9OiNQjxc5eM2vSv7i2zQPEb+gxGAMAPQ67ss=; h=From:To:Subject:Date:From; b=P6mVnCfavMG+vt16TvuqMrzsnlX5XbQpmYWGxFxSNNweezFRj8EWnky62/PRpcCUH X2roXGO0T5608N/0K/1BO5f94xGRpYFqa/KPH5+CKIKTLdGksk6mZfITm1uRnTod9t iuaXuDYi+Ev4JoZe+GBi3jakI8wBMcZvBlYCpotU= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] sim/ppc: Add ATTRIBUTE_PRINTF X-Act-Checkin: binutils-gdb X-Git-Author: Tsukasa OI X-Git-Refname: refs/heads/master X-Git-Oldrev: 7f9495b21380c0184dde72920bcca37be9d76b9d X-Git-Newrev: 3efe5b4d9e431f58a17e38d17419d6bcc3a4dd11 Message-Id: <20221011141906.906313858401@sourceware.org> Date: Tue, 11 Oct 2022 14:19:06 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3efe5b4d9e43= 1f58a17e38d17419d6bcc3a4dd11 commit 3efe5b4d9e431f58a17e38d17419d6bcc3a4dd11 Author: Tsukasa OI Date: Thu Oct 6 06:36:32 2022 +0000 sim/ppc: Add ATTRIBUTE_PRINTF =20 Clang generates a warning if the format string of a printf-like functio= n is not a literal ("-Wformat-nonliteral"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). =20 To avoid warnings on the printf-like wrapper, it requires proper __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this rea= son. =20 This commit adds ATTRIBUTE_PRINTF to the printf-like functions. =20 For the error function defined in sim_calls.c, the ATTRIBUTE_NORETURN has been moved to the function declaration. Diff: --- sim/ppc/misc.h | 8 ++++---- sim/ppc/sim_callbacks.h | 5 ++--- sim/ppc/sim_calls.c | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) 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" =20 -extern void error -(const char *msg, ...); +extern void error (const char *msg, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); =20 #define ASSERT(EXPRESSION) \ do { \ @@ -47,8 +47,8 @@ do { \ extern void *zalloc (long size); =20 -extern void dumpf -(int indent, const char *msg, ...); +extern void dumpf (int indent, const char *msg, ...) + ATTRIBUTE_PRINTF (2, 3); =20 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; =20 -void ATTRIBUTE_NORETURN error -(const char *msg, ...); - +extern void error (const char *msg, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF (1, 2); =20 /* External environment: =20 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, ...) =20 /****/ =20 -void ATTRIBUTE_NORETURN +void error (const char *msg, ...) { va_list ap;