Repository navigation
drivers/clk: use uintptr_t for register addresses to fix GCC15 warnings - #19168
Merged
Merged
Conversation
Change the 'reg' field type from uint32_t to uintptr_t in all clock provider structs (clk_gate_s, clk_divider_s, clk_phase_s, clk_fractional_divider_s, clk_multiplier_s, clk_mux_s) and their corresponding clk_register_*() function prototypes. Also update clk_write() and clk_read() inline functions to take uintptr_t parameter and remove the now-redundant (uintptr_t) cast. On 32-bit embedded platforms uintptr_t equals uint32_t so there is no functional change. On 64-bit targets (e.g. sim) this fixes -Wint-to-pointer-cast warnings that GCC15 promotes to errors. Fixes: apache#16896 Signed-off-by: hanzhijian <[email protected]>
xiaoxiang781216
previously approved these changes
Jun 17, 2026
Contributor
|
@Zepp-Hanzj please fix: |
Update the function definitions in all 6 clk implementation files to match the uintptr_t parameter type already declared in clk_provider.h. Fixes CI error: error: conflicting types for 'clk_register_divider' Signed-off-by: hanzhijian <[email protected]>
Contributor
Author
|
Fixed. Updated all 6 implementation files (, , , , , ) to match the parameter type in the header. Thanks for catching this! |
acassis
approved these changes
Jun 18, 2026
xiaoxiang781216
approved these changes
Jun 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Change the
regfield type fromuint32_ttouintptr_tin all clock provider structs and theirclk_register_*()function prototypes. Updateclk_write()/clk_read()inline helpers accordingly.Fixes #16896 (sub-item:
drivers/clk/clk.hint-to-pointer cast warning).Changes
drivers/clk/clk.h(2 functions):clk_write(uint32_t reg, ...)→clk_write(uintptr_t reg, ...)clk_read(uint32_t reg)→clk_read(uintptr_t reg)(uintptr_t)cast in function bodiesinclude/nuttx/clk/clk_provider.h(6 structs + 6 prototypes):uint32_t reg→uintptr_t regin:clk_gate_s,clk_divider_s,clk_phase_s,clk_fractional_divider_s,clk_multiplier_s,clk_mux_sclk_register_gate/divider/phase/fractional_divider/multiplier/mux()prototypesImpact
-Wint-to-pointer-castwarning on 64-bit targets (e.g.sim). GCC15 promotes this warning to an error.uintptr_t == uint32_t).Why
uintptr_tThe
regfield holds a memory-mapped register address. Usinguintptr_tis the semantically correct type for storing addresses in C. All callers pass address values, and the inline functions already cast through(uintptr_t)before dereferencing.Testing
Verified with
sim:nshbuild (the primary 64-bit target that triggers the warning):Also verified ARM cross-compilation has no regression: