Skip to content

Commit

Permalink
Merge pull request #1821 from greenbone/fix-c-formatting2
Browse files Browse the repository at this point in the history
Fix C formatting again.
  • Loading branch information
Tehforsch authored Jan 27, 2025
2 parents 1c48c95 + fecae2f commit 27ab641
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
17 changes: 17 additions & 0 deletions .github/check-c-formatting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env sh
# I wanted to get the merge base using {{ github.base_ref }}, however this is only
# available for the event that opens the PR or edits it, not on pushes to the branch.
# Comparing to main should be an OK alternative, since it will - at worst - do more
# autoformatting than it otherwise would.

[ -z "$1" ] && merge_base=main || merge_base="$1"

git fetch origin $merge_base:refs/remotes/origin/$merge_base

echo "$(clang-format --version)"
(git diff --name-only "origin/$merge_base") | while read filename; do
extension="${filename##*.}"
if [ "$extension" = "c" ] || [ "$extension" = "h" ]; then
clang-format -i -style=file "$filename"
fi
done
4 changes: 1 addition & 3 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ jobs:
- name: Check out openvas-scanner
uses: actions/checkout@v4
- name: Formatting
run: |
clang-format -i -style=file {src,misc,nasl}/*.{c,h}
git diff --exit-code
run: sh .github/check-c-formatting.sh ${{ github.base_ref }}
Rust:
runs-on: ubuntu-latest
defaults:
Expand Down
4 changes: 2 additions & 2 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ write_script_stats (const char *buf, const char *path, int mode)
pd = fopen (path, mode == 0 ? "a" : mode == 1 ? "r+" : "w");
if (pd == NULL)
{
g_warning ("%s: Error opening FILE '%s' for script stats: %d - %s", __func__,
path, errno, strerror (errno));
g_warning ("%s: Error opening FILE '%s' for script stats: %d - %s",
__func__, path, errno, strerror (errno));
return;
}

Expand Down

0 comments on commit 27ab641

Please sign in to comment.