DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/6] fix the curly braces mismatch problem
@ 2022-02-06  0:44 Weiguo Li
  2022-02-07  9:29 ` Bruce Richardson
  2022-02-07 11:44 ` Weiguo Li
  0 siblings, 2 replies; 5+ messages in thread
From: Weiguo Li @ 2022-02-06  0:44 UTC (permalink / raw)
  To: dev

To make C header file compatible with C++ linking, a conventional
practice enclose the code with braces as below:

#ifdef __cplusplus
extern "C" {
#endif

...

#ifdef __cplusplus
}
#endif

Some alternative forms of "#ifdef __cplusplus", like 
"#if defined(__cplusplus)" or "# ifdef __cplusplus", also work.

While it's suspicious when a header file matchs this regular
expression "if.*__cplusplus" exactly once.

The following script is used to find these files:
grep -r ~/git/dpdk --include=*.h -e "if.*__cplusplus" -c|grep ":1$"

Apart from two false positive cases, I found some real issues --
some missing the left brace parts, the others missing the right
brace parts. 

In one of the cases, the c++ guard is removed since it's useless in 
private header as previous patch (http://dpdk.org/patch/98948) noted.
For the other cases, the missing parts are supplemented.

Weiguo Li (6):
  bus/dpaa: fix the curly braces mismatch problem
  common/mlx5: fix the curly braces mismatch problem
  net/cxgbe: fix the curly braces mismatch problem
  net/dpaa2: fix the curly braces mismatch problem
  eal/windows: fix the curly braces mismatch problem
  eventdev: remove C++ include guard from private header

 drivers/bus/dpaa/include/fsl_fman.h         | 5 +++++
 drivers/bus/dpaa/rte_dpaa_bus.h             | 4 ++++
 drivers/common/mlx5/windows/mlx5_win_defs.h | 5 +++++
 drivers/common/mlx5/windows/mlx5_win_ext.h  | 4 ++++
 drivers/net/cxgbe/base/common.h             | 5 +++++
 drivers/net/dpaa2/dpaa2_sparser.h           | 5 +++++
 lib/eal/windows/include/dirent.h            | 4 ++++
 lib/eventdev/eventdev_pmd.h                 | 4 ----
 8 files changed, 32 insertions(+), 4 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/6] fix the curly braces mismatch problem
  2022-02-06  0:44 [PATCH 0/6] fix the curly braces mismatch problem Weiguo Li
@ 2022-02-07  9:29 ` Bruce Richardson
  2022-02-07 11:44 ` Weiguo Li
  1 sibling, 0 replies; 5+ messages in thread
From: Bruce Richardson @ 2022-02-07  9:29 UTC (permalink / raw)
  To: Weiguo Li; +Cc: dev

On Sun, Feb 06, 2022 at 08:44:08AM +0800, Weiguo Li wrote:
> To make C header file compatible with C++ linking, a conventional
> practice enclose the code with braces as below:
> 
> #ifdef __cplusplus extern "C" { #endif
> 
> ...
> 
> #ifdef __cplusplus } #endif
> 
> Some alternative forms of "#ifdef __cplusplus", like "#if
> defined(__cplusplus)" or "# ifdef __cplusplus", also work.
> 
> While it's suspicious when a header file matchs this regular expression
> "if.*__cplusplus" exactly once.
> 
> The following script is used to find these files: grep -r ~/git/dpdk
> --include=*.h -e "if.*__cplusplus" -c|grep ":1$"
> 
> Apart from two false positive cases, I found some real issues -- some
> missing the left brace parts, the others missing the right brace parts. 
> 
> In one of the cases, the c++ guard is removed since it's useless in
> private header as previous patch (http://dpdk.org/patch/98948) noted.
> For the other cases, the missing parts are supplemented.
> 
Any headers that have filenames not starting with "rte_" are internal
headers, and so should have the guards removed. Therefore, I think that
most patches in this set should just be removing guards. From my tests with
building our public headers in C++ files, resulting in series[1], I only
found one public header with an incorrect guard.

/Bruce

[1]http://patches.dpdk.org/project/dpdk/list/?series=21466

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/6] fix the curly braces mismatch problem
  2022-02-06  0:44 [PATCH 0/6] fix the curly braces mismatch problem Weiguo Li
  2022-02-07  9:29 ` Bruce Richardson
@ 2022-02-07 11:44 ` Weiguo Li
  2022-02-07 13:39   ` Bruce Richardson
  1 sibling, 1 reply; 5+ messages in thread
From: Weiguo Li @ 2022-02-07 11:44 UTC (permalink / raw)
  To: bruce.richardson; +Cc: dev

On Mon, 7 Feb 2022 09:29:58 +0000, Bruce Richardson wrote:
> Any headers that have filenames not starting with "rte_" are internal
> headers, and so should have the guards removed. Therefore, I think that
> most patches in this set should just be removing guards. From my tests with
> building our public headers in C++ files, resulting in series[1], I only
> found one public header with an incorrect guard.
> 
> /Bruce
> 
> [1]http://patches.dpdk.org/project/dpdk/list/?series=21466
> 

Hi Bruce,

Thanks for your tip!

BTW it's strange that some file include these headers by angle-brackets.

I'll update this patch set later.

Thanks,
-Weiguo


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/6] fix the curly braces mismatch problem
  2022-02-07 11:44 ` Weiguo Li
@ 2022-02-07 13:39   ` Bruce Richardson
  2022-02-08 16:21     ` Thomas Monjalon
  0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2022-02-07 13:39 UTC (permalink / raw)
  To: Weiguo Li; +Cc: dev

On Mon, Feb 07, 2022 at 07:44:29PM +0800, Weiguo Li wrote:
> On Mon, 7 Feb 2022 09:29:58 +0000, Bruce Richardson wrote:
> > Any headers that have filenames not starting with "rte_" are internal
> > headers, and so should have the guards removed. Therefore, I think that
> > most patches in this set should just be removing guards. From my tests with
> > building our public headers in C++ files, resulting in series[1], I only
> > found one public header with an incorrect guard.
> > 
> > /Bruce
> > 
> > [1]http://patches.dpdk.org/project/dpdk/list/?series=21466
> > 
> 
> Hi Bruce,
> 
> Thanks for your tip!
> 
> BTW it's strange that some file include these headers by angle-brackets.
> 
> I'll update this patch set later.
> 
Thanks.
BTW: if you do find any headers that are being exposed as public headers,
but don't have "rte_" in the filename, please flag them as needing fixing
too. There shouldn't be any, but just in case....

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/6] fix the curly braces mismatch problem
  2022-02-07 13:39   ` Bruce Richardson
@ 2022-02-08 16:21     ` Thomas Monjalon
  0 siblings, 0 replies; 5+ messages in thread
From: Thomas Monjalon @ 2022-02-08 16:21 UTC (permalink / raw)
  To: Bruce Richardson; +Cc: Weiguo Li, dev

07/02/2022 14:39, Bruce Richardson:
> BTW: if you do find any headers that are being exposed as public headers,
> but don't have "rte_" in the filename, please flag them as needing fixing
> too. There shouldn't be any, but just in case....

It seems drivers/baseband/fpga_lte_fec/fpga_lte_fec.h is supposed to be exposed.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-08 16:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-06  0:44 [PATCH 0/6] fix the curly braces mismatch problem Weiguo Li
2022-02-07  9:29 ` Bruce Richardson
2022-02-07 11:44 ` Weiguo Li
2022-02-07 13:39   ` Bruce Richardson
2022-02-08 16:21     ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).