From f70a0d5febe62bdda9e9dd25d93b855c6d3352b3 Mon Sep 17 00:00:00 2001 From: Gerwin Klein Date: Wed, 18 Oct 2023 09:47:01 +1100 Subject: [PATCH 1/2] style: packed structs Explain that structs must be packed (not contain any implicit padding). Signed-off-by: Gerwin Klein --- processes/style-guide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/processes/style-guide.md b/processes/style-guide.md index dec7cf3277..9a2387829e 100644 --- a/processes/style-guide.md +++ b/processes/style-guide.md @@ -248,6 +248,10 @@ anything in the general guide. * Do not use `typedef` to create a type alias for an `enum`; always specify `enum` types as `word_t` (otherwise, the `enum` size is determined by the compiler). +* All `struct`s must be packed, i.e. not contain any implicit padding + that is inserted by the compiler (otherwise memory content is + unspecified). Use explicit `padding` fields of the required type size to + remove implicit compiler padding. ## Further resources From daa26319261e5704387af482c1d66eea5f70e774 Mon Sep 17 00:00:00 2001 From: Gerwin Klein Date: Wed, 18 Oct 2023 09:49:29 +1100 Subject: [PATCH 2/2] [squash] Update processes/style-guide.md Signed-off-by: Gerwin Klein --- processes/style-guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/processes/style-guide.md b/processes/style-guide.md index 9a2387829e..555e52046a 100644 --- a/processes/style-guide.md +++ b/processes/style-guide.md @@ -248,7 +248,7 @@ anything in the general guide. * Do not use `typedef` to create a type alias for an `enum`; always specify `enum` types as `word_t` (otherwise, the `enum` size is determined by the compiler). -* All `struct`s must be packed, i.e. not contain any implicit padding +* All `struct` definitions must be packed, i.e. not contain any implicit padding that is inserted by the compiler (otherwise memory content is unspecified). Use explicit `padding` fields of the required type size to remove implicit compiler padding.