Skip to content

Commit

Permalink
code refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
anandamideShakyan committed Dec 17, 2024
1 parent 24335f4 commit 557f739
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions velox/common/process/TraceContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ TraceContext::TraceContext(std::string label, bool isTemporary)
entry.line = __LINE__;
int result = snprintf(entry.label, entry.kLabelCapacity, "%s", label_.c_str());

if (result < 0) {
throw std::runtime_error("Encoding error in snprintf");
if (FOLLY_UNLIKELY(result < 0)) {
entry.label[0] = '\0';
}

if (result >= entry.kLabelCapacity) {
std::cerr << "Warning: label truncated in snprintf" << std::endl;
entry.label[entry.kLabelCapacity - 1] = '\0';
}
});
traceData_->withValue([&](auto& counts) {
Expand Down

0 comments on commit 557f739

Please sign in to comment.