Repository navigation
Conversation
tmleman
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1,
plbossart and
singalsu
as code owners
December 4, 2026 15:19
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The documentation omits the gcd restriction on INT_MIN when both arguments are nonzero and the length limit required to keep output indices representable in int16_t.
2 open issues
What changed in this PR
Improves the math helpers’ const-correctness and API documentation, addressing #11590 without changing runtime logic.
Changes:
- Makes the three vector-search inputs
const. - Adds Doxygen documentation for six math helpers, including boundary conditions and CRC continuation.
- Updates vector-search tests to use constant input arrays.
| File | Description |
|---|---|
| test/ztest/unit/math/basic/arithmetic/test_find_min_int16_ztest.c | Uses constant minimum-search inputs. |
| test/ztest/unit/math/basic/arithmetic/test_find_max_abs_int32_ztest.c | Uses constant absolute-maximum inputs. |
| test/ztest/unit/math/basic/arithmetic/test_find_equal_int16_ztest.c | Uses constant equality-search inputs. |
| src/math/numbers.c | Updates signatures and points comments to the header. |
| src/include/sof/math/numbers.h | Adds const-qualified declarations and Doxygen contracts. |
Review effort: Balanced
Comment on lines
+58
to
+59
| * gcd(0, 0) returns 0. Otherwise the signs of the arguments are ignored and | ||
| * the result is positive. |
| * if max_results is zero or negative | ||
| * \param[in] vec vector to search from | ||
| * \param[in] n value to search for | ||
| * \param[in] vec_length number of values in vec |
PR 11619: test resultsRun date: 2026-12-04 15:49 UTC Tested commit: 82f109318065760f66c4f0bd5679f7dcdbfa0b40 |
find_equal_int16(), find_min_int16() and find_max_abs_int32() only read their input vector. Declare it const, so callers with constant data do not have to cast the qualifier away. Existing callers are not affected, the functions are currently only called from the unit tests. Document gcd(), find_equal_int16(), find_min_int16(), find_max_abs_int32(), norm_int32() and crc32() with Doxygen comments in numbers.h, including what was not described before: the size idx[] needs and the meaning of a zero or negative max_results in find_equal_int16(), the minimum vector length of the find functions, the result of norm_int32() for -1 and the use of the base argument of crc32(). The comments in numbers.c now refer to the header. The comment of find_max_abs_int32() said that the smallest negative value is saturated. That is not what the code does: the negation of INT32_MIN is done in 32 bits and overflows. Document the value as not supported instead of changing the function here. Make the input vectors of the find_*() unit tests const, to build the tests against the new prototypes. No functional change. Closes thesofproject#11590 Assisted-by: Copilot:claude-fable-5.2 Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

find_equal_int16(), find_min_int16() and find_max_abs_int32() only read their input vector. Declare it const, so callers with constant data do not have to cast the qualifier away. Existing callers are not affected, the functions are currently only called from the unit tests.
Document gcd(), find_equal_int16(), find_min_int16(), find_max_abs_int32(), norm_int32() and crc32() with Doxygen comments in numbers.h, including what was not described before: the size idx[] needs and the meaning of a zero or negative max_results in find_equal_int16(), the minimum vector length of the find functions, the result of norm_int32() for -1 and the use of the base argument of crc32(). The comments in numbers.c now refer to the header.
The comment of find_max_abs_int32() said that the smallest negative value is saturated. That is not what the code does: the negation of INT32_MIN is done in 32 bits and overflows. Document the value as not supported instead of changing the function here.
Make the input vectors of the find_*() unit tests const, to build the tests against the new prototypes.
No functional change.
Closes #11590
Assisted-by: Copilot:claude-fable-5.2