Skip to content

Commit bc7ab07

Browse files
committed
src: remove unnecessary c_str() conversions in diagnostic messages
1 parent 4a13a62 commit bc7ab07

File tree

12 files changed

+54
-54
lines changed

12 files changed

+54
-54
lines changed

src/blob_serializer_deserializer-inl.h

Lines 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;

src/compile_cache.cc

Lines 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);

src/env.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ size_t Environment::NearHeapLimitCallback(void* data,
22002200
env->RemoveHeapSnapshotNearHeapLimitCallback(0);
22012201
}
22022202

2203-
FPrintF(stderr, "Wrote snapshot to %s\n", filename.c_str());
2203+
FPrintF(stderr, "Wrote snapshot to %s\n", filename);
22042204
// Tell V8 to reset the heap limit once the heap usage falls down to
22052205
// 95% of the initial limit.
22062206
env->isolate()->AutomaticallyRestoreInitialHeapLimit(0.95);

src/inspector_profiler.cc

Lines 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
}

src/large_pages/node_large_page.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ template <typename... Args>
122122
inline void Debug(std::string fmt, Args&&... args) {
123123
node::Debug(&per_process::enabled_debug_list,
124124
DebugCategory::HUGEPAGES,
125-
(std::string("Hugepages info: ") + fmt).c_str(),
125+
std::string("Hugepages info: ") + fmt,
126126
std::forward<Args>(args)...);
127127
}
128128

src/node_builtins.cc

Lines 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 {

src/node_config_file.cc

Lines changed: 13 additions & 13 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,7 +125,7 @@ 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));
@@ -134,13 +134,13 @@ ParseResult ConfigReader::ProcessOptionValue(
134134
case options_parser::OptionType::kNoOp: {
135135
FPrintF(stderr,
136136
"No-op flag %s is currently not supported\n",
137-
option_name.c_str());
137+
option_name);
138138
return ParseResult::InvalidContent;
139139
}
140140
case options_parser::OptionType::kV8Option: {
141141
FPrintF(stderr,
142142
"V8 flag %s is currently not supported\n",
143-
option_name.c_str());
143+
option_name);
144144
return ParseResult::InvalidContent;
145145
}
146146
default:
@@ -190,7 +190,7 @@ ParseResult ConfigReader::ParseOptions(
190190
// If the option has already been set, return an error
191191
if (unique_options->contains(option->first)) {
192192
FPrintF(
193-
stderr, "Option %s is already defined\n", option->first.c_str());
193+
stderr, "Option %s is already defined\n", option->first);
194194
return ParseResult::InvalidContent;
195195
}
196196
// Add the option to the unique set to prevent duplicates
@@ -206,7 +206,7 @@ ParseResult ConfigReader::ParseOptions(
206206
FPrintF(stderr,
207207
"Unknown or not allowed option %s for namespace %s\n",
208208
option_key,
209-
namespace_name.c_str());
209+
namespace_name);
210210
return ParseResult::InvalidContent;
211211
}
212212
}
@@ -303,7 +303,7 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) {
303303
if (field_error) {
304304
FPrintF(stderr,
305305
"\"%s\" value unexpected for %s (should be an object)\n",
306-
namespace_name.c_str(),
306+
namespace_name,
307307
config_path.data());
308308
return ParseResult::InvalidContent;
309309
}

src/node_errors.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ static std::string GetErrorSource(Isolate* isolate,
159159
std::string buf = SPrintF("%s:%i\n%s\n",
160160
filename_string,
161161
linenum,
162-
sourceline.c_str());
162+
sourceline);
163163
CHECK_GT(buf.size(), 0);
164164
*added_exception_line = true;
165165

src/node_sea.cc

Lines 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)