Skip to content

ut-fix - #476

Open
DetiPrudvi08 wants to merge 6 commits into
masterfrom
ut-fix
Open

ut-fix#476
DetiPrudvi08 wants to merge 6 commits into
masterfrom
ut-fix

Conversation

@DetiPrudvi08

Copy link
Copy Markdown
Contributor

No description provided.

Signed-off-by: prudvi <prudvi.deti@intel.com>
Signed-off-by: prudvi <prudvi.deti@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Hyperscan unit tests to use the public database-free API and adjusts a reverse-acceleration bounds check to avoid problematic integer conversions.

Changes:

  • Replace internal database unprotect/free sequences in unit tests with hs_free_database() and explicit nullptr reset where needed.
  • Introduce makeDatabaseWritable() in arg_checks.cpp and use it before intentional database corruption in tests.
  • Add a cast in nfa_rev_api.h to make the length vs rAccelOffset check operate in size_t.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
unit/hyperscan/single.cpp Switches test teardown to hs_free_database() and nulls the member pointer after free.
unit/hyperscan/arg_checks.cpp Adds helper for making databases writable and updates multiple tests to use hs_free_database().
src/nfa/nfa_rev_api.h Casts rAccelOffset to size_t in RDEOD checks to keep comparisons in the correct domain.
Comments suppressed due to low confidence (3)

unit/hyperscan/arg_checks.cpp:72

  • makeDatabaseWritable() now depends on sysconf/mprotect and page-alignment assumptions, duplicating logic already provided by hs_db_unprotect(). Using hs_db_unprotect() here avoids platform-specific APIs and keeps behavior consistent with the library’s own protection mechanism.
    long ps_raw = sysconf(_SC_PAGESIZE);
    if (ps_raw <= 0) {
        return;
    }
    size_t ps = (size_t)ps_raw;

unit/hyperscan/arg_checks.cpp:1162

  • db_len2 is now unused after switching teardown from hs_db_free(db, db_len2) to hs_free_database(db). Removing it avoids unused-variable warnings (notably MSVC C4189).
    // teardown
    err = hs_free_scratch(scratch);
    ASSERT_EQ(HS_SUCCESS, err);
    hs_free_database(db);

unit/hyperscan/arg_checks.cpp:1439

  • db_len3 is now unused after switching teardown from hs_db_free(db, db_len3) to hs_free_database(db). Removing it avoids unused-variable warnings (notably MSVC C4189).
    ASSERT_EQ(HS_INVALID, err);

    // teardown
    hs_free_database(db);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread unit/hyperscan/arg_checks.cpp
Comment thread unit/hyperscan/arg_checks.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants