Skip to content

Commit

Permalink
add C ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lquenti committed Jan 21, 2024
1 parent 9480197 commit 8e3d1f6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/c.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Everything C
on:
push:
branches: [ master ]
paths:
- 'src/c_code/**'
pull_request:
branches: [ master ]
paths:
- 'src/c_code/**'
jobs:
static_analysis:
name: Run gcc with warnings
steps:
- uses: actions/checkout@v3
- name: Install Dependencies
run: sudo apt-get install gcc cppcheck
- name: Compile Library with Warnings
run: gcc -Wall -Wextra -Wpedantic -std=c11 -c -o /dev/null ./src/c_code/benchmarker.c
- name: Run cppcheck
run: cppcheck --enable=all --error-exitcode=1 ./src/c_code/benchmarker.c
5 changes: 5 additions & 0 deletions blackheap-benchmarker/src/c_code/benchmarker.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
#include "benchmarker.h"

void should_fail_ci() {
int x; // Variable x is declared but not used.
int y = 10 / 0; // Division by zero, which is undefined behavior.
}

struct tuple tuple_add(const struct tuple *a, const struct tuple *b) {
struct tuple result = { a->a + b->a, a->b + b->b };
return result;
Expand Down

0 comments on commit 8e3d1f6

Please sign in to comment.