From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf1-f194.google.com (mail-pf1-f194.google.com [209.85.210.194]) by dpdk.org (Postfix) with ESMTP id 5BE9D1B9EF for ; Fri, 12 Oct 2018 16:54:32 +0200 (CEST) Received: by mail-pf1-f194.google.com with SMTP id l81-v6so6332302pfg.3 for ; Fri, 12 Oct 2018 07:54:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=M9ycEm5XsUfIKkIKsf4/fB9tNCBn0dmnJ2xjAkDnUJ8=; b=OOpDmza4MgS6jpXkgjSeoMkSt82h4oAR8LHSx58V0hacNovJKzHAWRPPU4v1rJ9Yqu wmENHdbemXTaNFQJ2USQMglRAAfXZnazQn+HVXCQH9FNP2Mf+oUzib9DQZkKAB+2tutQ bnUlM7YWH3TXP2rQbGJ2rgIQBmVX/NTeHsippnBhte+qAucT2d30p7V+RbP32HHqO6xn WsdMvEY4PZYWnqXGfZZk/DJs0WpZpyKOajSHEZWYvSrGlIC3ZwjzwlmAdcfjDHKBOT+H 2uCr0sLfvSmehhfJZ6m0ZaGr5nXPFD7gEXRiGCVOwNK2y5ihtfPrk+X3RxJhmRGtNaGv JEIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=M9ycEm5XsUfIKkIKsf4/fB9tNCBn0dmnJ2xjAkDnUJ8=; b=ucO40pQl9nCv/LxO9ve8BOaccz9pPApiCbaChBtM3E+Tt5QqmLN6L17I3oThsY/xhH sDLZ7yIuYBDFNK0vWyeI2VJa1ZLZpSJzybFKIownK4QcozZYtYxZY57H3GKYkPidP4Pq tXu9o/KuovpJtHGEQ9m77VBv91/0EKxLmmILdtWKg63rYL3wBkS6JvPmTk4voYU+Fvkj 35U0T/qTSWHq0JGrbdCQmBEyXAJN8V4z7IGdGUv5PdBnrSZg1j+G0xHg5n686sf1IW+9 Oz6QStxAiq+ce8Bk9XkFZfkbOES3OlEs/jTQ/R8HL3Aqf+6OMydBmOUIntgv47r6wg0M bNLw== X-Gm-Message-State: ABuFfohksP3T+9Qyue0MwEa5YFgfWwoMi0S2fEaQKySo4LZfirxGqyQb psOxmPk48BHVeuAvO/uIP59Sgw== X-Google-Smtp-Source: ACcGV63nCN42VUpkNtWKgH0C0aw1++LwwtWOkRfMq+7qHLvyyT2QvvSvXaKZ6odpuzvKVgdMVQVo7w== X-Received: by 2002:a62:f553:: with SMTP id n80-v6mr6401053pfh.59.1539356071403; Fri, 12 Oct 2018 07:54:31 -0700 (PDT) Received: from xeon-e3 (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id 76-v6sm3847552pfk.134.2018.10.12.07.54.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 12 Oct 2018 07:54:31 -0700 (PDT) Date: Fri, 12 Oct 2018 07:54:24 -0700 From: Stephen Hemminger To: Adrien Mazarguil Cc: Ferruh Yigit , thomas@monjalon.net, dev@dpdk.org, Gaetan Rivet Message-ID: <20181012075424.79383f32@xeon-e3> In-Reply-To: <20181012124357.GR18937@6wind.com> References: <20181011175940.6800-1-stephen@networkplumber.org> <98717fc3-c3dd-cc4f-e5ff-b5310e47d6ee@intel.com> <696e6f90-3d0c-acd4-d72d-bbebe1ff6f54@intel.com> <20181012124357.GR18937@6wind.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] ethdev: add function name to log message 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: , X-List-Received-Date: Fri, 12 Oct 2018 14:54:32 -0000 On Fri, 12 Oct 2018 14:43:57 +0200 Adrien Mazarguil wrote: > On Fri, Oct 12, 2018 at 11:45:01AM +0100, Ferruh Yigit wrote: > > On 10/12/2018 11:42 AM, Ferruh Yigit wrote: > > > On 10/11/2018 6:59 PM, Stephen Hemminger wrote: > > >> @@ -161,8 +161,9 @@ extern "C" { > > >> > > >> extern int rte_eth_dev_logtype; > > >> > > >> -#define RTE_ETHDEV_LOG(level, ...) \ > > >> - rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, "" __VA_ARGS__) > > >> +#define RTE_ETHDEV_LOG(level, fmt, ...) \ > > >> + rte_log(RTE_LOG_ ## level, rte_eth_dev_logtype, \ > > >> + "%s():" fmt, __func__, ## __VA_ARGS__) > > > > > > +1 to adding function name, but > > > > > > failsafe is giving build error [1] with clang because of ## usage [2], that is > > > why I add this as ` "" __VA_ARGS__` at first place but you can't do this trick > > > if __VA_ARGS__ used after fmt. > > > > > > I am not aware of a solution for this, __VA_OPT__(,) also didn't worked with clang. > > > > +cc Adrien & Gaetan, > > > > I saw Adrien put some "workaround" to this for mlx5 > > Yes, through RTE_FMT() (rte_common.h). Something like this: > > #define RTE_ETHDEV_LOG(level, fmt, ...) \ > rte_log(RTE_LOG_ ## level, \ > rte_eth_dev_logtype, \ > "%s():" fmt, \ > __func__, \ > ## __VA_ARGS__) > > Can be rewritten like that: > > #define RTE_ETHDEV_LOG(level, ...) \ > rte_log(RTE_LOG_ ## level, \ > rte_eth_dev_logtype, \ > RTE_FMT("%s():" RTE_FMT_HEAD(__VA_ARGS__,), \ > __func__, \ > RTE_FMT_TAIL(__VA_ARGS__,))) > > Although not too pretty and convenient, it does the job. In short: > > - Remove "fmt" argument from prototype. > - Enclose format string and its arguments in RTE_FMT(). > - Replace "fmt" with RTE_FMT_HEAD(__VA_ARGS__,). > - Replace "## __VA_ARGS__" with RTE_FMT_TAIL(__VA_ARGS__,). > - Yes, trailing commas are mandatory in RTE_FMT_(HEAD|TAIL)(). > - Note it quietly appends a dummy "%.0s" argument to the format string. > > > > [1] > > > .../build/include/rte_ethdev.h:166:26: error: token pasting of ',' and > > > __VA_ARGS__ is a GNU extension [-Werror,-Wgnu-zero-variadic-macro-arguments] > > > "%s():" fmt, __func__, ## __VA_ARGS__) > > > ^ > > > > > > [2] > > > This seems because of "-pedantic" argument driver uses, and other PMDs using > > > "-pedantic", like mlx, will have same error although they are disable by > > > default and error not observed in default build. > > > > > > Since zero varadic macros is a GNU extension, maybe just adding GNU source?