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 f14ff14

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 4c30d2b commit f14ff14
Copy full SHA for f14ff14

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
@@ -2192,7 +2192,7 @@ size_t Environment::NearHeapLimitCallback(void* data,
21922192
env->RemoveHeapSnapshotNearHeapLimitCallback(0);
21932193
}
21942194

2195-
FPrintF(stderr, "Wrote snapshot to %s\n", filename.c_str());
2195+
FPrintF(stderr, "Wrote snapshot to %s\n", filename);
21962196
// Tell V8 to reset the heap limit once the heap usage falls down to
21972197
// 95% of the initial limit.
21982198
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(Isolate::GetCurrent(), 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
@@ -49,7 +49,7 @@ ParseResult ConfigReader::ProcessOptionValue(
4949
case options_parser::OptionType::kBoolean: {
5050
bool result;
5151
if (option_value->get_bool().get(result)) {
52-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
52+
FPrintF(stderr, "Invalid value for %s\n", option_name);
5353
return ParseResult::InvalidContent;
5454
}
5555

@@ -75,13 +75,13 @@ ParseResult ConfigReader::ProcessOptionValue(
7575
std::vector<std::string> result;
7676
simdjson::ondemand::array raw_imports;
7777
if (option_value->get_array().get(raw_imports)) {
78-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
78+
FPrintF(stderr, "Invalid value for %s\n", option_name);
7979
return ParseResult::InvalidContent;
8080
}
8181
for (auto raw_import : raw_imports) {
8282
std::string_view import;
8383
if (raw_import.get_string(import)) {
84-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
84+
FPrintF(stderr, "Invalid value for %s\n", option_name);
8585
return ParseResult::InvalidContent;
8686
}
8787
output->push_back(option_name + "=" + std::string(import));
@@ -91,22 +91,22 @@ ParseResult ConfigReader::ProcessOptionValue(
9191
case simdjson::ondemand::json_type::string: {
9292
std::string result;
9393
if (option_value->get_string(result)) {
94-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
94+
FPrintF(stderr, "Invalid value for %s\n", option_name);
9595
return ParseResult::InvalidContent;
9696
}
9797
output->push_back(option_name + "=" + result);
9898
break;
9999
}
100100
default:
101-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
101+
FPrintF(stderr, "Invalid value for %s\n", option_name);
102102
return ParseResult::InvalidContent;
103103
}
104104
break;
105105
}
106106
case options_parser::OptionType::kString: {
107107
std::string result;
108108
if (option_value->get_string(result)) {
109-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
109+
FPrintF(stderr, "Invalid value for %s\n", option_name);
110110
return ParseResult::InvalidContent;
111111
}
112112
output->push_back(option_name + "=" + result);
@@ -115,7 +115,7 @@ ParseResult ConfigReader::ProcessOptionValue(
115115
case options_parser::OptionType::kInteger: {
116116
int64_t result;
117117
if (option_value->get_int64().get(result)) {
118-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
118+
FPrintF(stderr, "Invalid value for %s\n", option_name);
119119
return ParseResult::InvalidContent;
120120
}
121121
output->push_back(option_name + "=" + std::to_string(result));
@@ -125,22 +125,19 @@ ParseResult ConfigReader::ProcessOptionValue(
125125
case options_parser::OptionType::kUInteger: {
126126
uint64_t result;
127127
if (option_value->get_uint64().get(result)) {
128-
FPrintF(stderr, "Invalid value for %s\n", option_name.c_str());
128+
FPrintF(stderr, "Invalid value for %s\n", option_name);
129129
return ParseResult::InvalidContent;
130130
}
131131
output->push_back(option_name + "=" + std::to_string(result));
132132
break;
133133
}
134134
case options_parser::OptionType::kNoOp: {
135-
FPrintF(stderr,
136-
"No-op flag %s is currently not supported\n",
137-
option_name.c_str());
135+
FPrintF(
136+
stderr, "No-op flag %s is currently not supported\n", option_name);
138137
return ParseResult::InvalidContent;
139138
}
140139
case options_parser::OptionType::kV8Option: {
141-
FPrintF(stderr,
142-
"V8 flag %s is currently not supported\n",
143-
option_name.c_str());
140+
FPrintF(stderr, "V8 flag %s is currently not supported\n", option_name);
144141
return ParseResult::InvalidContent;
145142
}
146143
default:
@@ -189,8 +186,7 @@ ParseResult ConfigReader::ParseOptions(
189186
if (option != options_map.end()) {
190187
// If the option has already been set, return an error
191188
if (unique_options->contains(option->first)) {
192-
FPrintF(
193-
stderr, "Option %s is already defined\n", option->first.c_str());
189+
FPrintF(stderr, "Option %s is already defined\n", option->first);
194190
return ParseResult::InvalidContent;
195191
}
196192
// Add the option to the unique set to prevent duplicates
@@ -206,7 +202,7 @@ ParseResult ConfigReader::ParseOptions(
206202
FPrintF(stderr,
207203
"Unknown or not allowed option %s for namespace %s\n",
208204
option_key,
209-
namespace_name.c_str());
205+
namespace_name);
210206
return ParseResult::InvalidContent;
211207
}
212208
}
@@ -303,7 +299,7 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
303299
if (field_error) {
304300
FPrintF(stderr,
305301
"\"%s\" value unexpected for %s (should be an object)\n",
306-
namespace_name.c_str(),
302+
namespace_name,
307303
config_path.data());
308304
return ParseResult::InvalidContent;
309305
}
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
@@ -639,7 +639,7 @@ int BuildAssets(const std::unordered_map<std::string, std::string>& config,
639639
int r = ReadFileSync(&blob, path.c_str());
640640
if (r != 0) {
641641
const char* err = uv_strerror(r);
642-
FPrintF(stderr, "Cannot read asset %s: %s\n", path.c_str(), err);
642+
FPrintF(stderr, "Cannot read asset %s: %s\n", path, err);
643643
return r;
644644
}
645645
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.