Skip to content

flash_map: pointer dereferencing causes build to fail #48722

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

Closed
sslupsky opened this issue Aug 5, 2022 · 2 comments · Fixed by #49191
Closed

flash_map: pointer dereferencing causes build to fail #48722

sslupsky opened this issue Aug 5, 2022 · 2 comments · Fixed by #49191
Assignees
Labels
area: Flash bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug

Comments

@sslupsky
Copy link
Contributor

sslupsky commented Aug 5, 2022

Describe the bug
A recent change to flash_map is causing build problems. A pointer is not properly declared which causes the build to fail.

shell_print(shell, "%-4d %-8d %-20s 0x%-10x 0x%-12x",
fa->fa_id, fa->fa_device_id, fa->fa_dev->name,
fa->fa_off, fa->fa_size);

In file included from /Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/storage/flash_map/flash_map_shell.c:7:
/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/storage/flash_map/flash_map_shell.c: In function 'fa_cb':
/Users/stevenslupsky/Documents/source/zephyrproject/zephyr/subsys/storage/flash_map/flash_map_shell.c:27:46: error: dereferencing pointer to incomplete type 'const struct device'
       fa->fa_id, fa->fa_device_id, fa->fa_dev->name,
                                              ^~

flash_map_shell.c and flash_map.h do not include device.h so the device struct has an incomplete type hence the error. Including device.h in flash_map.h resolves the problem.

@JordanYates FYI. #47193 appears to have caused this issue.

@sslupsky sslupsky added the bug The issue is a bug, or the PR is fixing a bug label Aug 5, 2022
@sslupsky
Copy link
Contributor Author

sslupsky commented Aug 5, 2022

Also, the fa->fa_off argument is throwing a Wformat warning. I am compiling on arm32 and the sizes are actually correct but the compiler is generating a warning. Probably should type cast the argument?

@fabiobaltieri
Copy link
Member

FYI @de-nordic.

sslupsky added a commit to sslupsky/zephyr that referenced this issue Aug 17, 2022
A pointer is not properly declared properly which causes the
build to fail.

flash_map_shell.c and flash_map.h do not include device.h so
the device struct has an incomplete type hence the build error.
Including device.h resolves the problem.

Also fixes a Wformat warning when referencing fa_off which is a pointer.
Cast the pointer to an uint32_t.

Fixes zephyrproject-rtos#48722

Signed-off-by: Steven Slupsky <[email protected]>
carlescufi pushed a commit that referenced this issue Aug 18, 2022
A pointer is not properly declared properly which causes the
build to fail.

flash_map_shell.c and flash_map.h do not include device.h so
the device struct has an incomplete type hence the build error.
Including device.h resolves the problem.

Also fixes a Wformat warning when referencing fa_off which is a pointer.
Cast the pointer to an uint32_t.

Fixes #48722

Signed-off-by: Steven Slupsky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Flash bug The issue is a bug, or the PR is fixing a bug priority: low Low impact/importance bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants