-
Notifications
You must be signed in to change notification settings - Fork 804
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
Wrong printf specifiers #982
Comments
Hi @stefano-zanotti, thanks for creating an issue. This would be good to fix. Out of curiousity, what compiler are you using? Compiling littlefs with -DLFS_YES_TRACE unfortunately doesn't report these warnings with our current makefile. |
In hindsight what PRI* expands to depends on the exact architecture. Given how printf/PRI* works, I don't think it's going to be possible for us to prevent these sort of mistakes in CI... |
I gone ahead and created #997 to fix this. Will bring it in on the next patch, though this is low priority. I had forgotten printf accepts %i, but I changed these to PRId32 for consistency. Let me know if you see any other uncaught format warnings. |
I'm using GCC, with these flags (among others) (According to the docs, the latter implies -Werror=format -Werror=format-nonliteral -Werror=format-security -Werror=format-y2k) The specific issue reported here is raised by "-Werror=format=2"; GCC reports something like: Signedness problems should be evident on every platform, though it's true that number-of-bits errors might be missed by CI depending on the target architecture. It's very possible that I missed some other cases (as you've already found), because of the specific LFS configuration flags I'm using. |
When LFS_TRACE is enabled, some printf-like calls are compiled.
Some of the %-specifiers are wrong (they do not match the actual type of the arguments), which raises compiler warnings, possibly escalated to errors.
In two cases (see below), the specifier should be changed. In another one, a cast is needed.
In lfs.c:5889: ".block_cycles=%"PRIu32 --> PRIi32
In lfs.c:5919: ".block_cycles=%"PRIu32 --> PRIi32
In lfs.c:6078: flags --> (unsigned)flags
The text was updated successfully, but these errors were encountered: