All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Morten Brørup" <mb@smartsharesystems.com>
Cc: <dev@dpdk.org>, "Nicolas Chautru" <nicolas.chautru@intel.com>,
	"Gagandeep Singh" <g.singh@nxp.com>,
	"Hemant Agrawal" <hemant.agrawal@nxp.com>,
	"Parav Pandit" <parav@nvidia.com>,
	"Xueming Li" <xuemingl@nvidia.com>,
	"Nipun Gupta" <nipun.gupta@amd.com>,
	"Nikhil Agarwal" <nikhil.agarwal@amd.com>,
	"Sachin Saxena" <sachin.saxena@nxp.com>,
	"Rosen Xu" <rosen.xu@intel.com>,
	"Tomasz Duszynski" <tduszynski@marvell.com>,
	"Chengwen Feng" <fengchengwen@huawei.com>,
	"Long Li" <longli@microsoft.com>,
	"Nithin Dabilpuram" <ndabilpuram@marvell.com>,
	"Kiran Kumar K" <kirankumark@marvell.com>,
	"Sunil Kumar Kori" <skori@marvell.com>,
	"Satha Rao" <skoteshwar@marvell.com>,
	"Harman Kalra" <hkalra@marvell.com>,
	"Jingjing Wu" <jingjing.wu@intel.com>,
	"Nagadheeraj Rottela" <rnagadheeraj@marvell.com>,
	"Srikanth Jampala" <jsrikanth@marvell.com>,
	"Andrew Rybchenko" <andrew.rybchenko@oktetlabs.ru>,
	"Lee Daly" <lee.daly@intel.com>,
	"Pablo de Lara" <pablo.de.lara.guarch@intel.com>,
	"Fan Zhang" <fanzhang.oss@gmail.com>,
	"Ashish Gupta" <ashish.gupta@marvell.com>,
	"Sunila Sahu" <ssahu@marvell.com>,
	"Ruifeng Wang" <ruifeng.wang@arm.com>,
	"Michael Shamis" <michaelsh@marvell.com>,
	"Liron Himi" <lironh@marvell.com>, "Kai Ji" <kai.ji@intel.com>,
	"Anoob Joseph" <anoobj@marvell.com>,
	"Zhangfei Gao" <zhangfei.gao@linaro.org>,
	"Bruce Richardson" <bruce.richardson@intel.com>,
	"Kevin Laatz" <kevin.laatz@intel.com>,
	"Conor Walsh" <conor.walsh@intel.com>,
	"Abdullah Sevincer" <abdullah.sevincer@intel.com>,
	"Jerin Jacob" <jerinj@marvell.com>,
	"Harry van Haaren" <harry.van.haaren@intel.com>,
	"Elena Agostini" <eagostini@nvidia.com>,
	"John W. Linville" <linville@tuxdriver.com>,
	"Ciara Loftus" <ciara.loftus@intel.com>,
	"Shepard Siegel" <shepard.siegel@atomicrules.com>,
	"Ed Czeck" <ed.czeck@atomicrules.com>,
	"John Miller" <john.miller@atomicrules.com>,
	"Rahul Lakkireddy" <rahul.lakkireddy@chelsio.com>,
	"Apeksha Gupta" <apeksha.gupta@nxp.com>,
	"John Daley" <johndale@cisco.com>,
	"Hyong Youb Kim" <hyonkim@cisco.com>,
	"Ziyang Xuan" <xuanziyang2@huawei.com>,
	"Xiaoyun Wang" <cloud.wangxiaoyun@huawei.com>,
	"Guoyang Zhou" <zhouguoyang@huawei.com>,
	"Andrew Boyer" <andrew.boyer@amd.com>,
	"Jakub Grajciar" <jgrajcia@cisco.com>,
	"Zyta Szpak" <zr@semihalf.com>,
	"Martin Spinler" <spinler@cesnet.cz>,
	"Tetsuya Mukawa" <mtetsuyah@gmail.com>,
	"Vamsi Attunuru" <vattunuru@marvell.com>,
	"Cristian Dumitrescu" <cristian.dumitrescu@intel.com>,
	"Matan Azrad" <matan@nvidia.com>,
	"Maxime Coquelin" <maxime.coquelin@redhat.com>,
	"Chenbo Xia" <chenbox@nvidia.com>,
	"Konstantin Ananyev" <konstantin.v.ananyev@yandex.ru>,
	"Akhil Goyal" <gakhil@marvell.com>,
	"Byron Marohn" <byron.marohn@intel.com>,
	"Yipeng Wang" <yipeng1.wang@intel.com>,
	"Thomas Monjalon" <thomas@monjalon.net>,
	"Ferruh Yigit" <ferruh.yigit@amd.com>,
	"Vladimir Medvedkin" <vladimir.medvedkin@intel.com>,
	"Zhirun Yan" <yanzhirun_163@163.com>,
	"Sameh Gobriel" <sameh.gobriel@intel.com>,
	"Reshma Pattan" <reshma.pattan@intel.com>,
	"Srikanth Yalavarthi" <syalavarthi@marvell.com>,
	"Jasvinder Singh" <jasvinder.singh@intel.com>,
	"Pavan Nikhilesh" <pbhagavatula@marvell.com>,
	"Anatoly Burakov" <anatoly.burakov@intel.com>,
	"David Hunt" <david.hunt@intel.com>,
	"Sivaprasad Tummala" <sivaprasad.tummala@amd.com>,
	"Honnappa Nagarahalli" <honnappa.nagarahalli@arm.com>,
	"Ori Kam" <orika@nvidia.com>,
	"Volodymyr Fialko" <vfialko@marvell.com>,
	"Ciara Power" <ciara.power@intel.com>
