Open ahollist opened 4 years ago
Ah! Good find. I should see if I can add clang-analyzer-core to littlefs's CI.
I don't have anything against changing these to strncpy. Unfortunately it looks like strlcpy is not available in C99, which is a shame since it looks like it fixes the main flaw with strncpy (which IMO kinda defeats the main purpose of strncpy).
When adding littlefs to a project that uses Clang static checking that includes
clang-analyzer-core
, thelittlefs.c.o
object throws several errors during compilation:Suppressing clang checking/warnings-as-errors on the library allows littlefs to build just fine, and indeed I can cross compile with arm-gcc with no problem.
I understand the reasons for using strcpy on such single character literals, but for the purposes of projects which may use clang or other static analysis, would it make sense to change these function calls to be the 'safer' strncpy or strlcpy?
Here are the resulting lines in my CMakeLists.txt that exclude Clang: (other compilation flags are set elsewhere)