From 701cf404710065cb615bb01eb5b9aa18b077ed68 Mon Sep 17 00:00:00 2001 From: ddidderr Date: Wed, 22 Jul 2026 00:59:17 +0200 Subject: [PATCH] feat(compress): route parameter bounds checks through Rust Parameter-bound lookup already lived in Rust, but the internal C helper still performed the error and interval comparison locally. Call the existing Rust bounds predicate directly so the compression parameter policy has one owner while preserving the C helper and its callers. Test Plan: - ulimit -v 41943040; make -j1 - ulimit -v 41943040; make -j1 -C tests test - Previous capped cargo check and clippy passed for the unchanged Rust API. --- lib/compress/zstd_compress_internal.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/compress/zstd_compress_internal.h b/lib/compress/zstd_compress_internal.h index 2cc6c2480..4626aebe4 100644 --- a/lib/compress/zstd_compress_internal.h +++ b/lib/compress/zstd_compress_internal.h @@ -622,13 +622,10 @@ MEM_STATIC U32 ZSTD_MLcode(U32 mlBase) /* ZSTD_cParam_withinBounds: * @return 1 if value is within cParam bounds, * 0 otherwise */ +int ZSTD_rust_cctx_params_within_bounds(int param, int value); MEM_STATIC int ZSTD_cParam_withinBounds(ZSTD_cParameter cParam, int value) { - ZSTD_bounds const bounds = ZSTD_cParam_getBounds(cParam); - if (ZSTD_isError(bounds.error)) return 0; - if (value < bounds.lowerBound) return 0; - if (value > bounds.upperBound) return 0; - return 1; + return ZSTD_rust_cctx_params_within_bounds((int)cParam, value); } /* ZSTD_selectAddr: