Skip to content

Avoid memcmp() in tests and new equality checks#318

Open
attipaci wants to merge 10 commits intomainfrom
no-memcmp-tests
Open

Avoid memcmp() in tests and new equality checks#318
attipaci wants to merge 10 commits intomainfrom
no-memcmp-tests

Conversation

@attipaci
Copy link
Copy Markdown
Collaborator

@attipaci attipaci commented May 8, 2026

Using memcmp() to compare structures can be problematic, because of the padding between fields. The initializer is not guaranteed to set the padded areas to 0 (even if it usually does). When it does not, two structures may have identical fields bit-for-bit, but 1memcmp()1 will report them as differing because of the different uninitialized padding.

To resolve:

  • Add novas_equals_[...]() functions to the C99 API, and use these to perform comparisons between structures with typical 'sane' tolerances.
  • Add complete testing of the new struct comparison methods.
  • Add equals(), operator==() and operator!=() methods to more C++ classes, using the new C99 comparisons.
  • Add tests for new C++ methods.

@attipaci attipaci added this to the 1.7.0 milestone May 8, 2026
@attipaci attipaci self-assigned this May 8, 2026
@attipaci attipaci added the enhancement New feature or request label May 8, 2026
@attipaci attipaci linked an issue May 8, 2026 that may be closed by this pull request
@attipaci attipaci force-pushed the no-memcmp-tests branch from 8a83e58 to 8a26e6f Compare May 8, 2026 07:20
@coveralls
Copy link
Copy Markdown

coveralls commented May 8, 2026

Coverage Report for CI Build 25597637302

Coverage increased (+0.02%) to 99.13%

Details

  • Coverage increased (+0.02%) from the base build.
  • Patch coverage: 204 of 204 lines across 7 files are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 9198
Covered Lines: 9118
Line Coverage: 99.13%
Coverage Strength: 40704.52 hits per line

💛 - Coveralls

@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@attipaci attipaci force-pushed the no-memcmp-tests branch 6 times, most recently from 9922a49 to 752e638 Compare May 8, 2026 13:00
@attipaci attipaci force-pushed the no-memcmp-tests branch from bd9c3a3 to f9037bb Compare May 8, 2026 18:25
@attipaci attipaci changed the title Avoid memcmp() in tests Avoid memcmp() in tests and new C++ comparison methods. May 8, 2026
@attipaci attipaci force-pushed the no-memcmp-tests branch 2 times, most recently from 8d0ef38 to 8045ce9 Compare May 8, 2026 19:32
@attipaci attipaci force-pushed the no-memcmp-tests branch from 8045ce9 to 5f86712 Compare May 8, 2026 19:34
@attipaci attipaci marked this pull request as ready for review May 8, 2026 19:34
@attipaci attipaci force-pushed the no-memcmp-tests branch 2 times, most recently from 430f3d0 to 60036c8 Compare May 9, 2026 07:26
@attipaci attipaci force-pushed the no-memcmp-tests branch 3 times, most recently from f9e941f to 9d4b436 Compare May 9, 2026 09:23
@attipaci attipaci force-pushed the no-memcmp-tests branch from 9d4b436 to 521fd57 Compare May 9, 2026 09:25
@attipaci attipaci changed the title Avoid memcmp() in tests and new C++ comparison methods. Avoid memcmp() in tests and new equality checks May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't use memcmp() to check for identical structures in tests

2 participants