Subject: Re: [RFC] fix semicolon at the end of RTE_LOG_REGISTER_DEFAULT
Date: Mon, 22 Apr 2024 08:13:47 -0700	[thread overview]
Message-ID: <20240422081347.2d356390@hermes.local> (raw)
In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F3D0@smartserver.smartshare.dk>

On Sat, 20 Apr 2024 09:48:24 +0200
Morten Brørup <mb@smartsharesystems.com> wrote:

> > From: Stephen Hemminger [mailto:stephen@networkplumber.org]
> > Sent: Saturday, 20 April 2024 02.08
> > 
> > The macro RTE_LOG_REGISTER_DEFAULT emits code for an initialization
> > function. If a driver (and most do) adds a semicolon after the macro.
> > 
> > RTE_LOG_REGISTER_DEFAULT(logtype_foo, INFO);
> > 
> > Is equivalent to:
> > 
> > 	int logtype_foo;
> > 	static void __logtype_foo(void) {
> > 	    logtype_foo = rte_log_register_type_and_pick_level(name,
> > 	                  	 RTE_LOG_INFO);
> > 		if (type < 0)
> > 			logtype_foo = RTE_LOGTYPE_EAL;
> > 	};
> > The problem is that extra semi-colon after the function.
> > 
> > If code is built with highest level of warnings (pedantic),
> > then it will generate a warning.
> >   warning: ISO C does not allow extra ‘;’ outside of a function
> > 
> > This is a treewide fix for this.  
> 
> It seems weird omitting the semicolon when using this macro.
> 
> How about using the same trick as RTE_INIT_PRIO():
> 
> #define RTE_INIT_PRIO(name, priority) \
> 	static void name(void); \
> 	static int __cdecl name ## _thunk(void) { name(); return 0; } \
> 	__pragma(const_seg(CTOR_PRIORITY_TO_SECTION(priority))) \
> 	__declspec(allocate(CTOR_PRIORITY_TO_SECTION(priority))) \
> 	    _PIFV name ## _pointer = &name ## _thunk; \
> 	__pragma(const_seg()) \
> 	static void name(void)


RTE_INIT_PRIO is what is causing the problem. My example comes from:
   RTE_LOG_REGISTER_DEFAULT() -> RTE_LOG_REGISTER_IMPL() -> RTE_INIT -> RTE_INIT_PRIO

The last line is used as prefix before RTE_LOG_REGISTER_IMPL that defines
the init function full expansion is:

// from RTE_LOG_REGISTER_IMPL
int logtype_foo;
// from RTE_INIT_PRIO
static void __logtype_foo(void);
static int __cdecl __logtype_foo_thunk(void) { __logtype_foo(); return 0; }
__pragma(const_seg(CTOR_PRIORITY_TO_SECTION(priority)))
__declspec(allocate(CTOR_PRIORITY_TO_SECTION(priority)))
    _PIFV __logtype_foo ## _pointer = &__logtype_foo_thunk;
