Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6cda3d3

Browse filesBrowse files
addaleaxaduh95
authored andcommitted
src: remove unnecessary c_str() conversions in diagnostic messages
PR-URL: #61786 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 1c2064c commit 6cda3d3
Copy full SHA for 6cda3d3

11 files changed

+55-63Lines changed: 55 additions & 63 deletions
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/blob_serializer_deserializer-inl.h‎

Copy file name to clipboardExpand all lines: src/blob_serializer_deserializer-inl.h
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ template <typename T>
105105
std::vector<T> BlobDeserializer<Impl>::ReadVector() {
106106
if (is_debug) {
107107
std::string name = GetName<T>();
108-
Debug("\nReadVector<%s>()(%d-byte)\n", name.c_str(), sizeof(T));
108+
Debug("\nReadVector<%s>()(%d-byte)\n", name, sizeof(T));
109109
}
110110
size_t count = static_cast<size_t>(ReadArithmetic<size_t>());
111111
if (count == 0) {
@@ -123,7 +123,7 @@ std::vector<T> BlobDeserializer<Impl>::ReadVector() {
123123
if (is_debug) {
124124
std::string str = std::is_arithmetic_v<T> ? "" : ToStr(result);
125125
std::string name = GetName<T>();
126-
Debug("ReadVector<%s>() read %s\n", name.c_str(), str.c_str());
126+
Debug("ReadVector<%s>() read %s\n", name, str);
127127
}
128128
return result;
129129
}
@@ -163,7 +163,7 @@ void BlobDeserializer<Impl>::ReadArithmetic(T* out, size_t count) {
163163
DCHECK_GT(count, 0); // Should not read contents for vectors of size 0.
164164
if (is_debug) {
165165
std::string name = GetName<T>();
166-
Debug("Read<%s>()(%d-byte), count=%d: ", name.c_str(), sizeof(T), count);
166+
Debug("Read<%s>()(%d-byte), count=%d: ", name, sizeof(T), count);
167167
}
168168

169169
size_t size = sizeof(T) * count;
@@ -172,7 +172,7 @@ void BlobDeserializer<Impl>::ReadArithmetic(T* out, size_t count) {
172172
if (is_debug) {
173173
std::string str =
174174
"{ " + std::to_string(out[0]) + (count > 1 ? ", ... }" : " }");
175-
Debug("%s, read %zu bytes\n", str.c_str(), size);
175+
Debug("%s, read %zu bytes\n", str, size);
176176
}
177177
read_total += size;
178178
}
@@ -240,10 +240,10 @@ size_t BlobSerializer<Impl>::WriteVector(const std::vector<T>& data) {
240240
std::string name = GetName<T>();
241241
Debug("\nAt 0x%x: WriteVector<%s>() (%d-byte), count=%d: %s\n",
242242
sink.size(),
243-
name.c_str(),
243+
name,
244244
sizeof(T),
245245
data.size(),
246-
str.c_str());
246+
str);
247247
}
248248

249249
size_t written_total = WriteArithmetic<size_t>(data.size());
@@ -259,7 +259,7 @@ size_t BlobSerializer<Impl>::WriteVector(const std::vector<T>& data) {
259259

260260
if (is_debug) {
261261
std::string name = GetName<T>();
262-
Debug("WriteVector<%s>() wrote %d bytes\n", name.c_str(), written_total);
262+
Debug("WriteVector<%s>() wrote %d bytes\n", name, written_total);
263263
}
264264

265265
return written_total;
@@ -319,10 +319,10 @@ size_t BlobSerializer<Impl>::WriteArithmetic(const T* data, size_t count) {
319319
std::string name = GetName<T>();
320320
Debug("At 0x%x: Write<%s>() (%zu-byte), count=%zu: %s",
321321
sink.size(),
322-
name.c_str(),
322+
name,
323323
sizeof(T),
324324
count,
325-
str.c_str());
325+
str);
326326
}
327327

328328
size_t size = sizeof(T) * count;
Collapse file

‎src/compile_cache.cc‎

Copy file name to clipboardExpand all lines: src/compile_cache.cc
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ CompileCacheEntry* CompileCacheHandler::GetOrInsert(Local<String> code,
265265
if (!relative_path.empty()) {
266266
file_path = relative_path;
267267
Debug("[compile cache] using relative path %s from %s\n",
268-
file_path.c_str(),
269-
compile_cache_dir_.c_str());
268+
file_path,
269+
compile_cache_dir_);
270270
}
271271
}
272272
uint32_t key = GetCacheKey(file_path, type);
Collapse file

‎src/env.cc‎

Copy file name to clipboardExpand all lines: src/env.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ size_t Environment::NearHeapLimitCallback(void* data,
21812181
env->RemoveHeapSnapshotNearHeapLimitCallback(0);
21822182
}
21832183

2184-
FPrintF(stderr, "Wrote snapshot to %s\n", filename.c_str());
2184+
FPrintF(stderr, "Wrote snapshot to %s\n", filename);
21852185
// Tell V8 to reset the heap limit once the heap usage falls down to
21862186
// 95% of the initial limit.
21872187
env->isolate()->AutomaticallyRestoreInitialHeapLimit(0.95);
Collapse file

‎src/inspector_profiler.cc‎

Copy file name to clipboardExpand all lines: src/inspector_profiler.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ uint64_t V8ProfilerConnection::DispatchMessage(const char* method,
6666
Debug(env(),
6767
DebugCategory::INSPECTOR_PROFILER,
6868
"Dispatching message %s\n",
69-
message.c_str());
69+
message);
7070
session_->Dispatch(StringView(message_data, message.length()));
7171
return id;
7272
}
Collapse file

