From 23747628d58498fecce108df80b2d4dcbeb9071f Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 7 Sep 2022 12:23:44 -0500 Subject: [PATCH 1/3] Added clang build step to CI As found by dpgeorge, clang has slightly different warnings than GCC. There's really no cost to running clang as an extra build step to test for these. --- .github/workflows/test.yml | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bc8bb0c6..81f00c1e 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 From 30175de38414afd6e6e0c77de06649933e535526 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 7 Sep 2022 12:38:04 -0500 Subject: [PATCH 2/3] Remove -Wshadow -Wjump-misses-init -Wundef Doing this now specifically because clang does not have -Wjump-misses-init, but I've been looking for an excuse to remove these for a while. These warning flags create more annoyance than they add value. There is probably a reason they aren't included in -Wall + -Wextra. -Wshadow specifically is potentially harmful as it forces coming up with new, sometimes less descriptive names for repeated variables. Dependent projects should use different flags for their dependencies if this introduces problems. --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7cc59f8a..13879336 100644 --- a/Makefile +++ b/Makefile @@ -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 From 47914b925fd8dd558b68dffc826f9a4097519e0e Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Wed, 7 Sep 2022 12:46:29 -0500 Subject: [PATCH 3/3] Fixed self-assign warnings discovered by clang --- lfs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lfs.c b/lfs.c index 117595e0..9e47bb2a 100644 --- a/lfs.c +++ b/lfs.c @@ -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;