littlefs icon indicating copy to clipboard operation
littlefs copied to clipboard

Compiler warnings in `lfs_dir_traverse` about `dir = dir` etc

Open dpgeorge opened this issue 2 years ago • 5 comments

Removal of recursion in lfs_dir_traverse in 8109f282668d0396c1a8df05d38ed215b0b8feac added 4 lines which give warnings on some compilers (eg clang):

               dir = dir;
               off = off;
               ptag = ptag;
               attrs = attrs;
               attrcount = attrcount;

I suggest to remove these 5 lines.

dpgeorge avatar May 23 '22 02:05 dpgeorge

Example of warning:

../../lib/littlefs/lfs2.c:868:27: error: explicitly assigning value of variable of type 'int' to itself [-Werror,-Wself-assign]
                attrcount = attrcount;
                ~~~~~~~~~ ^ ~~~~~~~~~

dpgeorge avatar May 23 '22 02:05 dpgeorge

Thanks for creating an issue, it sounds like we should add clang to CI with -Werror like we have GCC.

I'll look at these for the next patch release.

geky avatar May 23 '22 07:05 geky

it sounds like we should add clang to CI with -Werror like we have GCC

Yes I think that would be a good idea, to prevent other warnings from creeping in.

So, is it the correct fix to just remove these 5 lines? (We need to apply that patch to our copy of littlefs.)

dpgeorge avatar May 23 '22 07:05 dpgeorge

So, is it the correct fix to just remove these 5 lines? (We need to apply that patch to our copy of littlefs.)

Yes those lines have no effect. I think I left them as a documentation tool since those variables are the "stack frame" of the lfs_dir_traverse function.

geky avatar May 23 '22 07:05 geky

Sorry for about the timing. I have a PR for this up here now: https://github.com/littlefs-project/littlefs/pull/724

geky avatar Sep 07 '22 17:09 geky