* [PATCH] doc: drop recommendation against bool in structures
@ 2026-07-20 11:46 Maxime Leroy
2026-07-20 12:13 ` Bruce Richardson
0 siblings, 1 reply; 5+ messages in thread
From: Maxime Leroy @ 2026-07-20 11:46 UTC (permalink / raw)
To: dev; +Cc: Stephen Hemminger, Thomas Monjalon, David Marchand, Maxime Leroy
The coding style advised against bool in structures, citing space and
type-size concerns inherited from the Linux kernel. That does not match
DPDK practice: bool is already used in over 1400 structure fields across
the tree, including core APIs such as rte_flow. Drop the note so the
style guide reflects actual usage.
Signed-off-by: Maxime Leroy <maxime@leroys.fr>
---
doc/guides/contributing/coding_style.rst | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index 976a1e1de3..11de3bb39a 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -313,15 +313,6 @@ Structure Declarations
* Use of the structures should be by separate variable declarations and those declarations must be extern if they are declared in a header file.
* Externally visible structure definitions should have the structure name prefixed by ``rte_`` to avoid namespace collisions.
-.. note::
-
- Avoid using ``bool`` in structures because it wastes space and
- the type size is unclear. A preferred use of
- ``bool`` is mainly as a return type from functions that return true/false,
- and maybe local variable functions.
-
- Ref: `LKML <https://lkml.org/lkml/2017/11/21/384>`_
-
Queues
~~~~~~
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] doc: drop recommendation against bool in structures
2026-07-20 11:46 [PATCH] doc: drop recommendation against bool in structures Maxime Leroy
@ 2026-07-20 12:13 ` Bruce Richardson
2026-07-20 12:51 ` Morten Brørup
0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2026-07-20 12:13 UTC (permalink / raw)
To: Maxime Leroy; +Cc: dev, Stephen Hemminger, Thomas Monjalon, David Marchand
On Mon, Jul 20, 2026 at 01:46:02PM +0200, Maxime Leroy wrote:
> The coding style advised against bool in structures, citing space and
> type-size concerns inherited from the Linux kernel. That does not match
> DPDK practice: bool is already used in over 1400 structure fields across
> the tree, including core APIs such as rte_flow. Drop the note so the
> style guide reflects actual usage.
>
> Signed-off-by: Maxime Leroy <maxime@leroys.fr>
> ---
Definite +1
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> doc/guides/contributing/coding_style.rst | 9 ---------
> 1 file changed, 9 deletions(-)
>
> diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
> index 976a1e1de3..11de3bb39a 100644
> --- a/doc/guides/contributing/coding_style.rst
> +++ b/doc/guides/contributing/coding_style.rst
> @@ -313,15 +313,6 @@ Structure Declarations
> * Use of the structures should be by separate variable declarations and those declarations must be extern if they are declared in a header file.
> * Externally visible structure definitions should have the structure name prefixed by ``rte_`` to avoid namespace collisions.
>
> -.. note::
> -
> - Avoid using ``bool`` in structures because it wastes space and
> - the type size is unclear. A preferred use of
> - ``bool`` is mainly as a return type from functions that return true/false,
> - and maybe local variable functions.
> -
> - Ref: `LKML <https://lkml.org/lkml/2017/11/21/384>`_
> -
> Queues
> ~~~~~~
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] doc: drop recommendation against bool in structures
2026-07-20 12:13 ` Bruce Richardson
@ 2026-07-20 12:51 ` Morten Brørup
2026-07-20 12:57 ` Bruce Richardson
0 siblings, 1 reply; 5+ messages in thread
From: Morten Brørup @ 2026-07-20 12:51 UTC (permalink / raw)
To: Bruce Richardson, Maxime Leroy
Cc: dev, Stephen Hemminger, Thomas Monjalon, David Marchand
> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Monday, 20 July 2026 14.13
>
> On Mon, Jul 20, 2026 at 01:46:02PM +0200, Maxime Leroy wrote:
> > The coding style advised against bool in structures, citing space and
> > type-size concerns inherited from the Linux kernel. That does not
> match
> > DPDK practice: bool is already used in over 1400 structure fields
> across
> > the tree, including core APIs such as rte_flow. Drop the note so the
> > style guide reflects actual usage.
The note is still valid, although massively violated.
Could we paraphrase the note as an advice/recommendation, instead of completely removing it?
The intention is to make developers consider alternatives when adding a Boolean field to a structure.
Maybe it could be expanded with a few example alternatives:
uint8_t value, or
uintN_t value:1 (bitfield).
> >
> > Signed-off-by: Maxime Leroy <maxime@leroys.fr>
> > ---
>
> Definite +1
>
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
>
> > doc/guides/contributing/coding_style.rst | 9 ---------
> > 1 file changed, 9 deletions(-)
> >
> > diff --git a/doc/guides/contributing/coding_style.rst
> b/doc/guides/contributing/coding_style.rst
> > index 976a1e1de3..11de3bb39a 100644
> > --- a/doc/guides/contributing/coding_style.rst
> > +++ b/doc/guides/contributing/coding_style.rst
> > @@ -313,15 +313,6 @@ Structure Declarations
> > * Use of the structures should be by separate variable declarations
> and those declarations must be extern if they are declared in a header
> file.
> > * Externally visible structure definitions should have the structure
> name prefixed by ``rte_`` to avoid namespace collisions.
> >
> > -.. note::
> > -
> > - Avoid using ``bool`` in structures because it wastes space and
> > - the type size is unclear. A preferred use of
> > - ``bool`` is mainly as a return type from functions that return
> true/false,
> > - and maybe local variable functions.
> > -
> > - Ref: `LKML <https://lkml.org/lkml/2017/11/21/384>`_
> > -
> > Queues
> > ~~~~~~
> >
> > --
> > 2.43.0
> >
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] doc: drop recommendation against bool in structures
2026-07-20 12:51 ` Morten Brørup
@ 2026-07-20 12:57 ` Bruce Richardson
2026-07-20 12:59 ` Morten Brørup
0 siblings, 1 reply; 5+ messages in thread
From: Bruce Richardson @ 2026-07-20 12:57 UTC (permalink / raw)
To: Morten Brørup
Cc: Maxime Leroy, dev, Stephen Hemminger, Thomas Monjalon,
David Marchand
On Mon, Jul 20, 2026 at 02:51:09PM +0200, Morten Brørup wrote:
> > From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> > Sent: Monday, 20 July 2026 14.13
> >
> > On Mon, Jul 20, 2026 at 01:46:02PM +0200, Maxime Leroy wrote:
> > > The coding style advised against bool in structures, citing space and
> > > type-size concerns inherited from the Linux kernel. That does not
> > match
> > > DPDK practice: bool is already used in over 1400 structure fields
> > across
> > > the tree, including core APIs such as rte_flow. Drop the note so the
> > > style guide reflects actual usage.
>
> The note is still valid, although massively violated.
> Could we paraphrase the note as an advice/recommendation, instead of completely removing it?
> The intention is to make developers consider alternatives when adding a Boolean field to a structure.
> Maybe it could be expanded with a few example alternatives:
> uint8_t value, or
> uintN_t value:1 (bitfield).
>
I don't think we want those alternative approaches. If something is a
boolean value, then let's just store it as a bool and be done with it. If
we store it as an int type then we need comments documenting that it's
actually a flag. If it's a bit type, then the field becomes just that
little bit more awkward to manage - though still a good choice if the
struct is size-sensitive.
Because of this, I'd be in favour of just removing the text and then
letting the developer choose the best field type for the job. If bool is a
bad choice for a given situation, that should be caught in review.
/Bruce
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: [PATCH] doc: drop recommendation against bool in structures
2026-07-20 12:57 ` Bruce Richardson
@ 2026-07-20 12:59 ` Morten Brørup
0 siblings, 0 replies; 5+ messages in thread
From: Morten Brørup @ 2026-07-20 12:59 UTC (permalink / raw)
To: Bruce Richardson
Cc: Maxime Leroy, dev, Stephen Hemminger, Thomas Monjalon,
David Marchand
> From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> Sent: Monday, 20 July 2026 14.58
>
> On Mon, Jul 20, 2026 at 02:51:09PM +0200, Morten Brørup wrote:
> > > From: Bruce Richardson [mailto:bruce.richardson@intel.com]
> > > Sent: Monday, 20 July 2026 14.13
> > >
> > > On Mon, Jul 20, 2026 at 01:46:02PM +0200, Maxime Leroy wrote:
> > > > The coding style advised against bool in structures, citing space
> and
> > > > type-size concerns inherited from the Linux kernel. That does not
> > > match
> > > > DPDK practice: bool is already used in over 1400 structure fields
> > > across
> > > > the tree, including core APIs such as rte_flow. Drop the note so
> the
> > > > style guide reflects actual usage.
> >
> > The note is still valid, although massively violated.
> > Could we paraphrase the note as an advice/recommendation, instead of
> completely removing it?
> > The intention is to make developers consider alternatives when adding
> a Boolean field to a structure.
> > Maybe it could be expanded with a few example alternatives:
> > uint8_t value, or
> > uintN_t value:1 (bitfield).
> >
> I don't think we want those alternative approaches. If something is a
> boolean value, then let's just store it as a bool and be done with it.
> If
> we store it as an int type then we need comments documenting that it's
> actually a flag. If it's a bit type, then the field becomes just that
> little bit more awkward to manage - though still a good choice if the
> struct is size-sensitive.
>
> Because of this, I'd be in favour of just removing the text and then
> letting the developer choose the best field type for the job. If bool
> is a
> bad choice for a given situation, that should be caught in review.
>
> /Bruce
OK, I'll buy that.
Acked-by: Morten Brørup <mb@smartsharesystems.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-20 12:59 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 11:46 [PATCH] doc: drop recommendation against bool in structures Maxime Leroy
2026-07-20 12:13 ` Bruce Richardson
2026-07-20 12:51 ` Morten Brørup
2026-07-20 12:57 ` Bruce Richardson
2026-07-20 12:59 ` Morten Brørup
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox