From 8c45c68e419043e37e4b571771884f944dd39fd4 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 21 Apr 2026 17:26:30 +1000 Subject: [PATCH 1/6] cli: avoid passing function pointer through 'void *' Technically it is Undefined Behavior to cast back-and-forth between function pointers and other pointers in strict ISO C, because it is not guaranteed that function pointers have the same representation/width. This change is progress towards being -Wpedantic clean. --- cli/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cli/main.c b/cli/main.c index a06dd96..ca7ec05 100644 --- a/cli/main.c +++ b/cli/main.c @@ -194,8 +194,8 @@ static void discard_entries(passwand_entry_t **entries, size_t *entry_len) { // not need the state parameter static void entry_trampoline(void *state, const char *space, const char *key, const char *value) { - void (*f)(const char *, const char *, const char *) = state; - f(space, key, value); + const command_t *const cmd = state; + cmd->loop_body(space, key, value); } typedef struct { @@ -231,8 +231,9 @@ static void *thread_loop(void *arg) { break; if (command->loop_body != NULL) { - passwand_error_t err = passwand_entry_do( - ts->main, &ts->entries[index], entry_trampoline, command->loop_body); + passwand_error_t err = + passwand_entry_do(ts->main, &ts->entries[index], entry_trampoline, + (command_t *)command); if (err != PW_OK) { eprint("failed to handle entry %zu: %s\n", index, passwand_error(err)); ret = (void *)-1; From 0b55c544355952490b4f6779411a3f14f859370e Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 21 Apr 2026 17:28:30 +1000 Subject: [PATCH 2/6] gui: avoid GNU case range extension Further progress towards being -Wpedantic clean. --- gui/gui.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/gui.h b/gui/gui.h index 738fe31..6a968e2 100644 --- a/gui/gui.h +++ b/gui/gui.h @@ -3,10 +3,12 @@ #include static inline bool supported_lower(char c) { + if (c >= 'a' && c <= 'z') + return true; + if (c >= '0' && c <= '9') + return true; switch (c) { - case 'a' ... 'z': case '`': - case '0' ... '9': case '-': case '=': case '[': @@ -24,8 +26,9 @@ static inline bool supported_lower(char c) { } static inline bool supported_upper(char c) { + if (c >= 'A' && c <= 'Z') + return true; switch (c) { - case 'A' ... 'Z': case '~': case '!': case '@': From f0a6b76a1b9aced613b9865f36557c379619899f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 21 Apr 2026 17:33:05 +1000 Subject: [PATCH 3/6] CI: migrate no-GUI Linux job to Github Actions This regresses to GCC 13, but I think that is fine for now. We also get to drop the locale kludges because locales are configured reasonably in the Github Actions Ubuntu images. We also drop installing `man-db` because it is already there in these images. --- .cirrus.yml | 13 ------------- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 265104d..83d304d 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,19 +4,6 @@ task: only_if: $CIRRUS_BRANCH == "main" || $CIRRUS_PR != "" matrix: - - name: Linux, GCC, no GTK - container: - image: gcc:15.1 - environment: - DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined -fuse-ld=gold - # $LANG and $LC_* are not set by default in this images, so force - # $LC_ALL to make `man` work correctly - LC_ALL: C - UBSAN_OPTIONS: print_stacktrace=1 - install_script: apt-get update -y && apt-get install --no-install-recommends -y cmake libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev man-db python3-pexpect python3-pytest xxd - test_script: uname -sr && python3 --version && mkdir build && cd build && cmake -DENABLE_GUI=OFF .. && cmake --build . && cmake --build . -- check && cmake --build . -- install - - name: Linux, GCC, GTK 2 container: image: gcc:15.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 274804a..d419326 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,3 +32,23 @@ jobs: cmake --build build cmake --build build --target check cmake --install build + + ubuntu2404_nogui: + name: Ubuntu 24.04, no GTK + runs-on: ubuntu-24.04 + env: + DEBIAN_FRONTEND: noninteractive + CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + UBSAN_OPTIONS: print_stacktrace=1 + steps: + - run: uname -rms + - run: python3 --version + - run: sudo apt-get update + - run: sudo apt-get install --no-install-recommends -y cmake libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev python3-pexpect python3-pytest xxd + - run: echo "cloning ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" + - run: git clone --no-checkout -- ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} wd + - run: cd wd && git fetch -- origin ${{ github.event.pull_request.head.sha }} && git checkout FETCH_HEAD + - run: cmake -DENABLE_GUI=OFF -B build -S wd + - run: cmake --build build + - run: cmake --build build --target check + - run: sudo cmake --install build From 6ba6714e0bb42fbc9422239b3fe2a5e1e7620794 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 21 Apr 2026 17:36:33 +1000 Subject: [PATCH 4/6] CI: migrate GTK 2 Linux job to Github Actions --- .cirrus.yml | 13 ------------- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 83d304d..69d6bc8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,19 +4,6 @@ task: only_if: $CIRRUS_BRANCH == "main" || $CIRRUS_PR != "" matrix: - - name: Linux, GCC, GTK 2 - container: - image: gcc:15.1 - environment: - DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined -fuse-ld=gold -Wno-deprecated-declarations - # $LANG and $LC_* are not set by default in this images, so force - # $LC_ALL to make `man` work correctly - LC_ALL: C - UBSAN_OPTIONS: print_stacktrace=1 - install_script: apt-get update -y && apt-get install --no-install-recommends -y cmake libgtk2.0-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev man-db python3-pexpect python3-pytest xxd - test_script: uname -sr && python3 --version && mkdir build && cd build && cmake .. && cmake --build . && cmake --build . -- check && cmake --build . -- install - - name: Linux, GCC, GTK 3 container: image: gcc:15.1 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d419326..b6deb9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -52,3 +52,23 @@ jobs: - run: cmake --build build - run: cmake --build build --target check - run: sudo cmake --install build + + ubuntu2404_gtk2: + name: Ubuntu 24.04, GTK 2 + runs-on: ubuntu-24.04 + env: + DEBIAN_FRONTEND: noninteractive + CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + UBSAN_OPTIONS: print_stacktrace=1 + steps: + - run: uname -rms + - run: python3 --version + - run: sudo apt-get update + - run: sudo apt-get install --no-install-recommends -y cmake libgtk2.0-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev python3-pexpect python3-pytest xxd + - run: echo "cloning ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" + - run: git clone --no-checkout -- ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} wd + - run: cd wd && git fetch -- origin ${{ github.event.pull_request.head.sha }} && git checkout FETCH_HEAD + - run: cmake -B build -S wd + - run: cmake --build build + - run: cmake --build build --target check + - run: sudo cmake --install build From cd840b441cfdd9a9a894c21b4f111291b9c9ed89 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 21 Apr 2026 17:36:33 +1000 Subject: [PATCH 5/6] CI: migrate GTK 3 Linux job to Github Actions --- .cirrus.yml | 13 ------------- .github/workflows/ci.yml | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 69d6bc8..b480ca0 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -4,19 +4,6 @@ task: only_if: $CIRRUS_BRANCH == "main" || $CIRRUS_PR != "" matrix: - - name: Linux, GCC, GTK 3 - container: - image: gcc:15.1 - environment: - DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=undefined -fuse-ld=gold -Wno-deprecated-declarations - # $LANG and $LC_* are not set by default in this images, so force - # $LC_ALL to make `man` work correctly - LC_ALL: C - UBSAN_OPTIONS: print_stacktrace=1 - install_script: apt-get update -y && apt-get install --no-install-recommends -y cmake libgtk-3-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev man-db python3-pexpect python3-pytest xxd - test_script: uname -sr && python3 --version && mkdir build && cd build && cmake .. && cmake --build . && cmake --build . -- check && cmake --build . -- install - - name: macOS macos_instance: image: ghcr.io/cirruslabs/macos-runner:sequoia diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6deb9e..68f72eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,3 +72,23 @@ jobs: - run: cmake --build build - run: cmake --build build --target check - run: sudo cmake --install build + + ubuntu2404_gtk3: + name: Ubuntu 24.04, GTK 3 + runs-on: ubuntu-24.04 + env: + DEBIAN_FRONTEND: noninteractive + CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + UBSAN_OPTIONS: print_stacktrace=1 + steps: + - run: uname -rms + - run: python3 --version + - run: sudo apt-get update + - run: sudo apt-get install --no-install-recommends -y cmake libgtk-3-dev libjson-c-dev libscrypt-kdf1 libscrypt-kdf-dev libxtst-dev python3-pexpect python3-pytest xxd + - run: echo "cloning ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}" + - run: git clone --no-checkout -- ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} wd + - run: cd wd && git fetch -- origin ${{ github.event.pull_request.head.sha }} && git checkout FETCH_HEAD + - run: cmake -B build -S wd + - run: cmake --build build + - run: cmake --build build --target check + - run: sudo cmake --install build From e6f2e31afa4268d3a04346853e6c2783d1076b82 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 21 Apr 2026 17:41:35 +1000 Subject: [PATCH 6/6] CI: enable -pedantic --- .cirrus.yml | 2 +- .github/workflows/ci.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index b480ca0..9a7f2ba 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -8,7 +8,7 @@ task: macos_instance: image: ghcr.io/cirruslabs/macos-runner:sequoia environment: - CFLAGS: -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/include + CFLAGS: -pedantic -I/opt/homebrew/opt/openssl@3/include -I/opt/homebrew/include LDFLAGS: -L/opt/homebrew/opt/openssl@3/lib -L/opt/homebrew/lib PKG_CONFIG_PATH: /opt/homebrew/opt/openssl@3/lib/pkgconfig install_script: brew update && brew install json-c libscrypt openssl python3 && env PIP_BREAK_SYSTEM_PACKAGES=1 python3 -m pip install pexpect pytest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68f72eb..27afd79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,7 @@ jobs: cd wd git fetch -- origin ${{ github.event.pull_request.head.sha }} git checkout FETCH_HEAD - export CFLAGS="-Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined" + export CFLAGS="-pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined" export UBSAN_OPTIONS=print_stacktrace=1 cmake -DENABLE_GUI=OFF -B build -S . cmake --build build @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-24.04 env: DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + CFLAGS: -pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined UBSAN_OPTIONS: print_stacktrace=1 steps: - run: uname -rms @@ -58,7 +58,7 @@ jobs: runs-on: ubuntu-24.04 env: DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + CFLAGS: -pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined UBSAN_OPTIONS: print_stacktrace=1 steps: - run: uname -rms @@ -78,7 +78,7 @@ jobs: runs-on: ubuntu-24.04 env: DEBIAN_FRONTEND: noninteractive - CFLAGS: -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined + CFLAGS: -pedantic -Werror -g -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined UBSAN_OPTIONS: print_stacktrace=1 steps: - run: uname -rms