Skip to content

Use std::array/std::vector in inspect_file and apply CTAD for std::atomic in multithread example#101

Merged
Easton97-Jens merged 1 commit into
v3/master_pr3489from
codex/refactor-inspectfile-operator-for-security-hardening
Apr 24, 2026
Merged

Use std::array/std::vector in inspect_file and apply CTAD for std::atomic in multithread example#101
Easton97-Jens merged 1 commit into
v3/master_pr3489from
codex/refactor-inspectfile-operator-for-security-hardening

Conversation

@Easton97-Jens

Copy link
Copy Markdown
Owner

Motivation

  • Modernize and harden subprocess and buffer handling in the InspectFile operator by replacing raw C arrays and const_cast usage with safer C++ containers and APIs.
  • Simplify the example by using class template argument deduction for std::atomic in multithread to reduce verbosity and silences potential warnings.

Description

  • Replaced int pipefd[2] with std::array<int, 2> and use pipefd.data() for pipe() to avoid C-style arrays in InspectFile.
  • Replaced raw char *argv[] and const_cast usage with std::vector<std::string> and a std::vector<char*> for posix_spawn arguments to keep argument storage alive and eliminate unsafe casts.
  • Replaced char buff[512] with std::array<char, 512> and updated the read loop to use buff.data()/buff.size() and an explicit loop-control flag for clearer EINTR handling.
  • Replaced std::atomic<int> completed_threads{0}; with class template argument deduction std::atomic completed_threads{0}; in examples/multithread.

Testing

  • Performed a full project build (cmake/make) which completed successfully.
  • Ran the test suite (ctest) and the tests passed without regressions.
  • Executed the examples/multithread smoke test which started, completed threads, and reported elapsed time successfully.

Codex Task

@Easton97-Jens Easton97-Jens merged commit 19d7155 into v3/master_pr3489 Apr 24, 2026
186 of 192 checks passed
@Easton97-Jens Easton97-Jens deleted the codex/refactor-inspectfile-operator-for-security-hardening branch April 24, 2026 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant