From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4I8IN0pB2WADAgAAWB0awg (envelope-from ) for ; Sun, 27 Jun 2021 23:26:02 -0400 Received: by simark.ca (Postfix, from userid 112) id DF4FF1F1F2; Sun, 27 Jun 2021 23:26:02 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 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 524311E939 for ; Sun, 27 Jun 2021 23:26:02 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14BF4383B80A for ; Mon, 28 Jun 2021 03:26:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14BF4383B80A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1624850762; bh=lsWIyqiLXZ0zrvUzM4Ye+KYtpI/Xslg5LSoYY8rqv9s=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=TCaF7neCi/GFL+REYa+BTN9ifQmj1ehZgjWYlY9DcEeuwab6PK/EomuaXes8MHnn8 8LgRUxlHzNSyvgK7KXATMz5wQSwsjLjr2bWFFlnpphc6ilAWm+XCjrb/2bVI7JsM7b /aUqoRfG7l2+0O3BZF4ZyQqgM8gtH3uhlyaWB75w= Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by sourceware.org (Postfix) with ESMTP id 9AAFF383D02C for ; Mon, 28 Jun 2021 03:24:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9AAFF383D02C Received: from vapier.lan (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id EC46A33FA71 for ; Mon, 28 Jun 2021 03:24:43 +0000 (UTC) To: gdb-patches@sourceware.org Subject: [PATCH 2/3] sim: callback: add printf attributes Date: Sun, 27 Jun 2021 23:24:38 -0400 Message-Id: <20210628032439.14514-2-vapier@gentoo.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210628032439.14514-1-vapier@gentoo.org> References: <20210628032439.14514-1-vapier@gentoo.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: Mike Frysinger via Gdb-patches Reply-To: Mike Frysinger Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" This helps these funcs get printf format checking coverage. The sim-io.c hack as a result is a bit unfortunate, but the compiler throws warnings when printing with empty strings. In this one case, we actually want that due to the side-effect of the callback halting execution for us. --- include/sim/callback.h | 12 ++++++++---- sim/common/sim-io.c | 3 ++- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/sim/callback.h b/include/sim/callback.h index be72f4503e1a..06aa2d4be790 100644 --- a/include/sim/callback.h +++ b/include/sim/callback.h @@ -113,18 +113,22 @@ struct host_callback_struct int (*init) (host_callback *); /* depreciated, use vprintf_filtered - Talk to the user on a console. */ - void (*printf_filtered) (host_callback *, const char *, ...); + void (*printf_filtered) (host_callback *, const char *, ...) + ATTRIBUTE_PRINTF_2; /* Talk to the user on a console. */ - void (*vprintf_filtered) (host_callback *, const char *, va_list); + void (*vprintf_filtered) (host_callback *, const char *, va_list) + ATTRIBUTE_PRINTF (2, 0); /* Same as vprintf_filtered but to stderr. */ - void (*evprintf_filtered) (host_callback *, const char *, va_list); + void (*evprintf_filtered) (host_callback *, const char *, va_list) + ATTRIBUTE_PRINTF (2, 0); /* Print an error message and "exit". In the case of gdb "exiting" means doing a longjmp back to the main command loop. */ - void (*error) (host_callback *, const char *, ...) ATTRIBUTE_NORETURN; + void (*error) (host_callback *, const char *, ...) + ATTRIBUTE_NORETURN ATTRIBUTE_PRINTF_2; int last_errno; /* host format */ diff --git a/sim/common/sim-io.c b/sim/common/sim-io.c index e09a4af7ba2e..0d14e0dfc452 100644 --- a/sim/common/sim-io.c +++ b/sim/common/sim-io.c @@ -309,7 +309,8 @@ sim_io_error (SIM_DESC sd, va_start (ap, fmt); STATE_CALLBACK (sd)->evprintf_filtered (STATE_CALLBACK (sd), fmt, ap); va_end (ap); - STATE_CALLBACK (sd)->error (STATE_CALLBACK (sd), ""); + /* Printing a space here avoids empty printf compiler warnings. */ + STATE_CALLBACK (sd)->error (STATE_CALLBACK (sd), " "); } } -- 2.31.1