Skip to content

support __packed struct

Luc Van Oostenryck linux-sparse 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest16 patches 1 replyIn review
  2. v216 patches 14 repliesSuperseded

Changes in v3 from the cover letter

* correct several typos
* add an explanation for one of the test
* avoid sizeof() in tests where the size is constrained to some fixed value
* remove a redundency in a test (struct sb identical to struct sa)
* reformulate the commit message for apply_ctype()'s arguments reversal
* tweak the not-so-1-to-1 code movement
* fix the truncated commit message of the last patch

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/16add testcases for dubious enum valuesvalidation/enum-type-dubious.c+18 -00 replies
2/16add testcases for exotic enum valuesvalidation/enum-type-exotic.c+28 -00 replies
3/16add testcases for enum attributesvalidation/parsing/enum-attr.c+29 -00 replies
4/16add testcases for type attributesvalidation/type-attribute-align.c validation/type-attribute-as.c validation/type-attribute-mod.c +1 more+91 -00 replies
5/16add testcases for packed structuresvalidation/packed-deref0.c validation/packed-struct.c+57 -00 replies
6/16add testcases for packed bitfieldsvalidation/packed-bitfield0.c validation/packed-bitfield1.c validation/packed-bitfield2.c +3 more+172 -00 replies
7/16apply_ctype: use self-explanatory argument nameparse.c+10 -100 replies
8/16apply_ctype: reverse the order of argumentsparse.c+4 -40 replies
9/16apply_ctype: move up its declarationparse.c+2 -20 replies
10/16struct-attr: prepare to handle attributes at the end of struct definitions (1)parse.c validation/parsing/enum-attr.c+7 -70 replies
11/16struct-attr: prepare to handle attributes at the end of struct definitions (2)parse.c+13 -130 replies
12/16struct-attr: prepare to handle attributes at the end of struct definitions (3)parse.c+6 -90 replies
13/16struct-attr: fix type attribute like 'struct __attr { ... }'parse.c+3 -10 replies
14/16struct-attr: fix: do not ignore struct/union/enum type attributesparse.c validation/packed-bitfield3.c validation/packed-bitfield4.c +3 more+2 -50 replies
15/16packed: no out-of-bound access of packed bitfieldslinearize.c symbol.h+12 -20 replies
16/16packed: add support for __packed structDocumentation/TODO.md parse.c symbol.c +7 more+14 -130 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 00/16] support __packed struct

During parsing, Sparse recognizes the attribute 'packed' but this attribute is otherwise ignored for several reasons:
1) the attribute in 'struct __attr { ... }' is wrongly handled as belonging to the whole declaration but it should belong to the type,
2) the attribute in 'struct <name> { ... } __attr;' is simply ignored,
3) the layout of packed bitfields need special care.

This series contains 2 parts:
1) handling of type attributes
2) correct layout of packed structs, including packed bitfields.

This series is also available for review and testing at:
git://git.kernel.org/pub/scm/devel/sparse/sparse-dev.git packed-v3

Changes since v2 (all thanks to Ramsay Jones):
* correct several typos
* add an explanation for one of the test
* avoid sizeof() in tests where the size is constrained to some fixed value
* remove a redundency in a test (struct sb identical to struct sa)
* reformulate the commit message for apply_ctype()'s arguments reversal
* tweak the not-so-1-to-1 code movement
* fix the truncated commit message of the last patch

Changes since v1:
* fix layout of packed bitfields

Luc Van Oostenryck (16):
add testcases for dubious enum values
add testcases for exotic enum values
add testcases for enum attributes
add testcases for type attributes
add testcases for packed structures
add testcases for packed bitfields
apply_ctype: use self-explanatory argument name
apply_ctype: reverse the order of arguments
apply_ctype: move up its declaration
struct-attr: prepare to handle attributes at the end of struct
definitions (1)
struct-attr: prepare to handle attributes at the end of struct
definitions (2)
struct-attr: prepare to handle attributes at the end of struct
definitions (3)
struct-attr: fix type attribute like 'struct __attr { ... }'
struct-attr: fix: do not ignore struct/union/enum type attributes
packed: no out-of-bound access of packed bitfields
packed: add support for __packed struct

 Documentation/TODO.md             |  3 --
 linearize.c                       | 13 +++++-
 parse.c                           | 78 ++++++++++++++++---------------
 symbol.c                          | 12 +++--
 symbol.h                          |  2 +
 validation/enum-type-dubious.c    | 18 +++++++
 validation/enum-type-exotic.c     | 28 +++++++++++
 validation/packed-bitfield0.c     | 58 +++++++++++++++++++++++
 validation/packed-bitfield1.c     | 27 +++++++++++
 validation/packed-bitfield2.c     | 15 ++++++
 validation/packed-bitfield3.c     | 28 +++++++++++
 validation/packed-bitfield4.c     | 18 +++++++
 validation/packed-bitfield5.c     | 20 ++++++++
 validation/packed-deref0.c        | 23 +++++++++
 validation/packed-struct.c        | 32 +++++++++++++
 validation/parsing/enum-attr.c    | 29 ++++++++++++
 validation/type-attribute-align.c | 19 ++++++++
 validation/type-attribute-as.c    | 33 +++++++++++++
 validation/type-attribute-mod.c   | 21 +++++++++
 validation/type-attribute-qual.c  | 15 ++++++
 20 files changed, 447 insertions(+), 45 deletions(-)
 create mode 100644 validation/enum-type-dubious.c
 create mode 100644 validation/enum-type-exotic.c
 create mode 100644 validation/packed-bitfield0.c
 create mode 100644 validation/packed-bitfield1.c
 create mode 100644 validation/packed-bitfield2.c
 create mode 100644 validation/packed-bitfield3.c
 create mode 100644 validation/packed-bitfield4.c
 create mode 100644 validation/packed-bitfield5.c
 create mode 100644 validation/packed-deref0.c
 create mode 100644 validation/packed-struct.c
 create mode 100644 validation/parsing/enum-attr.c
 create mode 100644 validation/type-attribute-align.c
 create mode 100644 validation/type-attribute-as.c
 create mode 100644 validation/type-attribute-mod.c
 create mode 100644 validation/type-attribute-qual.c
Signature · 1 line
2.29.2