Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2125: Fix sprintf warnings #2208

Merged
merged 2 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/vt/group/collective/group_info_collective.cc
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,12 @@ void InfoColl::finalize() {
if (in_phase_two_ && send_down_finished_ == send_down_) {

if (!vt_check_enabled(production_build)) {
char buf[256];
constexpr int max_buffer_length = 256;
char buf[max_buffer_length];
buf[0] = '\0';
int cur = 0;
for (auto&& elm : collective_->span_children_) {
cur += sprintf(buf + cur, "%d,", elm);
cur += snprintf(buf + cur, max_buffer_length - cur, "%d,", elm);
}

auto const& num_children = collective_->span_children_.size();
Expand Down
5 changes: 3 additions & 2 deletions src/vt/runtime/runtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,10 @@ bool Runtime::hasSchedRun() const {

void Runtime::pauseForDebugger() {
if (theConfig()->vt_pause) {
char node_str[256];
constexpr int max_buffer_length = 256;
char node_str[max_buffer_length];
auto node = vt::theContext() ? vt::theContext()->getNode() : -1;
sprintf(node_str, "prog-%d.pid", node);
snprintf(node_str, max_buffer_length, "prog-%d.pid", node);
auto const pid = getpid();
FILE* f = fopen(node_str, "w+");
fprintf(f, "%d", pid);
Expand Down
Loading