Skip to content

warning: declaration of 'err' shadows a previous local [-Wshadow] #1147

@mattenic

Description

@mattenic

Hi

My CC is a tricore-gcc for AURIX.
I have some warning on lfs.c due to shadowing definition of err variable.

libs/littlefs/lfs.c: In function 'lfs_dir_commitcrc':
libs/littlefs/lfs.c:1768:17: warning: declaration of 'err' shadows a previous local [-Wshadow]
             int err = lfs_bd_sync(lfs, &lfs->pcache, &lfs->rcache, false);
                 ^
libs/littlefs/lfs.c:1745:13: warning: shadowed declaration is here [-Wshadow]
         int err = lfs_bd_prog(lfs,
             ^
libs/littlefs/lfs.c: In function 'lfs_fs_traverse_':
libs/littlefs/lfs.c:4721:17: warning: declaration of 'err' shadows a previous local [-Wshadow]
             int err = cb(data, dir.tail[i]);
                 ^
libs/littlefs/lfs.c:4713:9: warning: shadowed declaration is here [-Wshadow]
     int err = LFS_ERR_OK;
         ^
libs/littlefs/lfs.c:4728:13: warning: declaration of 'err' shadows a previous local [-Wshadow]
         int err = lfs_dir_fetch(lfs, &dir, dir.tail);
             ^
libs/littlefs/lfs.c:4713:9: warning: shadowed declaration is here [-Wshadow]
     int err = LFS_ERR_OK;
         ^
libs/littlefs/lfs.c:4771:17: warning: declaration of 'err' shadows a previous local [-Wshadow]
             int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
                 ^
libs/littlefs/lfs.c:4713:9: warning: shadowed declaration is here [-Wshadow]
     int err = LFS_ERR_OK;
         ^
libs/littlefs/lfs.c:4779:17: warning: declaration of 'err' shadows a previous local [-Wshadow]
             int err = lfs_ctz_traverse(lfs, &f->cache, &lfs->rcache,
                 ^
libs/littlefs/lfs.c:4713:9: warning: shadowed declaration is here [-Wshadow]
     int err = LFS_ERR_OK;
         ^
libs/littlefs/lfs.c: In function 'lfs_fs_pred':
libs/littlefs/lfs.c:4813:13: warning: declaration of 'err' shadows a previous local [-Wshadow]
         int err = lfs_dir_fetch(lfs, pdir, pdir->tail);
             ^
libs/littlefs/lfs.c:4802:9: warning: shadowed declaration is here [-Wshadow]
     int err = LFS_ERR_OK;

Here you can find a proposal for a patch -> Wshadow.patch

Matteo

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions