Skip to content

Commit

Permalink
sprintf -> snprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Oct 21, 2024
1 parent 1986ccf commit 3b4baf7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/TiledArray/util/bug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void Debugger::set_prefix(const char *p) {

void Debugger::set_prefix(int i) {
char p[128];
sprintf(p, "%3d: ", i);
snprintf(p, sizeof(p), "%3d: ", i);
set_prefix(p);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/dist_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace {
std::string to_parallel_archive_file_name(const char* prefix_name, int rank) {
char buf[256];
MADNESS_ASSERT(strlen(prefix_name) + 7 <= sizeof(buf));
sprintf(buf, "%s.%5.5d", prefix_name, rank);
snprintf(buf, sizeof(buf), "%s.%5.5d", prefix_name, rank);
return buf;
}
} // namespace
Expand Down Expand Up @@ -716,7 +716,7 @@ BOOST_AUTO_TEST_CASE(parallel_serialization) {
mktemp(archive_file_prefix_name);
madness::archive::ParallelOutputArchive<> oar(world, archive_file_prefix_name,
nio);
oar& a;
oar & a;
oar.close();

madness::archive::ParallelInputArchive<> iar(world, archive_file_prefix_name,
Expand All @@ -740,7 +740,7 @@ BOOST_AUTO_TEST_CASE(parallel_sparse_serialization) {
mktemp(archive_file_prefix_name);
madness::archive::ParallelOutputArchive<> oar(world, archive_file_prefix_name,
nio);
oar& b;
oar & b;
oar.close();

madness::archive::ParallelInputArchive<> iar(world, archive_file_prefix_name,
Expand Down Expand Up @@ -783,7 +783,7 @@ BOOST_AUTO_TEST_CASE(issue_225) {
madness::archive::BinaryFstreamInputArchive iar(archive_file_name);
decltype(S) S_read;
decltype(St) St_read;
iar& S_read& St_read;
iar & S_read & St_read;

BOOST_CHECK_EQUAL(S_read.trange(), S.trange());
BOOST_REQUIRE(S_read.shape() == S.shape());
Expand Down

0 comments on commit 3b4baf7

Please sign in to comment.