From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id AEE8B43EDB; Mon, 22 Apr 2024 17:13:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9ABB140268; Mon, 22 Apr 2024 17:13:54 +0200 (CEST) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 8C88F40265 for ; Mon, 22 Apr 2024 17:13:52 +0200 (CEST) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-6f30f69a958so529160b3a.1 for ; Mon, 22 Apr 2024 08:13:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1713798831; x=1714403631; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=qrhFgfZRmxT1NbAij+uzFMuCn/JjJM3WRL7zLfa6GV8=; b=l5S4f0frS8zNTsfqDwjGWNG9S0TudQ7L0C5zncvBskv95fPcdRstF90fJH7JNgwxJl PyCIoS/Nrw0InQ81M13ckAtzSWWcIXeImxR54Znb9pCKUNslxUNG07HfE3sbE+eB000V x910e4Uj1MvFN+jB8MwigwXj+cBYzQueBxsPxzyaA5Cb0W1zq1MW/ITf7Wz8JRX2FciT Tk4Ly3F0E4u1J9aPiOs0whbQ/8/LdrW26xvKbY8p/oMUWc6EUKuZwW1XLdhtpFDmkWxN lzHTE/KTKFXJnPvpaeenz9diz5doyruoMKXzkti9bjb4Avgj7/H+C5JbZrsp4JIbIIqN nzkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713798831; x=1714403631; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qrhFgfZRmxT1NbAij+uzFMuCn/JjJM3WRL7zLfa6GV8=; b=A4AldMIq6wxyRbvijjLQUgCgyHWWqRd+A1kR0LFOrUbSUthV6klMCbm5lNN956IzPb vfStbd1lVPK7jA5KHA8jrl9HTIAI9u3rmLD4WG3sVGL3BowOWINsCqnqj/sb535Gnp2y R2zXgzvwZqpZwgA84ztOfE1SaVvi3Fs0W1GLBBpySHl2/Gc8P4/2YhxJc3qwpdIPxmzt gbLgIJbJhIG0MHIOAXyFN95C4dlkE9yhl/S8Ng4wbKFY3WxnHmZrJN/xTGgG7SyoSnLa 8px9Pqyw2aHy/P+/zoGhSlhZJCqRUGC8v5n2esUJjbrHlSqnRd+Vu7xD4OjBzHzrrJDP sdmg== X-Gm-Message-State: AOJu0YycrkQCl7J+6TI/VUXGf2kUMgUt0yWF7gYYn0GcmFiT6JCegD8h HqyQjTpR2a7AkVYE3RwipxsiFJET7yTZOzZRFDurt0/undyFxuZM7l1FcGN9F2U= X-Google-Smtp-Source: AGHT+IFa7X521MHZrbARhYu4zTyCnyU7GUlK95WBFm6UoRu/o5+VzLRL24t9FHarjubWKMbEDy8zaw== X-Received: by 2002:a17:902:c952:b0:1e3:d4eb:a0f2 with SMTP id i18-20020a170902c95200b001e3d4eba0f2mr12184032pla.51.1713798831466; Mon, 22 Apr 2024 08:13:51 -0700 (PDT) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id mq8-20020a170902fd4800b001e23fcdebe9sm8263721plb.98.2024.04.22.08.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 08:13:51 -0700 (PDT) Date: Mon, 22 Apr 2024 08:13:47 -0700 From: Stephen Hemminger To: Morten =?UTF-8?B?QnLDuHJ1cA==?= Cc: , "Nicolas Chautru" , "Gagandeep Singh" , "Hemant Agrawal" , "Parav Pandit" , "Xueming Li" , "Nipun Gupta" , "Nikhil Agarwal" , "Sachin Saxena" , "Rosen Xu" , "Tomasz Duszynski" , "Chengwen Feng" , "Long Li" , "Nithin Dabilpuram" , "Kiran Kumar K" , "Sunil Kumar Kori" , "Satha Rao" , "Harman Kalra" , "Jingjing Wu" , "Nagadheeraj Rottela" , "Srikanth Jampala" , "Andrew Rybchenko" , "Lee Daly" , "Pablo de Lara" , "Fan Zhang" , "Ashish Gupta" , "Sunila Sahu" , "Ruifeng Wang" , "Michael Shamis" , "Liron Himi" , "Kai Ji" , "Anoob Joseph" , "Zhangfei Gao" , "Bruce Richardson" , "Kevin Laatz" , "Conor Walsh" , "Abdullah Sevincer" , "Jerin Jacob" , "Harry van Haaren" , "Elena Agostini" , "John W. Linville" , "Ciara Loftus" , "Shepard Siegel" , "Ed Czeck" , "John Miller" , "Rahul Lakkireddy" , "Apeksha Gupta" , "John Daley" , "Hyong Youb Kim" , "Ziyang Xuan" , "Xiaoyun Wang" , "Guoyang Zhou" , "Andrew Boyer" , "Jakub Grajciar" , "Zyta Szpak" , "Martin Spinler" , "Tetsuya Mukawa" , "Vamsi Attunuru" , "Cristian Dumitrescu" , "Matan Azrad" , "Maxime Coquelin" , "Chenbo Xia" , "Konstantin Ananyev" , "Akhil Goyal" , "Byron Marohn" , "Yipeng Wang" , "Thomas Monjalon" , "Ferruh Yigit" , "Vladimir Medvedkin" , "Zhirun Yan" , "Sameh Gobriel" , "Reshma Pattan" , "Srikanth Yalavarthi" , "Jasvinder Singh" , "Pavan Nikhilesh" , "Anatoly Burakov" , "David Hunt" , "Sivaprasad Tummala" , "Honnappa Nagarahalli" , "Ori Kam" , "Volodymyr Fialko" , "Ciara Power" Subject: Re: [RFC] fix semicolon at the end of RTE_LOG_REGISTER_DEFAULT Message-ID: <20240422081347.2d356390@hermes.local> In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F3D0@smartserver.smartshare.dk> References: <20240420000827.192451-1-stephen@networkplumber.org> <98CBD80474FA8B44BF855DF32C47DC35E9F3D0@smartserver.smartshare.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Sat, 20 Apr 2024 09:48:24 +0200 Morten Br=C3=B8rup wrote: > > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > > Sent: Saturday, 20 April 2024 02.08 > >=20 > > The macro RTE_LOG_REGISTER_DEFAULT emits code for an initialization > > function. If a driver (and most do) adds a semicolon after the macro. > >=20 > > RTE_LOG_REGISTER_DEFAULT(logtype_foo, INFO); > >=20 > > Is equivalent to: > >=20 > > int logtype_foo; > > static void __logtype_foo(void) { > > logtype_foo =3D rte_log_register_type_and_pick_level(name, > > RTE_LOG_INFO); > > if (type < 0) > > logtype_foo =3D RTE_LOGTYPE_EAL; > > }; > > The problem is that extra semi-colon after the function. > >=20 > > If code is built with highest level of warnings (pedantic), > > then it will generate a warning. > > warning: ISO C does not allow extra =E2=80=98;=E2=80=99 outside of a = function > >=20 > > This is a treewide fix for this. =20 >=20 > It seems weird omitting the semicolon when using this macro. >=20 > How about using the same trick as RTE_INIT_PRIO(): >=20 > #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 =3D &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 =3D &__logtype_foo_thunk; __pragma(const_seg()) static void __logtype_foo(void) // from RTE_LOG_REGISTER_IMPL logtype_foo =3D rte_log_register_logtype_foo_and_pick_level(__logtype_foo,= RTE_LOG_##level); if (logtype_foo < 0) logtype_foo =3D RTE_LOGLOGTYPE_FOO_EAL; } // no ; here is allowed =09