Skip to content

Commit

Permalink
Merge pull request #2208 from DARMA-tasking/2125-remove-sprintf-warnings
Browse files Browse the repository at this point in the history
#2125: Fix sprintf warnings
  • Loading branch information
nlslatt authored Nov 7, 2023
2 parents 09f8bab + 51da09c commit dca2a02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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

0 comments on commit dca2a02

Please sign in to comment.