Skip to content

Conversation

@JPHutchins
Copy link
Contributor

Generally, the flash_sector array is known at compile time and is immutable, therefore developers may like to store it in ROM. The only function that requires a mutable struct flash_sector seems to be flash_area_get_sectors(), allowing the developer to store a mutable sector definition in persistent RAM rather than ROM. An example of this approach is in setting_fcb.c.

@de-nordic de-nordic added the Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. label Oct 23, 2024
@de-nordic de-nordic added this to the 4.1 milestone Oct 23, 2024
@Laczen Laczen removed their request for review October 24, 2024 03:38
@erwango erwango modified the milestones: 4.1, v4.1.0 Oct 24, 2024
@JPHutchins JPHutchins force-pushed the refactor/fcb-flash-sectors-const branch from 8d068c2 to 82f8700 Compare November 6, 2024 01:54
@JPHutchins
Copy link
Contributor Author

I am able to reproduce the CI error on local:

./scripts/coccicheck --mode=report --cocci=scripts/coccinelle/same_identifier.cocci | grep fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_last_of_n.c:13:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_append.c:59:23-26: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_append.c:120:30-33: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_append.c:39:34-37: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_append.c:14:61-64: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_empty_walk.c:13:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_append_too_big.c:12:14-17: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_rotate.c:12:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_multiple_scratch.c:12:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_append_fill.c:12:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_init.c:13:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_walk.c:15:25-28: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/tests/subsys/fs/fcb/src/fcb_test_reset.c:12:13-16: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_rotate.c:12:23-26: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_getnext.c:108:24-27: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_getnext.c:14:34-37: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_getnext.c:43:31-34: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
/home/jp/repos/zephyrproject/zephyr/subsys/fs/fcb/fcb_getnext.c:33:58-61: WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb

But not sure how to improve!

@github-actions
Copy link

github-actions bot commented Jan 6, 2025

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jan 6, 2025
@JPHutchins
Copy link
Contributor Author

Needs rebase.

@github-actions github-actions bot removed the Stale label Jan 7, 2025
Copy link
Contributor

@de-nordic de-nordic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the const type qualifier between type definition and after storage class (extern).
The change sticks out from all the other code, including modified files:
image

@kartben
Copy link
Contributor

kartben commented Jan 31, 2025

Needs rebase.

Yes but you're the author? 🙂

Generally, the flash_sector array is known at compile time and
is immutable, therefore developers may like to store it in ROM.
The only function that requires a mutable struct flash_sector
seems to be flash_area_get_sectors(), allowing the developer
to store a mutable sector definition in persistent RAM rather
than ROM.  An example of this approach is in setting_fcb.c.

Signed-off-by: JP Hutchins <[email protected]>
@JPHutchins JPHutchins force-pushed the refactor/fcb-flash-sectors-const branch from 82f8700 to 5ea63d0 Compare January 31, 2025 05:32
@JPHutchins JPHutchins requested a review from de-nordic January 31, 2025 05:33
@JPHutchins
Copy link
Contributor Author

Any insight on these compliance check problems? They are present on lines that are not modified by this PR.

Error: subsys/fs/fcb/fcb_append.c:14:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
subsys/fs/fcb/fcb_getnext.c:33:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
subsys/fs/fcb/fcb_walk.c:15:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
Error: Process completed with exit code 1.

@de-nordic
Copy link
Contributor

Any insight on these compliance check problems? They are present on lines that are not modified by this PR.

Error: subsys/fs/fcb/fcb_append.c:14:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
subsys/fs/fcb/fcb_getnext.c:33:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
subsys/fs/fcb/fcb_walk.c:15:WARNING: Violation to rule 5.7 (Tag name should be unique) tag: fcb
Error: Process completed with exit code 1.

I guess CI does not like name of variable to be the same as type used to define it.
It was that before, but you have touched the line, so CI can now insist on you to fix it.

@kartben
Copy link
Contributor

kartben commented Jan 31, 2025

ya most of these files hadn't been touched in many years, and the coding guidelines check has been introduced since then. Luckily the fix should be pretty straightforward

@fabiobaltieri fabiobaltieri modified the milestones: v4.1.0, v4.2.0 Mar 6, 2025
Comment on lines -33 to +37
struct flash_sector test_fcb_sector[] = {
[0] = {
.fs_off = 0,
.fs_size = SECTOR_SIZE
},
[1] = {
.fs_off = SECTOR_SIZE,
.fs_size = SECTOR_SIZE
},
[2] = {
.fs_off = 2 * SECTOR_SIZE,
.fs_size = SECTOR_SIZE
},
[3] = {
.fs_off = 3 * SECTOR_SIZE,
.fs_size = SECTOR_SIZE
}
};

const struct flash_sector test_fcb_sector[] = {
[0] = {.fs_off = 0, .fs_size = SECTOR_SIZE},
[1] = {.fs_off = SECTOR_SIZE, .fs_size = SECTOR_SIZE},
[2] = {.fs_off = 2 * SECTOR_SIZE, .fs_size = SECTOR_SIZE},
[3] = {.fs_off = 3 * SECTOR_SIZE, .fs_size = SECTOR_SIZE}};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated change? same in another couple of files, PRs should nto change unrelated code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JPHutchins If you did run clang format on the code, please do not do that. At least not with other changes.

@github-actions
Copy link

github-actions bot commented May 6, 2025

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label May 6, 2025
@de-nordic de-nordic removed the Stale label May 6, 2025
@de-nordic
Copy link
Contributor

Any movement here?

@github-actions
Copy link

github-actions bot commented Jul 6, 2025

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jul 6, 2025
@github-actions github-actions bot closed this Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: File System area: Settings Settings subsystem Stale Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants