From 5176d7b81830718f130f98d4beab133f3736849e Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Aug 2024 14:36:02 +0200 Subject: [PATCH 1/2] Add checks for zombie sourcecode problems This adds checks for zombie sourcecode problems, i.e. problems we have tried to eliminate but which might be or have been resurrected. The example check is for the problematic #include "ac_cfg.h" with double quotes instead of <> which were identified as a problem in https://github.com/avrdudes/avrdude/issues/1706 and then fixed. --- .github/workflows/check-sourcecode.yml | 24 ++++++++++++ tools/check-sourcecode | 53 ++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 .github/workflows/check-sourcecode.yml create mode 100755 tools/check-sourcecode diff --git a/.github/workflows/check-sourcecode.yml b/.github/workflows/check-sourcecode.yml new file mode 100644 index 000000000..af24346df --- /dev/null +++ b/.github/workflows/check-sourcecode.yml @@ -0,0 +1,24 @@ +name: "Check Sourcecode" + +on: + push: + branches-ignore: + - 'onlinedocs' + pull_request: + branches-ignore: + - 'onlinedocs' + +jobs: + + check-sourcecode: + name: "Check Sourcecode" + runs-on: ubuntu-latest + + steps: + + - uses: actions/checkout@v4 + + # - name: Install prerequisites + + - name: "Check the sourcecode" + run: ./tools/check-sourcecode diff --git a/tools/check-sourcecode b/tools/check-sourcecode new file mode 100755 index 000000000..1ae5a8fc6 --- /dev/null +++ b/tools/check-sourcecode @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# check-sourcecode -- check the avrdude source code for zombie mistakes +# Copyright (C) 2024 Hans Ulrich Niedermann +# SPDX-License-Identifier: GPL-2.0-or-later + + +set -e + +prog="$(basename "$0")" +cd "$(dirname "$0")" +cd .. +test -s README.md +test -s COPYING +test -s build.sh +test -d .git/refs/heads + + +declare -a checks=() +fail=0 +succ=0 + + +checks+=(check_ac_cfg) +check_ac_cfg() { + if git grep -E '#include\s+"ac_cfg\.h"' + then + echo "Error: Found #include \"ac_cfg.h\" with double quotes \"\". Should be <>." + echo " See https://github.com/avrdudes/avrdude/issues/1706 for details." + return 1 + fi +} + + +for check in "${checks[@]}" +do + if "$check"; then + succ=$(( "$succ" + 1 )) + status="SUCC" + else + fail=$(( "$fail" + 1 )) + status="FAIL" + fi + echo "$status $check" +done +total=$(( "$succ" + "$fail" )) + + +echo "$prog: Summary: $fail checks failed, $succ checks succeeded. $total checks in total." +if [[ "$fail" -gt 0 ]]; then + exit 1 +else + exit 0 +fi From 548c8711948d18a32d4c416f5fb2940e56c20347 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Sat, 24 Aug 2024 14:45:24 +0200 Subject: [PATCH 2/2] Fix all remaining #include "ac_cfg.h" to use --- src/config_gram.y | 2 +- src/lexer.l | 2 +- src/libavrdude.i | 2 +- src/serprog.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config_gram.y b/src/config_gram.y index 797796b23..9bf134864 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -20,7 +20,7 @@ %{ -#include "ac_cfg.h" +#include #include #include diff --git a/src/lexer.l b/src/lexer.l index d33ad4ba8..9489c6fc3 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -25,7 +25,7 @@ #include #include -#include "ac_cfg.h" +#include #include "avrdude.h" #include "libavrdude.h" #include "config.h" diff --git a/src/libavrdude.i b/src/libavrdude.i index ebc3794e0..235904118 100644 --- a/src/libavrdude.i +++ b/src/libavrdude.i @@ -35,7 +35,7 @@ The following global variables are available in `ad.cvar`: %module (docstring=DOCSTRING) swig_avrdude %feature("autodoc", "1"); %{ -#include "ac_cfg.h" +#include #include "libavrdude.h" // global variables referenced by library diff --git a/src/serprog.c b/src/serprog.c index c47b41b15..d85e3afb6 100644 --- a/src/serprog.c +++ b/src/serprog.c @@ -22,7 +22,7 @@ * */ -#include "ac_cfg.h" +#include #include "avrdude.h" #include "libavrdude.h"