4
0
Fork
You've already forked libopencm3
3

fix: Fixed warning: unsuffixed floating constant #4

Merged
lasutek merged 2 commits from fix/unsuffixed-floating-constant into main 2024年02月05日 12:22:55 +01:00
lasutek commented 2024年02月04日 23:32:23 +01:00 (Migrated from github.com)
Copy link

warning: unsuffixed floating constant [-Wunsuffixed-float-constants]

Note! Make sure sure to carefully check what I have done. I am no expert in the C language (or programming in general). If it looks wired, it probably is, and the PR should be rejected.

Reason behind my solution
C-language, or at least Gnu gcc, does not support exponents for integer constants, therefor integer constant expressions need to be changed to plain numbers (e.g. 72e6 --> 72000000).

The project builds without errors and warnings (that is the only test I can perform).

Blackmagic repo, Issue #1762

warning: unsuffixed floating constant [-Wunsuffixed-float-constants] **Note!** Make sure sure to carefully check what I have done. I am no expert in the C language (or programming in general). If it looks wired, it probably is, and the PR should be rejected. **Reason behind my solution** C-language, or at least Gnu gcc, does not support exponents for integer constants, therefor integer constant expressions need to be changed to plain numbers (e.g. 72e6 --> 72000000). The project builds without errors and warnings (that is the only test I can perform). Blackmagic repo, Issue #1762
dragonmux left a comment
Copy link

This all looks good - we've one suggestion for the lm4f RCC code, but otherwise this looks ready to merge.

This all looks good - we've one suggestion for the lm4f RCC code, but otherwise this looks ready to merge.
@ -372,7 +372,7 @@ void rcc_change_pll_divisor(uint8_t pll_div400)
/* Disable PLL bypass to derive the system clock from the PLL clock */

Given how this gets used, we're going to suggest a small tweak to this fix: 400000000U / (uint32_t)pll_div400; - this way the division gets done unsigned and we avoid a whole pile of potential UB dependant on the denominator fed in.

Given how this gets used, we're going to suggest a small tweak to this fix: `400000000U / (uint32_t)pll_div400;` - this way the division gets done unsigned and we avoid a whole pile of potential UB dependant on the denominator fed in.
dragonmux left a comment
Copy link

LGTM, thank you for the contribution! Merging.

LGTM, thank you for the contribution! Merging.
Sign in to join this conversation.
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blackmagic-debug/libopencm3!4
Reference in a new issue
blackmagic-debug/libopencm3
No description provided.
Delete branch "fix/unsuffixed-floating-constant"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?