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

fs/littlefs:littlefs shouldn't be used without C99 BOOL #9037

Merged
merged 1 commit into from Apr 18, 2023

Conversation

XinStellaris
Copy link
Contributor

Summary

littlefs is a c99 project, and it malfunctions with c89. See disscusion in littlefs-project/littlefs#801.

To highlight this problem, littlefs added an assert in littlefs-project/littlefs#801.
However, it is better to expose this when compiling. This patch adds a compiling error when C99 requirement is not met.

Impact

Littlefs

Testing

Compiling okay.

@pkarashchenko
Copy link
Contributor

Can we either add CFLAGS += -std=c99 if C99 is a prerequisite or apply patch after tarball download to get it c89 compatible?

Copy link
Contributor

@pkarashchenko pkarashchenko left a comment

Choose a reason for hiding this comment

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

I re-inspected the code of littlefs and see that CFLAGS += -std=c99 is a must and code has designated initialiser, variable declaration in the middle of the scope and other C99 features.

@xiaoxiang781216
Copy link
Contributor

Can we either add CFLAGS += -std=c99 if C99 is a prerequisite or apply patch after tarball download to get it c89 compatible?

-std=c99 is tool chain specific, it isn't good to turn on it in the common code.

@pkarashchenko
Copy link
Contributor

But the littlefs code is anyway C89 in compliant no matter of a toolchain.
I just saw that CONFIG_C99_BOOL is selected based on __STDC_VERSION__ , so I'm fine with the change now.

#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#  define CONFIG_C99_BOOL 1
#endif

@xiaoxiang781216
Copy link
Contributor

Yes, I think it's enough to warn the user if they enforce c89 accidently.

Copy link
Contributor

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

Telling them why and what to do about would be better.

fs/littlefs/lfs_vfs.c Outdated Show resolved Hide resolved
@XinStellaris XinStellaris force-pushed the lfs_must_c99 branch 2 times, most recently from a2b8d5d to e04124d Compare April 18, 2023 12:15
fs/littlefs/lfs_vfs.c Outdated Show resolved Hide resolved
Signed-off-by: XinStellaris <tianxin7@xiaomi.com>
@davids5 davids5 merged commit 770817b into apache:master Apr 18, 2023
26 checks passed
@jerpelea jerpelea added this to To-Add in Release Notes - 12.2.0 Jun 13, 2023
@jerpelea jerpelea moved this from To-Add to In Progress in Release Notes - 12.2.0 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants