From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id 0B5073978 for ; Tue, 5 Apr 2016 16:08:45 +0200 (CEST) Received: by mail-wm0-f53.google.com with SMTP id f198so33858959wme.0 for ; Tue, 05 Apr 2016 07:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ZxH1uC4o9V5eozqe1gl2WeeImqc8KCcn6PXdXeAOxnM=; b=vc0XoBnCuSPBWder/dzSDDI3Cj2lawUuj+f28BeAHaz3bU2ht2ol8WeRBWbv2MCF0b ClJyzkiffrKAQBd39A1dmi+j7g/ZWRrqsPOUDIj7yi7zRmCSSwWTN5fZK4oYcfR3otlV 4BvEhird8Cge/YjhH2AvAHTyFcYGZ2lDWshtQ3xqBHKEGeMlKWQA9snK51SD/WLUnDqR w4egBLMOyHgz7lN+6TE9ToLnscsjKEVAbAre2/uboUXtS551niEEKMbS6/oWxfVXr0hh da/XGqCHZu8DQPsGhwzZCwmw/McNqjlcuzMXPtJePmvBrSzPG0gYEktHZ+/AotS+FbZl K8bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ZxH1uC4o9V5eozqe1gl2WeeImqc8KCcn6PXdXeAOxnM=; b=N4c8wuilVJS4XSCy9iKL/RIZdk7yUZtyqzaUaDFb2rQwuWKTbeFAzxX08RQ6CF9Y/0 ntUOKyqiplvFnW8J6+Crus3h8LXity34+E4RY0bPxcs4WfxSvH36Yj6WWnqFomYGDSIH 7/f4NWv14hAhxr61X8tJMvUSaIZE5HhY9ardbVWGjkvP4mC+ZeW3GBvAvPgpK9uBD90o ce2PWo19LYdKe6GJfDN/sqxvHCMc/O0DXUrM/gjGHkfGl4UF0a5ObKAyIRHpofHVUoh2 LgHcQ4Wu/G3+G/eaMGeHPbXmoaoJUvbs6RTnBuk/HzJTELoD9CrQNOWFa2pyeTHoPN9x rloA== X-Gm-Message-State: AD7BkJLUMViZ7n4Q2OEVk4PP6aghn6V17swGOFUkdQADzM4aaAvIABBYFvl00zyiR7TV8vNM X-Received: by 10.28.52.72 with SMTP id b69mr18226343wma.35.1459865324910; Tue, 05 Apr 2016 07:08:44 -0700 (PDT) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id a1sm34862714wje.43.2016.04.05.07.08.43 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2016 07:08:44 -0700 (PDT) From: Adrien Mazarguil To: dev@dpdk.org Cc: Bruce Richardson , Thomas Monjalon Date: Tue, 5 Apr 2016 16:08:09 +0200 Message-Id: <1459865290-10248-10-git-send-email-adrien.mazarguil@6wind.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459865290-10248-1-git-send-email-adrien.mazarguil@6wind.com> References: <1459865290-10248-1-git-send-email-adrien.mazarguil@6wind.com> Subject: [dpdk-dev] [PATCH 09/10] lib: remove named variadic macros in exported headers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Apr 2016 14:08:45 -0000 Exported header files used by applications should allow the strictest compiler flags. Language extensions used in many places must be explicitly marked or removed to avoid warnings and compilation failures. Since there is no way to force named variadic macros as extensions, use a a standard __VA_ARGS__ with an extra dummy argument to format strings. This commit prevents the following errors: error: ISO C does not permit named variadic macros Signed-off-by: Adrien Mazarguil --- lib/librte_cryptodev/rte_cryptodev.h | 32 +++++++++++++++++------------- lib/librte_cryptodev/rte_cryptodev_pmd.h | 2 +- lib/librte_eal/common/include/rte_common.h | 9 +++++++++ 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/lib/librte_cryptodev/rte_cryptodev.h b/lib/librte_cryptodev/rte_cryptodev.h index 62e616b..817d2c9 100644 --- a/lib/librte_cryptodev/rte_cryptodev.h +++ b/lib/librte_cryptodev/rte_cryptodev.h @@ -78,26 +78,30 @@ extern const char **rte_cyptodev_names; /* Logging Macros */ -#define CDEV_LOG_ERR(fmt, args...) \ - RTE_LOG(ERR, CRYPTODEV, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) +#define CDEV_LOG_ERR(...) \ + RTE_LOG(ERR, CRYPTODEV, \ + RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) -#define CDEV_PMD_LOG_ERR(dev, fmt, args...) \ - RTE_LOG(ERR, CRYPTODEV, "[%s] %s() line %u: " fmt "\n", \ - dev, __func__, __LINE__, ## args) +#define CDEV_PMD_LOG_ERR(dev, ...) \ + RTE_LOG(ERR, CRYPTODEV, \ + RTE_FMT("[%s] %s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + dev, __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) #ifdef RTE_LIBRTE_CRYPTODEV_DEBUG -#define CDEV_LOG_DEBUG(fmt, args...) \ - RTE_LOG(DEBUG, CRYPTODEV, "%s() line %u: " fmt "\n", \ - __func__, __LINE__, ## args) \ +#define CDEV_LOG_DEBUG(...) \ + RTE_LOG(DEBUG, CRYPTODEV, \ + RTE_FMT("%s() line %u: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + __func__, __LINE__, RTE_FMT_TAIL(__VA_ARGS__,))) -#define CDEV_PMD_TRACE(fmt, args...) \ - RTE_LOG(DEBUG, CRYPTODEV, "[%s] %s: " fmt "\n", \ - dev, __func__, ## args) +#define CDEV_PMD_TRACE(...) \ + RTE_LOG(DEBUG, CRYPTODEV, \ + RTE_FMT("[%s] %s: " RTE_FMT_HEAD(__VA_ARGS__,) "\n", \ + dev, __func__, RTE_FMT_TAIL(__VA_ARGS__,))) #else -#define CDEV_LOG_DEBUG(fmt, args...) -#define CDEV_PMD_TRACE(fmt, args...) +#define CDEV_LOG_DEBUG(...) (void)0 +#define CDEV_PMD_TRACE(...) (void)0 #endif /** diff --git a/lib/librte_cryptodev/rte_cryptodev_pmd.h b/lib/librte_cryptodev/rte_cryptodev_pmd.h index cf08a50..4a07362 100644 --- a/lib/librte_cryptodev/rte_cryptodev_pmd.h +++ b/lib/librte_cryptodev/rte_cryptodev_pmd.h @@ -62,7 +62,7 @@ extern "C" { #define RTE_PMD_DEBUG_TRACE(...) \ rte_pmd_debug_trace(__func__, __VA_ARGS__) #else -#define RTE_PMD_DEBUG_TRACE(fmt, args...) +#define RTE_PMD_DEBUG_TRACE(...) #endif struct rte_cryptodev_session { diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 98ecc1c..db5ac91 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -335,6 +335,15 @@ rte_bsf32(uint32_t v) /** Take a macro value and get a string version of it */ #define RTE_STR(x) _RTE_STR(x) +/** + * ISO C helpers to modify format strings using variadic macros. + * This is a replacement for the ", ## __VA_ARGS__" GNU extension. + * An empty %s argument is appended to avoid a dangling comma. + */ +#define RTE_FMT(fmt, ...) fmt "%.0s", __VA_ARGS__ "" +#define RTE_FMT_HEAD(fmt, ...) fmt +#define RTE_FMT_TAIL(fmt, ...) __VA_ARGS__ + /** Mask value of type "tp" for the first "ln" bit set. */ #define RTE_LEN2MASK(ln, tp) \ ((tp)((uint64_t)-1 >> (sizeof(uint64_t) * CHAR_BIT - (ln)))) -- 2.1.4