Run static analysis in CI (#129)
* Run static analysis in CI * Remove analysis-report in make clean * Add remark * Remove the memory helper functions * Revert "Remove the memory helper functions" This reverts commit 364234aea02cca38ed40a5bce1bbc8f8eb02aee2. * Remove swap file
This commit is contained in:
parent
fcea0faff6
commit
44fe79fd42
|
@ -23,6 +23,10 @@ jobs:
|
|||
run: |
|
||||
cd src
|
||||
make test
|
||||
- name: Clang Static Analyzer
|
||||
run: |
|
||||
cd src
|
||||
make analyze
|
||||
- name: Install LLVM
|
||||
uses: egor-tensin/setup-clang@v1
|
||||
- name: Generate coverage report
|
||||
|
|
|
@ -91,10 +91,17 @@ profile: \
|
|||
profile_compute_kzg_proof \
|
||||
profile_compute_aggregate_kzg_proof
|
||||
|
||||
.PHONY: analyze
|
||||
analyze: c_kzg_4844.c
|
||||
@$(CC) --analyze -Xanalyzer -analyzer-output=html \
|
||||
-o analysis-report $(CFLAGS) -c $<
|
||||
@[ -d analysis-report ] && exit 1 || exit 0
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@rm -f *.o *.profraw *.profdata *.html xray-log.* *.prof *.pdf \
|
||||
test_c_kzg_4844 test_c_kzg_4844_cov test_c_kzg_4844_prof
|
||||
@rm -rf analysis-report
|
||||
|
||||
.PHONY: format
|
||||
format:
|
||||
|
|
|
@ -145,16 +145,15 @@ static const fr_t FR_ONE = {
|
|||
/**
|
||||
* Wrapped `malloc()` that reports failures to allocate.
|
||||
*
|
||||
* @remark Will return C_KZG_BADARGS if the requested size is zero.
|
||||
*
|
||||
* @param[out] x Pointer to the allocated space
|
||||
* @param[in] n The number of bytes to be allocated
|
||||
*/
|
||||
static C_KZG_RET c_kzg_malloc(void **x, size_t n) {
|
||||
if (n > 0) {
|
||||
if (n == 0) return C_KZG_BADARGS;
|
||||
*x = malloc(n);
|
||||
return *x != NULL ? C_KZG_OK : C_KZG_MALLOC;
|
||||
}
|
||||
*x = NULL;
|
||||
return C_KZG_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -564,6 +563,7 @@ static C_KZG_RET bit_reversal_permutation(
|
|||
) {
|
||||
CHECK(n >> 32 == 0);
|
||||
CHECK(is_power_of_two(n));
|
||||
CHECK(log2_pow2(n) != 0);
|
||||
|
||||
// Pointer arithmetic on `void *` is naughty, so cast to something
|
||||
// definite
|
||||
|
@ -1601,6 +1601,8 @@ C_KZG_RET load_trusted_setup(
|
|||
out->g1_values = NULL;
|
||||
out->g2_values = NULL;
|
||||
|
||||
CHECK(n1 > 0);
|
||||
CHECK(n2 > 0);
|
||||
ret = new_g1_array(&out->g1_values, n1);
|
||||
if (ret != C_KZG_OK) goto out_error;
|
||||
ret = new_g2_array(&out->g2_values, n2);
|
||||
|
|
Loading…
Reference in New Issue