Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checks for zombie sourcecode problems #1910

Merged
merged 2 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/check-sourcecode.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/config_gram.y
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

%{

#include "ac_cfg.h"
#include <ac_cfg.h>

#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion src/lexer.l
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <sys/types.h>
#include <sys/stat.h>

#include "ac_cfg.h"
#include <ac_cfg.h>
#include "avrdude.h"
#include "libavrdude.h"
#include "config.h"
Expand Down
2 changes: 1 addition & 1 deletion src/libavrdude.i
Original file line number Diff line number Diff line change
Expand Up @@ -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 <ac_cfg.h>
#include "libavrdude.h"

// global variables referenced by library
Expand Down
2 changes: 1 addition & 1 deletion src/serprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*
*/

#include "ac_cfg.h"
#include <ac_cfg.h>

#include "avrdude.h"
#include "libavrdude.h"
Expand Down
53 changes: 53 additions & 0 deletions tools/check-sourcecode
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env bash
# check-sourcecode -- check the avrdude source code for zombie mistakes
# Copyright (C) 2024 Hans Ulrich Niedermann <hun@n-dimensional.de>
# 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
Loading