Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ydb/core/base/logoblob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ TString TLogoBlobID::ToString() const {

void TLogoBlobID::Out(IOutputStream &o) const {
char buf[240];
sprintf(buf,
snprintf(buf, sizeof(buf),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest you to rewrite it like this:
o << '[' << TabletID() << ':' << Generation() << ':' ....

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

считаю, что это другая задача, которую нужно делать в другом PR

"[%" PRIu64 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 ":%" PRIu32 "]",
TabletID(),
Generation(),
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/base/traceid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ TString TTraceID::ToString() const {

void TTraceID::Out(IOutputStream &o) const {
char buf[240];
sprintf(buf, "[ID:%" PRIu64 ", Created: %s]", RandomID, TInstant::MicroSeconds(CreationTime).ToRfc822StringLocal().data());
snprintf(buf, sizeof(buf), "[ID:%" PRIu64 ", Created: %s]", RandomID, TInstant::MicroSeconds(CreationTime).ToRfc822StringLocal().data());
o << buf;
}

Expand Down
10 changes: 5 additions & 5 deletions ydb/library/workload/stock_workload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ TQueryInfo TStockWorkloadGenerator::FillStockData() const {
INSERT INTO `stock`(product, quantity) SELECT product, quantity from AS_TABLE( $stocks );
)";

char productName[8] = "";
NYdb::TValueBuilder rows;
rows.BeginList();
for (size_t i = 0; i < Params.ProductCount; ++i) {
std::sprintf(productName, "p%.6zu", i);
char productName[8] = "";
std::snprintf(productName, sizeof(productName), "p%.6zu", i);
rows.AddListItem()
.BeginStruct()
.AddMember("product").Utf8(productName)
Expand Down Expand Up @@ -238,10 +238,10 @@ unsigned int TStockWorkloadGenerator::GetProductCountInOrder() {
}

TStockWorkloadGenerator::TProductsQuantity TStockWorkloadGenerator::GenerateOrder(unsigned int productCountInOrder, int quantity) {
char productName[8] = "";
TProductsQuantity products;
for (unsigned i = 0; i < productCountInOrder; ++i) {
std::sprintf(productName, "p%.6i", ProductIdGenerator(Gen));
char productName[8] = "";
std::snprintf(productName, sizeof(productName), "p%.6i", ProductIdGenerator(Gen));
products.emplace(productName, quantity);
}
return products;
Expand Down Expand Up @@ -277,7 +277,7 @@ TQueryInfoList TStockWorkloadGenerator::SubmitSameOrder() {
char productName[8] = "";
TProductsQuantity products;
for (unsigned i = 0; i < Params.ProductCount; ++i) {
std::sprintf(productName, "p%.6i", i);
std::snprintf(productName, sizeof(productName), "p%.6i", i);
products.emplace(productName, 1);
}
res.push_back(InsertOrder(orderID, customer, products));
Expand Down
2 changes: 1 addition & 1 deletion ydb/library/yql/ast/yql_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2724,7 +2724,7 @@ TAstParseResult ConvertToAst(const TExprNode& root, TExprContext& exprContext, c
YQL_ENSURE(frame.Bindings.emplace(node.second, buffer).second);
} else {
char buffer[1 + 10 + 1];
sprintf(buffer, "$%" PRIu32, ++uniqueNum);
snprintf(buffer, sizeof(buffer), "$%" PRIu32, ++uniqueNum);
YQL_ENSURE(frame.Bindings.emplace(node.second, buffer).second);
}
frame.TopoSortedNodes.emplace_back(node.second);
Expand Down
2 changes: 1 addition & 1 deletion ydb/public/lib/ydb_cli/commands/click_bench.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ int TClickBenchCommandClean::Run(TConfig& config) {
static const char DropDdlTmpl[] = "DROP TABLE `%s`;";
char dropDdl[sizeof(DropDdlTmpl) + 8192*3]; // 32*256 for DbPath
TString fullPath = FullTablePath(config.Database, Table);
int res = std::sprintf(dropDdl, DropDdlTmpl, fullPath.c_str());
int res = std::snprintf(dropDdl, sizeof(dropDdl), DropDdlTmpl, fullPath.c_str());
if (res < 0) {
Cerr << "Failed to generate DROP DDL query for `" << fullPath << "` table." << Endl;
return -1;
Expand Down
2 changes: 1 addition & 1 deletion ydb/public/lib/ydb_cli/commands/tpch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ int TTpchCommandClean::Run(TConfig& config) {
char dropDdl[sizeof(DropDdlTmpl) + 8192*3]; // 32*256 for DbPath
for (auto& table : Tables) {
TString fullPath = FullTablePath(config.Database, table);
int res = std::sprintf(dropDdl, DropDdlTmpl, fullPath.c_str());
int res = std::snprintf(dropDdl, sizeof(dropDdl), DropDdlTmpl, fullPath.c_str());
if (res < 0) {
Cerr << "Failed to generate DROP DDL query for `" << fullPath << "` table." << Endl;
return -1;
Expand Down