zephyr/subsys/fs
Aurelien Jarno 9e8bb61009 nvs: workaround a GCC and Coverity warning
Following the recent NVS changes, the following warning now appear with
GCC 7.3 when building with -O2:

ZEPHYROOT/subsys/fs/nvs/nvs.c: In function 'nvs_reinit':
ZEPHYROOT/subsys/fs/nvs/nvs.c:92:36: warning: 'addr' may be used
uninitialized in this function [-Wmaybe-uninitialized]
  offset += fs->sector_size * (addr >> ADDR_SECT_SHIFT);
                              ~~~~~~^~~~~~~~~~~~~~~~~~~
ZEPHYROOT/subsys/fs/nvs/nvs.c:606:8: note: 'addr' was declared here
  u32_t addr;
        ^~~~

This was already reported by Coverity earlier as CID:187903.

In practice this can only happen if fs->sector_count equals 0, which is
not possible as checked in nvs_init(). At least in the GCC case, it
believes that k_mutex_lock(&fs->nvs_lock, K_FOREVER) could modify
fs->sector_count.

Workaround the issue by initializing addr to 0.

Fixes #9767

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
2019-01-02 13:03:09 +01:00
..
fcb misra-c: Add 'U' to unsigned variable assignments in subsys/ 2018-12-04 22:51:56 -05:00
nvs nvs: workaround a GCC and Coverity warning 2019-01-02 13:03:09 +01:00
CMakeLists.txt
Kconfig subsys: filesystem: move conditional location 2018-11-02 15:31:44 -05:00
fat_fs.c misra-c: Add 'U' to unsigned variable assignments in subsys/ 2018-12-04 22:51:56 -05:00
fs.c
nffs_fs.c crc: deprecate old headers and issue warning when used 2018-12-04 08:52:46 -06:00
shell.c tests: subsys: fs: multifs: Enable fs shell using new shell 2018-12-14 13:14:17 +01:00