‎src/node_builtins.cc‎

Copy file name to clipboardExpand all lines: src/node_builtins.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache(
559559
if (bootstrapCatch.HasCaught()) {
560560
per_process::Debug(DebugCategory::CODE_CACHE,
561561
"Failed to compile code cache for %s\n",
562-
id.data());
562+
id);
563563
all_succeeded = false;
564564
PrintCaughtException(context->GetIsolate(), context, bootstrapCatch);
565565
} else {
Collapse file

‎src/node_config_file.cc‎

Copy file name to clipboardExpand all lines: src/node_config_file.cc
+14-18Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ ParseResult ConfigReader::ProcessOptionValue(
4848
case options_parser::OptionType::kBoolean: {
4949
bool result;
5050
if (option_value->get_bool().get(result)) {
51-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
51+
FPrintF(stderr, "Invalid value for %s\n", option_name);
5252
return ParseResult::InvalidContent;
5353
}
5454

@@ -74,13 +74,13 @@ ParseResult ConfigReader::ProcessOptionValue(
7474
std::vector<std::string> result;
7575
simdjson::ondemand::array raw_imports;
7676
if (option_value->get_array().get(raw_imports)) {
77-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
77+
FPrintF(stderr, "Invalid value for %s\n", option_name);
7878
return ParseResult::InvalidContent;
7979
}
8080
for (auto raw_import : raw_imports) {
8181
std::string_view import;
8282
if (raw_import.get_string(import)) {
83-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
83+
FPrintF(stderr, "Invalid value for %s\n", option_name);
8484
return ParseResult::InvalidContent;
8585
}
8686
output->push_back(option_name + "=" + std::string(import));
@@ -90,22 +90,22 @@ ParseResult ConfigReader::ProcessOptionValue(
9090
case simdjson::ondemand::json_type::string: {
9191
std::string result;
9292
if (option_value->get_string(result)) {
93-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
93+
FPrintF(stderr, "Invalid value for %s\n", option_name);
9494
return ParseResult::InvalidContent;
9595
}
9696
output->push_back(option_name + "=" + result);
9797
break;
9898
}
9999
default:
100-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
100+
FPrintF(stderr, "Invalid value for %s\n", option_name);
101101
return ParseResult::InvalidContent;
102102
}
103103
break;
104104
}
105105
case options_parser::OptionType::kString: {
106106
std::string result;
107107
if (option_value->get_string(result)) {
108-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
108+
FPrintF(stderr, "Invalid value for %s\n", option_name);
109109
return ParseResult::InvalidContent;
110110
}
111111
output->push_back(option_name + "=" + result);
@@ -114,7 +114,7 @@ ParseResult ConfigReader::ProcessOptionValue(
114114
case options_parser::OptionType::kInteger: {
115115
int64_t result;
116116
if (option_value->get_int64().get(result)) {
117-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
117+
FPrintF(stderr, "Invalid value for %s\n", option_name);
118118
return ParseResult::InvalidContent;
119119
}
120120
output->push_back(option_name + "=" + std::to_string(result));
@@ -124,22 +124,19 @@ ParseResult ConfigReader::ProcessOptionValue(
124124
case options_parser::OptionType::kUInteger: {
125125
uint64_t result;
126126
if (option_value->get_uint64().get(result)) {
127-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
127+
FPrintF(stderr, "Invalid value for %s\n", option_name);
128128
return ParseResult::InvalidContent;
129129
}
130130
output->push_back(option_name + "=" + std::to_string(result));
131131
break;
132132
}
133133
case options_parser::OptionType::kNoOp: {
134-
FPrintF(stderr,
135-
"No-op flag %s is currently not supported\n",
136-
option_name.c_str());
134+
FPrintF(
135+
stderr, "No-op flag %s is currently not supported\n", option_name);
137136
return ParseResult::InvalidContent;
138137
}
139138
case options_parser::OptionType::kV8Option: {
140-
FPrintF(stderr,
141-
"V8 flag %s is currently not supported\n",
142-
option_name.c_str());
139+
FPrintF(stderr, "V8 flag %s is currently not supported\n", option_name);
143140
return ParseResult::InvalidContent;
144141
}
145142
default:
@@ -187,8 +184,7 @@ ParseResult ConfigReader::ParseOptions(
187184
if (option != options_map.end()) {
188185
// If the option has already been set, return an error
189186
if (unique_options->contains(option->first)) {
190-
FPrintF(
191-
stderr, "Option %s is already defined\n", option->first.c_str());
187+
FPrintF(stderr, "Option %s is already defined\n", option->first);
192188
return ParseResult::InvalidContent;
193189
}
194190
// Add the option to the unique set to prevent duplicates
@@ -204,7 +200,7 @@ ParseResult ConfigReader::ParseOptions(
204200
FPrintF(stderr,
205201
"Unknown or not allowed option %s for namespace %s\n",
206202
option_key,
207-
namespace_name.c_str());
203+
namespace_name);
208204
return ParseResult::InvalidContent;
209205
}
210206
}
@@ -277,7 +273,7 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
277273
if (field_error) {
278274
FPrintF(stderr,
279275
"\"%s\" value unexpected for %s (should be an object)\n",
280-
namespace_name.c_str(),
276+
namespace_name,
281277
config_path.data());
282278
return ParseResult::InvalidContent;
283279
}
Collapse file

‎src/node_errors.cc‎

Copy file name to clipboardExpand all lines: src/node_errors.cc
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,8 @@ static std::string GetErrorSource(Isolate* isolate,
156156
end -= script_start;
157157
}
158158

159-
std::string buf = SPrintF("%s:%i\n%s\n",
160-
filename_string,
161-
linenum,
162-
sourceline.c_str());
159+
std::string buf =
160+
SPrintF("%s:%i\n%s\n", filename_string, linenum, sourceline);
163161
CHECK_GT(buf.size(), 0);
164162
*added_exception_line = true;
165163

Collapse file

‎src/node_sea.cc‎

Copy file name to clipboardExpand all lines: src/node_sea.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ int BuildAssets(const std::unordered_map<std::string, std::string>& config,
642642
int r = ReadFileSync(&blob, path.c_str());
643643
if (r != 0) {
644644
const char* err = uv_strerror(r);
645-
FPrintF(stderr, "Cannot read asset %s: %s\n", path.c_str(), err);
645+
FPrintF(stderr, "Cannot read asset %s: %s\n", path, err);
646646
return r;
647647
}
648648
assets->emplace(key, std::move(blob));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.