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

Fix C formatting again. #1821

Merged
merged 4 commits into from
Jan 27, 2025
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
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
Loading