Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow VLAs in Matter code #9476

Merged
merged 2 commits into from
Sep 8, 2021

Conversation

bzbarsky-apple
Copy link
Contributor

Problem

VLAs can be dangerous, especially when sized based on network inputs.

Change overview

Stop using VLAs in most places, whitelist a few places that are tracked by open issues, and add -Wvla so no more places will get added accidentally.

Testing

Compiles and passes CI. No behavior changes.

@todo
Copy link

todo bot commented Sep 3, 2021

This VLA is not OK. See #8558 }}

{{! TODO: This VLA is not OK. See https://github.com/project-chip/connectedhomeip/issues/8558 }}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wvla"
{{chipType}} data[count];
#pragma GCC diagnostic pop
for (size_t i = 0; i < count; i++)
{
{{#if isStruct}}


This comment was generated by todo based on a TODO comment in fd767da in #9476. cc @bzbarsky-apple.

…onfig.

We suppress the warning in two places, both tracked by existing issues.
@github-actions
Copy link

github-actions bot commented Sep 8, 2021

Size increase report for "esp32-example-build" from 1e5a48b

File Section File VM
chip-temperature-measurement-app.elf .flash.text -36 -36
chip-ipv6only-app.elf .flash.text -172 -172
Full report output
BLOAT REPORT

Files found only in the build output:
    report.csv

Comparing ./master_artifact/chip-pigweed-app.elf and ./pull_artifact/chip-pigweed-app.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-shell.elf and ./pull_artifact/chip-shell.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-bridge-app.elf and ./pull_artifact/chip-bridge-app.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-all-clusters-app.elf and ./pull_artifact/chip-all-clusters-app.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-temperature-measurement-app.elf and ./pull_artifact/chip-temperature-measurement-app.elf:

sections,vmsize,filesize
[Unmapped],0,36
.flash.text,-36,-36

Comparing ./master_artifact/chip-persistent-storage.elf and ./pull_artifact/chip-persistent-storage.elf:

sections,vmsize,filesize

Comparing ./master_artifact/chip-ipv6only-app.elf and ./pull_artifact/chip-ipv6only-app.elf:

sections,vmsize,filesize
.flash.text,-172,-172
[Unmapped],0,-3924

Comparing ./master_artifact/chip-lock-app.elf and ./pull_artifact/chip-lock-app.elf:

sections,vmsize,filesize


@andy31415 andy31415 merged commit 3a3fbc0 into project-chip:master Sep 8, 2021
@bzbarsky-apple bzbarsky-apple deleted the disallow-vla branch September 8, 2021 18:59
kpschoedel pushed a commit to kpschoedel/connectedhomeip that referenced this pull request Sep 9, 2021
* Disallow VLAs in Matter code by adding -Wvla to our strict warnings config.

We suppress the warning in two places, both tracked by existing issues.

* Regenerate generated files
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.

5 participants