From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by dpdk.org (Postfix) with ESMTP id F2AA28E91 for ; Wed, 4 Nov 2015 11:24:38 +0100 (CET) Received: by wicll6 with SMTP id ll6so86754291wic.0 for ; Wed, 04 Nov 2015 02:24:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind_com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-type:content-disposition:in-reply-to; bh=heWl6Fa5MWEOOj4mH5mHIiG0FQHkfVRw2T6COEk0cMU=; b=KhNqvoHk9DDrgSpRnuEFCzWZUy2vycTptQguAYf6XCdnf+9IwEEOFqa+UTdWi+m68W VMkutxKrNC0qa8/rOojkAZzCiEMEjgnopJ1R1c/YlIn2PQy0TgTqIqFoGei2lH+18eei XRtKaKsMNAkR2tA8Qx85Ulr5II8Bo7MCgq2g4I678tvbNTijrTf98OSehbCJ2+N3gmiG tM6yQGuvyCZfxKFDhMW2GGb+4huGvyqA5fnQH1CbD3aQX5LAufbRfEAdFZmqmtKBPATS AYrJ3rjRzid5QDocgCtLOtQSzWiruySUovaKkZwfkyFmuLjrX9D67/Y+40NCd1h4Hcxj zfKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-type :content-disposition:in-reply-to; bh=heWl6Fa5MWEOOj4mH5mHIiG0FQHkfVRw2T6COEk0cMU=; b=FwrVOU0C0K3pi+ON34PnyAYx6QJ6cZyJDbEDiaMsV11U6ODwMBUuV9V9pCANBew/RI EUX98ORrpCmc86fm/0dOJDBIWiylOksJnj1V+oHDsrN1j69VeKDxOcRF1SQ0GGPc2gwp 33muEyg7/1XpEYoL3X1SLtiUTRtgwRwKuOc1Qc0iNSoZrKgeBPIlGRpbYxJjsWP1kQ5t CnFdi54I1uklsb5viqpFx6+ufXOmGAzoq2FSLcUWFdh5M+cMhqysjjsCPsIkXgwD6+M3 0TqHhM9NyDldaVRxv5QMGPo8yPLqiJIVqTcDJIcf+JqKG9AEA5Et+mkjLgqiV/1+NlMp Ljbg== X-Gm-Message-State: ALoCoQlVNVEJQ8NZj6iBUxOxfOdUwvlesQ6QMuPXejoTGE05ScMUGdE3VJSAVFQXPjSUXumisBPC X-Received: by 10.194.8.227 with SMTP id u3mr998716wja.38.1446632678805; Wed, 04 Nov 2015 02:24:38 -0800 (PST) Received: from 6wind.com (guy78-3-82-239-227-177.fbx.proxad.net. [82.239.227.177]) by smtp.gmail.com with ESMTPSA id t126sm2246813wmd.23.2015.11.04.02.24.37 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Nov 2015 02:24:37 -0800 (PST) Date: Wed, 4 Nov 2015 11:24:18 +0100 From: Adrien Mazarguil To: Thomas Monjalon Message-ID: <20151104102418.GN3518@6wind.com> Mail-Followup-To: Thomas Monjalon , Bruce Richardson , dev@dpdk.org References: <1441811374-28984-1-git-send-email-bruce.richardson@intel.com> <1446552059-5446-1-git-send-email-bruce.richardson@intel.com> <1446552059-5446-3-git-send-email-bruce.richardson@intel.com> <4698587.GS9blBozDC@xps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4698587.GS9blBozDC@xps13> Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v3 2/4] ethdev: move error checking macros to header 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: Wed, 04 Nov 2015 10:24:39 -0000 On Wed, Nov 04, 2015 at 02:19:36AM +0100, Thomas Monjalon wrote: > 2015-11-03 12:00, Bruce Richardson: > > Move the function ptr and port id checking macros to the header file, so > > that they can be used in the static inline functions there. In doxygen > > comments, mark them as for internal use only. > [...] > > +/** > > + * @internal > > + * Macro to print a message if in debugging mode > > + */ > > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) \ > > + RTE_LOG(ERR, PMD, "%s: " fmt, __func__, ## args) > > +#else > > +#define RTE_PMD_DEBUG_TRACE(fmt, args...) > > +#endif > > It does not compile because Mellanox drivers are pedantic: > > In file included from /home/thomas/projects/dpdk/dpdk/drivers/net/mlx4/mlx4.c:78:0: > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h: At top level: > /home/thomas/projects/dpdk/dpdk/x86_64-native-linuxapp-gcc-shared-next/include/rte_ethdev.h:933:38: error: ISO C does not permit named variadic macros [-Werror=variadic-macros] > #define RTE_PMD_DEBUG_TRACE(fmt, args...) \ I suggest something like the following definitions as a pedantic-proof and standard compliant method (one drawback being that it cannot be done with a single macro), see PMD_DRV_LOG() in drivers/net/mlx5/mlx5_utils.h which also automatically appends a line feed: #ifdef RTE_LIBRTE_ETHDEV_DEBUG #define STRIP(a, b) a #define OPAREN ( #define CPAREN ) #define COMMA , #define RTE_PMD_DEBUG_TRACE(...) \ RTE_PMD_DEBUG_TRACE_(__VA_ARGS__ STRIP OPAREN, CPAREN) #define RTE_PMD_DEBUG_TRACE_(fmt, ...) \ RTE_PMD_DEBUG_TRACE__(fmt COMMA __func__, __VA_ARGS__) #define RTE_PMD_DEBUG_TRACE__(...) \ RTE_LOG(ERR, PMD, "%s: " __VA_ARGS__) #else /* RTE_LIBRTE_ETHDEV_DEBUG */ #define RTE_PMD_DEBUG_TRACE(...) #endif /* RTE_LIBRTE_ETHDEV_DEBUG */ STRIP() and other helper macros are used to manage the dangling comma issue when __VA_ARGS__ is empty as in the first call below: RTE_PMD_DEBUG_TRACE("foo\n"); RTE_PMD_DEBUG_TRACE("foo %u\n", 42); -- Adrien Mazarguil 6WIND