chore(tfhe): remove dbg! macro calls and add a Makefile check for it

This commit is contained in:
Arthur Meyre
2023-07-13 14:08:05 +02:00
parent f982c58538
commit 228f85d843
4 changed files with 27 additions and 5 deletions

View File

@@ -405,6 +405,10 @@ ci_test_web_js_api_parallel: build_web_js_api_parallel
no_tfhe_typo:
@./scripts/no_tfhe_typo.sh
.PHONY: no_dbg_log # Check we did not leave dbg macro calls in the rust code
no_dbg_log:
@./scripts/no_dbg_calls.sh
#
# Benchmarks
#
@@ -509,10 +513,10 @@ sha256_bool: install_rs_check_toolchain
--features=$(TARGET_ARCH_FEATURE),boolean
.PHONY: pcc # pcc stands for pre commit checks
pcc: no_tfhe_typo check_fmt doc clippy_all check_compile_tests
pcc: no_tfhe_typo no_dbg_log check_fmt doc clippy_all check_compile_tests
.PHONY: fpcc # pcc stands for pre commit checks, the f stands for fast
fpcc: no_tfhe_typo check_fmt doc clippy_fast check_compile_tests
fpcc: no_tfhe_typo no_dbg_log check_fmt doc clippy_fast check_compile_tests
.PHONY: conformance # Automatically fix problems that can be fixed
conformance: fmt

20
scripts/no_dbg_calls.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e
THIS_SCRIPT_NAME="$(basename "$0")"
TMP_FILE="$(mktemp)"
COUNT="$(git grep -rniI "dbg!" . | grep -v "${THIS_SCRIPT_NAME}" | \
tee "${TMP_FILE}" | wc -l | tr -d '[:space:]')"
cat "${TMP_FILE}"
rm -rf "${TMP_FILE}"
if [[ "${COUNT}" == "0" ]]; then
exit 0
else
echo "dbg macro calls detected, see output log above"
exit 1
fi

View File

@@ -601,8 +601,6 @@ impl ServerKey {
let shift_within_block = n % num_bits_in_message;
let num_blocks = ct.blocks.len();
dbg!(rotations);
// rotate right as the blocks are from LSB to MSB
ct.blocks.rotate_right(rotations);

View File

@@ -160,7 +160,7 @@ impl U256 {
pub fn leading_zeros(self) -> u32 {
// iter from msb to lsb
for (i, word) in self.0.iter().copied().rev().enumerate() {
let leading_zeros = dbg!(word.leading_zeros());
let leading_zeros = word.leading_zeros();
if leading_zeros != u64::BITS {
return (i as u32 * u64::BITS) + leading_zeros;
}