Skip to content

Conversation

@kjbracey
Copy link
Contributor

@kjbracey kjbracey commented Jun 14, 2019

Description

Use standard C++11/C11 forms for MBED_STRUCT_STATIC_ASSERT, MBED_NORETURN and MBED_ALIGN when available.

Using standard forms increases the chances that code analysis tools such Coverity will recognise them - particularly important for "no return".

Fix excess alignment problem caused by non-C++11 MBED_STRUCT_STATIC_ASSERT fallback using int.

Pull request type

[ ] Fix
[X] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

The `int : 0` bitfield this produced could force integer alignment onto
the structure it was placed in, making a structure that should be 1 byte
be 4 bytes.

Change `int` to `bool` to minimise alignment impact - should be to
nothing.

Alignment/size problem was revealed in a `sizeof` check in an
`Atomic<uint8_t>` test.
kjbracey added 2 commits June 14, 2019 14:56
If available, we can use standard static_assert.
Newer language standards have standard forms for `MBED_NORETURN` and
`MBED_ALIGN` attributes. Use them when available.

C++14 also adds `[[deprecated]]`, but as it needs to go in the middle of
structure definitions as `class [[deprecated]] MyClass`, it's not a
total drop-in-replacemend for `MBED_DEPRECATED`, so that is not
attempted here.

Using standard forms increases the chances that code analysis tools such
Coverity will recognise them - particularly important for "no return".
@ciarmcom ciarmcom requested review from a team June 14, 2019 13:00
@ciarmcom
Copy link
Member

@kjbracey-arm, thank you for your changes.
@ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@adbridge
Copy link
Contributor

@bulislaw one for you perhaps to review ?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 4, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Jul 4, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit e4b4539 into ARMmbed:master Jul 4, 2019
@kjbracey kjbracey deleted the toolchain11 branch July 8, 2019 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants