From patchwork Tue Jul 25 22:21:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 27188 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 2E4D9532D; Wed, 26 Jul 2017 00:21:31 +0200 (CEST) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by dpdk.org (Postfix) with ESMTP id 510EE37B4 for ; Wed, 26 Jul 2017 00:21:20 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E146421319; Tue, 25 Jul 2017 18:21:19 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Tue, 25 Jul 2017 18:21:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=Fo+ 9j3f4ePBT7SuMQWuc1xpFRMuaXDFe0VtME452yvQ=; b=d5Qi1FDWJm0AwAO1f1W +PI98Dm9/ZI2zFjfzfUs0Ox4Sufn2VVj2K7wSVYdbq5+wgjk3P9sA7X1rnhp2TMt hVJLz5ARnNA4NrZohPuychfdlRA6LKnLHcMQO5rFKMFOU9BlPT/8OE4sG50TCGSn 1lzvjPiKNEZOY//SpJjs1v+k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc :x-sasl-enc; s=fm1; bh=Fo+9j3f4ePBT7SuMQWuc1xpFRMuaXDFe0VtME452y vQ=; b=h/3MvbGI90SzSb9zhiVxE4FkfUBeIlfs/B/TGNNfDbPLHj0v3yN8deYyW JNZ9dF3b3SrfJx1LlRc6kI3/eiHPws6NH9nPb6k2t+yGx3GeaI662V6vk5Lyx0ai O+yCd/qUWZoFI77oYO0pFvtMDx/nwYqOjOV8RCzeLDSVrFRogjAeTeDAnF36WfHI cE/lR5bwlq8Nb6hgDA0WZDD2OgifOAfGK47l+5p9/u6P/HCMqH+idQ/P7QF4LQ60 VkovdZc8dGQlJiI6MFmTrxd5rxoxph7snMGfQ2iA6uPp+Wzu/wKt2K9UVvtrUzVH 5LKEMjLnSS+AICadC7R0D0k+TffdQ== X-ME-Sender: X-Sasl-enc: fwZlHuXyC47dYmacyMTNpGQ0ZEpvkIEgTNAaetFmvzhP 1501021279 Received: from xps.domain.com (bzq-164-168-31-206.red.bezeqint.net [31.168.164.206]) by mail.messagingengine.com (Postfix) with ESMTPA id E5BBC24130; Tue, 25 Jul 2017 18:21:18 -0400 (EDT) From: Thomas Monjalon To: keith.wiles@intel.com Cc: dev@dpdk.org Date: Wed, 26 Jul 2017 01:21:04 +0300 Message-Id: <20170725222107.23203-4-thomas@monjalon.net> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170725222107.23203-1-thomas@monjalon.net> References: <20170725222107.23203-1-thomas@monjalon.net> Subject: [dpdk-dev] [pktgen PATCH 3/6] fix compilation of printf based functions X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Functions with printf style must be declared with __attribute__((format(printf, Otherwise there is this compilation error: error: format string is not a string literal Other errors fixed: - "%*s" must match an int value - "% " is not a valid printf format string Signed-off-by: Thomas Monjalon --- app/Makefile | 3 --- app/pktgen-log.c | 1 + lib/cli/cli.c | 2 +- lib/cli/cli_common.h | 1 + lib/cli/cli_map.c | 2 +- lib/cli/cli_scrn.c | 3 +++ lib/cli/cli_scrn.h | 1 + 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/Makefile b/app/Makefile index b290c8d..5bddb07 100644 --- a/app/Makefile +++ b/app/Makefile @@ -43,9 +43,6 @@ include $(RTE_SDK)/mk/rte.vars.mk # binary name APP = pktgen -CFLAGS_commands.o := -Wno-format-nonliteral -CFLAGS_pktgen-log.o := -Wno-format-nonliteral - CFLAGS += -O3 -g $(WERROR_FLAGS) -fno-stack-protector CFLAGS += -I$(RTE_SRCDIR) -I$(RTE_SRCDIR)/../lib/common diff --git a/app/pktgen-log.c b/app/pktgen-log.c index 019834c..598eb1f 100644 --- a/app/pktgen-log.c +++ b/app/pktgen-log.c @@ -99,6 +99,7 @@ pktgen_log_set_screen_level(int level) /* Log the provided message to the log screen and optionally a file. */ void +__attribute__((format(printf, 5, 6))) pktgen_log(int level, const char *file, long line, const char *func, const char *fmt, ...) { diff --git a/lib/cli/cli.c b/lib/cli/cli.c index d833947..bba0eb3 100644 --- a/lib/cli/cli.c +++ b/lib/cli/cli.c @@ -696,7 +696,7 @@ cli_pause(const char *msg, const char *keys) if (cli_poll(&c)) if (strchr(keys, c)) { /* clear the line of the prompt */ - cli_printf("\r%*s\r", strlen(prompt), " "); + cli_printf("\r%*s\r", (int)strlen(prompt), " "); return c; } } while (this_cli->quit_flag == 0); diff --git a/lib/cli/cli_common.h b/lib/cli/cli_common.h index 476d40e..59c2de5 100644 --- a/lib/cli/cli_common.h +++ b/lib/cli/cli_common.h @@ -71,6 +71,7 @@ extern "C" { */ static inline void +__attribute__((format(printf, 1, 2))) cli_printf(const char *fmt, ...) { va_list vaList; diff --git a/lib/cli/cli_map.c b/lib/cli/cli_map.c index 4fd5181..0fa34f8 100644 --- a/lib/cli/cli_map.c +++ b/lib/cli/cli_map.c @@ -162,7 +162,7 @@ decode_map(const char *fmt) } switch (fmt[1]) { - case '%': cli_printf("% "); break; + case '%': cli_printf("%% "); break; case 'd': cli_printf("<32bit number> "); break; case 'D': cli_printf("<64bit number> "); break; case 'h': cli_printf("<32bit hex> "); break; diff --git a/lib/cli/cli_scrn.c b/lib/cli/cli_scrn.c index b195e92..692698e 100644 --- a/lib/cli/cli_scrn.c +++ b/lib/cli/cli_scrn.c @@ -50,6 +50,7 @@ RTE_DEFINE_PER_LCORE(struct cli_scrn *, scrn); void +__attribute__((format(printf, 3, 4))) scrn_printf(int16_t r, int16_t c, const char *fmt, ...) { va_list vaList; @@ -63,6 +64,7 @@ scrn_printf(int16_t r, int16_t c, const char *fmt, ...) } void +__attribute__((format(printf, 3, 4))) scrn_cprintf(int16_t r, int16_t ncols, const char *fmt, ...) { va_list vaList; @@ -80,6 +82,7 @@ scrn_cprintf(int16_t r, int16_t ncols, const char *fmt, ...) } void +__attribute__((format(printf, 4, 5))) scrn_fprintf(int16_t r, int16_t c, FILE *f, const char *fmt, ...) { va_list vaList; diff --git a/lib/cli/cli_scrn.h b/lib/cli/cli_scrn.h index c841623..1bfb8f0 100644 --- a/lib/cli/cli_scrn.h +++ b/lib/cli/cli_scrn.h @@ -106,6 +106,7 @@ typedef enum { typedef uint8_t cli_rgb_t; static inline void +__attribute__((format(printf, 1, 2))) scrn_puts(const char *fmt, ...) { struct cli_scrn *scrn = this_scrn;