Skip to content

Commit 47c77bc

Browse files
authored
Merge pull request ceph#52734 from vedanshbhartia/coverity_ostream
rgw: Restore ostream format state after changing it reviwed-by: yuvalif
2 parents 7b774c4 + 366c684 commit 47c77bc

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

src/rgw/rgw_asio_frontend.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,15 @@ struct log_ms_remainder {
167167
};
168168
std::ostream& operator<<(std::ostream& out, const log_ms_remainder& m) {
169169
using namespace std::chrono;
170-
return out << std::setfill('0') << std::setw(3)
170+
171+
std::ios oldState(nullptr);
172+
oldState.copyfmt(out);
173+
174+
out << std::setfill('0') << std::setw(3)
171175
<< duration_cast<milliseconds>(m.t.time_since_epoch()).count() % 1000;
176+
177+
out.copyfmt(oldState);
178+
return out;
172179
}
173180

174181
// log time in apache format: day/month/year:hour:minute:second zone

src/rgw/rgw_common.cc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,16 @@ req_state::~req_state() {
286286

287287
std::ostream& req_state::gen_prefix(std::ostream& out) const
288288
{
289-
auto p = out.precision();
290-
return out << "req " << id << ' '
289+
std::ios oldState(nullptr);
290+
oldState.copyfmt(out);
291+
292+
out << "req " << id << ' '
291293
<< std::setprecision(3) << std::fixed << time_elapsed() // '0.123s'
292-
<< std::setprecision(p) << std::defaultfloat << ' ';
294+
<< ' ';
295+
296+
out.copyfmt(oldState);
297+
return out;
298+
293299
}
294300

295301
bool search_err(rgw_http_errors& errs, int err_no, int& http_ret, string& code)

src/rgw/rgw_public_access.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ void PublicAccessBlockConfiguration::dump_xml(Formatter *f) const {
2222

2323
std::ostream& operator<< (std::ostream& os, const PublicAccessBlockConfiguration& access_conf)
2424
{
25+
std::ios oldState(nullptr);
26+
oldState.copyfmt(os);
27+
2528
os << std::boolalpha
2629
<< "BlockPublicAcls: " << access_conf.block_public_acls() << std::endl
2730
<< "IgnorePublicAcls: " << access_conf.ignore_public_acls() << std::endl
2831
<< "BlockPublicPolicy" << access_conf.block_public_policy() << std::endl
2932
<< "RestrictPublicBuckets" << access_conf.restrict_public_buckets() << std::endl;
3033

34+
os.copyfmt(oldState);
3135
return os;
3236
}
3337

0 commit comments

Comments
 (0)