__pragma(const_seg())
static void __logtype_foo(void)
// from RTE_LOG_REGISTER_IMPL
	logtype_foo = rte_log_register_logtype_foo_and_pick_level(__logtype_foo, RTE_LOG_##level);
	if (logtype_foo < 0)
		logtype_foo = RTE_LOGLOGTYPE_FOO_EAL;
}  // no ; here is allowed

	

  reply	other threads:[~2024-04-22 15:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-20  0:08 [RFC] fix semicolon at the end of RTE_LOG_REGISTER_DEFAULT Stephen Hemminger
2024-04-20  7:48 ` Morten Brørup
2024-04-22 15:13   ` Stephen Hemminger [this message]
2024-04-22 15:24     ` Morten Brørup
2024-04-22 16:20       ` Stephen Hemminger
2024-04-22 16:32         ` Morten Brørup

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240422081347.2d356390@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=abdullah.sevincer@intel.com \
    --cc=anatoly.burakov@intel.com \
    --cc=andrew.boyer@amd.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=anoobj@marvell.com \
    --cc=apeksha.gupta@nxp.com \
    --cc=ashish.gupta@marvell.com \
    --cc=bruce.richardson@intel.com \
    --cc=byron.marohn@intel.com \
    --cc=chenbox@nvidia.com \
    --cc=ciara.loftus@intel.com \
    --cc=ciara.power@intel.com \
    --cc=cloud.wangxiaoyun@huawei.com \
    --cc=conor.walsh@intel.com \
    --cc=cristian.dumitrescu@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    --cc=eagostini@nvidia.com \
    --cc=ed.czeck@atomicrules.com \
    --cc=fanzhang.oss@gmail.com \
    --cc=fengchengwen@huawei.com \
    --cc=ferruh.yigit@amd.com \
    --cc=g.singh@nxp.com \
    --cc=gakhil@marvell.com \
    --cc=harry.van.haaren@intel.com \
    --cc=hemant.agrawal@nxp.com \
    --cc=hkalra@marvell.com \
    --cc=honnappa.nagarahalli@arm.com \
    --cc=hyonkim@cisco.com \
    --cc=jasvinder.singh@intel.com \
    --cc=jerinj@marvell.com \
    --cc=jgrajcia@cisco.com \
    --cc=jingjing.wu@intel.com \
    --cc=john.miller@atomicrules.com \
    --cc=johndale@cisco.com \
    --cc=jsrikanth@marvell.com \
    --cc=kai.ji@intel.com \
    --cc=kevin.laatz@intel.com \
    --cc=kirankumark@marvell.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=lee.daly@intel.com \
    --cc=linville@tuxdriver.com \
    --cc=lironh@marvell.com \
    --cc=longli@microsoft.com \
    --cc=matan@nvidia.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=mb@smartsharesystems.com \
    --cc=michaelsh@marvell.com \
    --cc=mtetsuyah@gmail.com \
    --cc=ndabilpuram@marvell.com \
    --cc=nicolas.chautru@intel.com \
    --cc=nikhil.agarwal@amd.com \
    --cc=nipun.gupta@amd.com \
    --cc=orika@nvidia.com \
    --cc=pablo.de.lara.guarch@intel.com \
    --cc=parav@nvidia.com \
    --cc=pbhagavatula@marvell.com \
    --cc=rahul.lakkireddy@chelsio.com \
    --cc=reshma.pattan@intel.com \
    --cc=rnagadheeraj@marvell.com \
    --cc=rosen.xu@intel.com \
    --cc=ruifeng.wang@arm.com \
    --cc=sachin.saxena@nxp.com \
    --cc=sameh.gobriel@intel.com \
    --cc=shepard.siegel@atomicrules.com \
    --cc=sivaprasad.tummala@amd.com \
    --cc=skori@marvell.com \
    --cc=skoteshwar@marvell.com \
    --cc=spinler@cesnet.cz \
    --cc=ssahu@marvell.com \
    --cc=syalavarthi@marvell.com \
    --cc=tduszynski@marvell.com \
    --cc=thomas@monjalon.net \
    --cc=vattunuru@marvell.com \
    --cc=vfialko@marvell.com \
    --cc=vladimir.medvedkin@intel.com \
    --cc=xuanziyang2@huawei.com \
    --cc=xuemingl@nvidia.com \
    --cc=yanzhirun_163@163.com \
    --cc=yipeng1.wang@intel.com \
    --cc=zhangfei.gao@linaro.org \
    --cc=zhouguoyang@huawei.com \
    --cc=zr@semihalf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.