Skip to content

refactor(tutorial): replace snprintf with std::copy_n in providers - #1277

Merged
castler merged 2 commits into
eclipse-score:mainfrom
castler:refactor_tutorial_snprintf
Oct 5, 2026
Merged

castler merged 2 commits into
eclipse-score:mainfrom
castler:refactor_tutorial_snprintf

Conversation

@castler

@castler castler commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Replaces std::snprintf + memcpy + pointer arithmetic in the tutorial providers (chapters 1, 2, 6, 10, 12) with a std::string payload copied via std::copy_n (truncated to capacity, null-terminated).

  • Simpler tutorial code; no printf-style error handling needed.
  • Removes cppcoreguidelines-pro-type-vararg and pro-bounds-pointer-arithmetic findings for these files (clang-tidy clean on the touched files).
  • Behavior is unchanged: payload is "Hello World" + counter.

Chapters 3-5 already build a std::string and use memcpy; not touched.

Build the payload as a std::string and copy it into the sample array with
std::copy_n, truncating to the array capacity and null-terminating. This
removes the snprintf/memcpy calls and the pointer arithmetic, and with them
the cppcoreguidelines-pro-type-vararg and pro-bounds-pointer-arithmetic
clang-tidy findings, while simplifying the tutorial code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
crimson11
crimson11 previously approved these changes Oct 5, 2026
@castler
castler marked this pull request as ready for review October 5, 2026 12:42
@castler
castler enabled auto-merge October 5, 2026 12:42
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@castler
castler added this pull request to the merge queue Oct 5, 2026
Merged via the queue into eclipse-score:main with commit 769ed86 Oct 5, 2026
19 checks passed
@castler
castler deleted the refactor_tutorial_snprintf branch October 5, 2026 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants