Skip to content

Commit 56bd3fc

Browse files
mizdebskmkoncek
authored andcommitted
Avoid narrowing conversion by using operator<< for string output
Replace calls to write() with operator<< when writing std::string to streams. std::string::size() returns an unsigned value (size_t), while std::ostream::write() expects a signed std::streamsize, which introduces a narrowing conversion. Using operator<< is simpler, idiomatic, and avoids this type mismatch. It also improves readability without changing behavior.
1 parent 002c039 commit 56bd3fc

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/java_symbols.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ try
632632
osyncstream << path.native() << ":\n";
633633
}
634634

635-
osyncstream.write(content.c_str(), content.size());
635+
osyncstream << content;
636636
}
637637
else if (content.size() < original_content.size())
638638
{
@@ -644,7 +644,7 @@ try
644644
}
645645

646646
ofs.exceptions(std::ios_base::badbit | std::ios_base::failbit);
647-
ofs.write(content.c_str(), content.size());
647+
ofs << content;
648648
std::osyncstream(std::clog) << "Removing symbols from file " << path.native() << "\n";
649649

650650
if (strict_mode)

0 commit comments

Comments
 (0)