diff options
-rw-r--r-- | .github/workflows/test.yml | 21 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | bd/lfs_filebd.c | 2 | ||||
-rw-r--r-- | lfs.c | 9 | ||||
-rw-r--r-- | lfs.h | 4 | ||||
-rw-r--r-- | lfs_util.h | 10 | ||||
-rwxr-xr-x | scripts/test.py | 2 |
8 files changed, 34 insertions, 19 deletions
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc8bb0c..81f00c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -292,6 +292,27 @@ jobs: - name: test-valgrind run: make test TESTFLAGS+="-k --valgrind" + # test that compilation is warning free under clang + clang: + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v2 + - name: install + run: | + # need toml, also pip3 isn't installed by default? + sudo apt-get update -qq + sudo apt-get install -qq python3 python3-pip + sudo pip3 install toml + - name: install-clang + run: | + sudo apt-get update -qq + sudo apt-get install -qq clang + echo "CC=clang" >> $GITHUB_ENV + clang --version + # no reason to not test again + - name: test-clang + run: make test TESTFLAGS+="-k" + # self-host with littlefs-fuse for a fuzz-like test fuse: runs-on: ubuntu-20.04 @@ -41,8 +41,7 @@ override CFLAGS += -DLFS_YES_TRACE endif override CFLAGS += -g3 override CFLAGS += -I. -override CFLAGS += -std=c99 -Wall -pedantic -override CFLAGS += -Wextra -Wshadow -Wjump-misses-init -Wundef +override CFLAGS += -std=c99 -Wall -Wextra -pedantic ifdef VERBOSE override TESTFLAGS += -v @@ -252,7 +252,7 @@ License Identifiers that are here available: http://spdx.org/licenses/ [mklfs]: https://github.com/whitecatboard/Lua-RTOS-ESP32/tree/master/components/mklfs/src [Lua RTOS]: https://github.com/whitecatboard/Lua-RTOS-ESP32 [Mbed OS]: https://github.com/armmbed/mbed-os -[LittleFileSystem]: https://os.mbed.com/docs/mbed-os/v5.12/apis/littlefilesystem.html +[LittleFileSystem]: https://os.mbed.com/docs/mbed-os/latest/apis/littlefilesystem.html [SPIFFS]: https://github.com/pellepl/spiffs [Dhara]: https://github.com/dlbeer/dhara [littlefs-python]: https://pypi.org/project/littlefs-python/ diff --git a/bd/lfs_filebd.c b/bd/lfs_filebd.c index 98e5abc..ee0c31e 100644 --- a/bd/lfs_filebd.c +++ b/bd/lfs_filebd.c @@ -204,7 +204,7 @@ int lfs_filebd_sync(const struct lfs_config *cfg) { // file sync lfs_filebd_t *bd = cfg->context; #ifdef _WIN32 - int err = FlushFileBuffers((HANDLE) _get_osfhandle(fd)) ? 0 : -1; + int err = FlushFileBuffers((HANDLE) _get_osfhandle(bd->fd)) ? 0 : -1; #else int err = fsync(bd->fd); #endif @@ -865,11 +865,6 @@ static int lfs_dir_traverse(lfs_t *lfs, }; sp += 1; - dir = dir; - off = off; - ptag = ptag; - attrs = attrs; - attrcount = attrcount; tmask = 0; ttag = 0; begin = 0; @@ -2999,12 +2994,14 @@ cleanup: return err; } +#ifndef LFS_NO_MALLOC static int lfs_file_rawopen(lfs_t *lfs, lfs_file_t *file, const char *path, int flags) { static const struct lfs_file_config defaults = {0}; int err = lfs_file_rawopencfg(lfs, file, path, flags, &defaults); return err; } +#endif static int lfs_file_rawclose(lfs_t *lfs, lfs_file_t *file) { #ifndef LFS_READONLY @@ -4196,7 +4193,7 @@ static int lfs_rawmount(lfs_t *lfs, const struct lfs_config *cfg) { if (superblock.block_size != lfs->cfg->block_size) { LFS_ERROR("Invalid block size (%"PRIu32" != %"PRIu32")", - superblock.block_count, lfs->cfg->block_count); + superblock.block_size, lfs->cfg->block_size); err = LFS_ERR_INVAL; goto cleanup; } @@ -534,8 +534,8 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file, // are values from the enum lfs_open_flags that are bitwise-ored together. // // The config struct provides additional config options per file as described -// above. The config struct must be allocated while the file is open, and the -// config struct must be zeroed for defaults and backwards compatibility. +// above. The config struct must remain allocated while the file is open, and +// the config struct must be zeroed for defaults and backwards compatibility. // // Returns a negative error code on failure. int lfs_file_opencfg(lfs_t *lfs, lfs_file_t *file, @@ -167,10 +167,9 @@ static inline int lfs_scmp(uint32_t a, uint32_t b) { // Convert between 32-bit little-endian and native order static inline uint32_t lfs_fromle32(uint32_t a) { -#if !defined(LFS_NO_INTRINSICS) && ( \ - (defined( BYTE_ORDER ) && defined( ORDER_LITTLE_ENDIAN ) && BYTE_ORDER == ORDER_LITTLE_ENDIAN ) || \ +#if (defined( BYTE_ORDER ) && defined( ORDER_LITTLE_ENDIAN ) && BYTE_ORDER == ORDER_LITTLE_ENDIAN ) || \ (defined(__BYTE_ORDER ) && defined(__ORDER_LITTLE_ENDIAN ) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN ) || \ - (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) + (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) return a; #elif !defined(LFS_NO_INTRINSICS) && ( \ (defined( BYTE_ORDER ) && defined( ORDER_BIG_ENDIAN ) && BYTE_ORDER == ORDER_BIG_ENDIAN ) || \ @@ -196,10 +195,9 @@ static inline uint32_t lfs_frombe32(uint32_t a) { (defined(__BYTE_ORDER ) && defined(__ORDER_LITTLE_ENDIAN ) && __BYTE_ORDER == __ORDER_LITTLE_ENDIAN ) || \ (defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)) return __builtin_bswap32(a); -#elif !defined(LFS_NO_INTRINSICS) && ( \ - (defined( BYTE_ORDER ) && defined( ORDER_BIG_ENDIAN ) && BYTE_ORDER == ORDER_BIG_ENDIAN ) || \ +#elif (defined( BYTE_ORDER ) && defined( ORDER_BIG_ENDIAN ) && BYTE_ORDER == ORDER_BIG_ENDIAN ) || \ (defined(__BYTE_ORDER ) && defined(__ORDER_BIG_ENDIAN ) && __BYTE_ORDER == __ORDER_BIG_ENDIAN ) || \ - (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)) + (defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__) return a; #else return (((uint8_t*)&a)[0] << 24) | diff --git a/scripts/test.py b/scripts/test.py index 92a13b1..c8196b3 100755 --- a/scripts/test.py +++ b/scripts/test.py @@ -93,7 +93,7 @@ PROLOGUE = """ __attribute__((unused)) lfs_dir_t dir; __attribute__((unused)) struct lfs_info info; __attribute__((unused)) char path[1024]; - __attribute__((unused)) uint8_t buffer[1024]; + __attribute__((unused)) uint8_t buffer[(1024 > LFS_BLOCK_SIZE * 4) ? (1024) : (LFS_BLOCK_SIZE * 4)]; __attribute__((unused)) lfs_size_t size; __attribute__((unused)) int err; |