doc: add note into coding style

Message ID 20180917152429.30518-1-marko.kovacevic@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series doc: add note into coding style |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Kovacevic, Marko Sept. 17, 2018, 3:24 p.m. UTC
  Added a note into the coding style to
highlight the use of a bool within a struct

Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>
---
 doc/guides/contributing/coding_style.rst | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Ferruh Yigit Sept. 17, 2018, 4:31 p.m. UTC | #1
On 9/17/2018 4:24 PM, Marko Kovacevic wrote:
> Added a note into the coding style to
> highlight the use of a bool within a struct
> 
> Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
  
Thomas Monjalon Nov. 24, 2018, 8:45 p.m. UTC | #2
17/09/2018 18:31, Ferruh Yigit:
> On 9/17/2018 4:24 PM, Marko Kovacevic wrote:
> > Added a note into the coding style to
> > highlight the use of a bool within a struct
> > 
> > Signed-off-by: Marko Kovacevic <marko.kovacevic@intel.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks
  

Patch

diff --git a/doc/guides/contributing/coding_style.rst b/doc/guides/contributing/coding_style.rst
index b1bf0d1..8b1febe 100644
--- a/doc/guides/contributing/coding_style.rst
+++ b/doc/guides/contributing/coding_style.rst
@@ -247,6 +247,15 @@  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::
+
+    Uses of ``bool`` in structures are not preferred as is wastes space and
+    it's also not clear as to what type size the bool is. 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
 ~~~~~~