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

core: chibios: bootloader: use integer pointers as volatile #13450

Merged
merged 1 commit into from
Jul 5, 2021

Conversation

t-8ch
Copy link
Contributor

@t-8ch t-8ch commented Jul 4, 2021

Description

core: chibios: bootloader: use integer pointers as volatile

This prevents gcc from incorrectly trying to validate array bounds.

tmk_core/common/chibios/bootloader.c: error: '__builtin_memcpy' offset [0, 21] is out of the bounds [0, 0] [-Werror=array-bounds]
  107 |     __builtin_memcpy((void *) VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c16

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Note: This is only compile tested, as I don't have such a device.

This prevents gcc from incorrectly trying to validate array bounds.

```
tmk_core/common/chibios/bootloader.c: error: '__builtin_memcpy' offset [0, 21] is out of the bounds [0, 0] [-Werror=array-bounds]
  107 |     __builtin_memcpy((void *) VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c16
Fixes qmk#12925
@github-actions github-actions bot added the core label Jul 4, 2021
@zvecr zvecr requested review from fauxpark, tzarc and a team July 4, 2021 22:29
@tzarc tzarc requested a review from a team July 4, 2021 22:56
@fauxpark
Copy link
Member

fauxpark commented Jul 5, 2021

@firetech

@firetech
Copy link
Contributor

firetech commented Jul 5, 2021

@firetech

@fauxpark Eh, hi? 🤔

@fauxpark
Copy link
Member

fauxpark commented Jul 5, 2021

Just thought you may want to check this works, as OP doesn't have a Kinetis device :)

@firetech
Copy link
Contributor

firetech commented Jul 5, 2021

Ah, read up a bit on #12925. Without that context I was wildly confused...

I haven't had any such issues compiling on my Debian system, though. Maybe we should ping @TheEdgeOfRage to check if it solves their issue? :)

@fauxpark
Copy link
Member

fauxpark commented Jul 5, 2021

Whoops, didn't notice the linked issue. Sorry for the noise.

@firetech
Copy link
Contributor

firetech commented Jul 5, 2021

No problem, happy to help anyway. 😛

@firetech
Copy link
Contributor

firetech commented Jul 5, 2021

I can confirm that the fix doesn't seem to introduce any issues on my Debian system at least. Compiling (still) works fine, and my RESET key does what it should.

@zvecr zvecr merged commit a535d24 into qmk:develop Jul 5, 2021
cadusk pushed a commit to cadusk/qmk_firmware that referenced this pull request Jul 7, 2021
* qmk/develop: (23 commits)
  Use the new ST7565 driver on Ergodox Infinity (qmk#13165)
  Xelus Ninjin: rename LAYOUT_all to LAYOUT_tkl_ansi_tsangan; add info.json (qmk#13477)
  Kopibeng XT65: Layout Macro Refactor (qmk#13476)
  [Keyboard] Add poker87c and poker87d (qmk#12810)
  [Keyboard] Add new Elise, 65% Keyboard ANSI / ISO  (qmk#12782)
  [Keyboard] Add bm65iso (qmk#13400)
  [Keyboard] Add keyboard reviung5 (qmk#13375)
  [Keyboard] Add kabedon98e (qmk#13314)
  [Keyboard] Set reasonable defaults for Corne keyboard (qmk#13440)
  /bin/bash to /usr/bin/env bash (qmk#13422)
  Update `MSG_PYTHON_MISSING` (qmk#13427)
  core: chibios: bootloader: use integer pointers as volatile (qmk#13450)
  Migrate SHIFT_ESC and RGB `fn_actions` to Grave Escape and RGB keycodes (qmk#13360)
  `keymap_extras`: Remove deprecated defines (qmk#12949)
  [Keyboard] fix encoder_update_user for nullbitsco/nibble (qmk#13451)
  Traveller cleanup (qmk#13441)
  LatinPadBLE: correct info.json data (qmk#13452)
  Jabberwocky: adjust key positioning in Configurator (qmk#13447)
  Molecule: Layout Macro Refactor (qmk#13453)
  [Docs] added list of MIDI keycodes (qmk#13159)
  ...
@TheEdgeOfRage
Copy link

For completeness sake, I can confirm that this fixed it for me. Thanks 👍

@t-8ch t-8ch deleted the chibios-gcc11 branch August 26, 2021 10:50
nhongooi pushed a commit to nhongooi/qmk_firmware that referenced this pull request Dec 5, 2021
This prevents gcc from incorrectly trying to validate array bounds.

```
tmk_core/common/chibios/bootloader.c: error: '__builtin_memcpy' offset [0, 21] is out of the bounds [0, 0] [-Werror=array-bounds]
  107 |     __builtin_memcpy((void *) VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c16
Fixes qmk#12925
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
This prevents gcc from incorrectly trying to validate array bounds.

```
tmk_core/common/chibios/bootloader.c: error: '__builtin_memcpy' offset [0, 21] is out of the bounds [0, 0] [-Werror=array-bounds]
  107 |     __builtin_memcpy((void *) VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578#c16
Fixes qmk#12925
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants