GeezerVison is showing github.com — src: remove unnecessary `c_str()` conversions in diagnostic messages · nodejs/node@f14ff14
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: src/blob_serializer_deserializer-inl.h +9-9Lines changed: 9 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -105,7 +105,7 @@ template <typename T> | 105 | 105 | std::vector<T> BlobDeserializer<Impl>::ReadVector() { | 106 | 106 | if (is_debug) { | 107 | 107 | 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)); | 109 | 109 | } | 110 | 110 | size_t count = static_cast<size_t>(ReadArithmetic<size_t>()); | 111 | 111 | if (count == 0) { | @@ -123,7 +123,7 @@ std::vector<T> BlobDeserializer<Impl>::ReadVector() { | 123 | 123 | if (is_debug) { | 124 | 124 | std::string str = std::is_arithmetic_v<T> ? "" : ToStr(result); | 125 | 125 | 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); | 127 | 127 | } | 128 | 128 | return result; | 129 | 129 | } | @@ -163,7 +163,7 @@ void BlobDeserializer<Impl>::ReadArithmetic(T* out, size_t count) { | 163 | 163 | DCHECK_GT(count, 0); // Should not read contents for vectors of size 0. | 164 | 164 | if (is_debug) { | 165 | 165 | 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); | 167 | 167 | } | 168 | 168 |
| 169 | 169 | size_t size = sizeof(T) * count; | @@ -172,7 +172,7 @@ void BlobDeserializer<Impl>::ReadArithmetic(T* out, size_t count) { | 172 | 172 | if (is_debug) { | 173 | 173 | std::string str = | 174 | 174 | "{ " + 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); | 176 | 176 | } | 177 | 177 | read_total += size; | 178 | 178 | } | @@ -240,10 +240,10 @@ size_t BlobSerializer<Impl>::WriteVector(const std::vector<T>& data) { | 240 | 240 | std::string name = GetName<T>(); | 241 | 241 | Debug("\nAt 0x%x: WriteVector<%s>() (%d-byte), count=%d: %s\n", | 242 | 242 | sink.size(), | 243 | | - name.c_str(), | | 243 | + name, | 244 | 244 | sizeof(T), | 245 | 245 | data.size(), | 246 | | - str.c_str()); | | 246 | + str); | 247 | 247 | } | 248 | 248 |
| 249 | 249 | size_t written_total = WriteArithmetic<size_t>(data.size()); | @@ -259,7 +259,7 @@ size_t BlobSerializer<Impl>::WriteVector(const std::vector<T>& data) { | 259 | 259 |
| 260 | 260 | if (is_debug) { | 261 | 261 | 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); | 263 | 263 | } | 264 | 264 |
| 265 | 265 | return written_total; | @@ -319,10 +319,10 @@ size_t BlobSerializer<Impl>::WriteArithmetic(const T* data, size_t count) { | 319 | 319 | std::string name = GetName<T>(); | 320 | 320 | Debug("At 0x%x: Write<%s>() (%zu-byte), count=%zu: %s", | 321 | 321 | sink.size(), | 322 | | - name.c_str(), | | 322 | + name, | 323 | 323 | sizeof(T), | 324 | 324 | count, | 325 | | - str.c_str()); | | 325 | + str); | 326 | 326 | } | 327 | 327 |
| 328 | 328 | size_t size = sizeof(T) * count; | |
Collapse file Copy file name to clipboardExpand all lines: src/compile_cache.cc +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -265,8 +265,8 @@ CompileCacheEntry* CompileCacheHandler::GetOrInsert(Local<String> code, | 265 | 265 | if (!relative_path.empty()) { | 266 | 266 | file_path = relative_path; | 267 | 267 | 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_); | 270 | 270 | } | 271 | 271 | } | 272 | 272 | uint32_t key = GetCacheKey(file_path, type); | |
Collapse file Copy file name to clipboardExpand all lines: src/env.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -2192,7 +2192,7 @@ size_t Environment::NearHeapLimitCallback(void* data, | 2192 | 2192 | env->RemoveHeapSnapshotNearHeapLimitCallback(0); | 2193 | 2193 | } | 2194 | 2194 |
| 2195 | | - FPrintF(stderr, "Wrote snapshot to %s\n", filename.c_str()); | | 2195 | + FPrintF(stderr, "Wrote snapshot to %s\n", filename); | 2196 | 2196 | // Tell V8 to reset the heap limit once the heap usage falls down to | 2197 | 2197 | // 95% of the initial limit. | 2198 | 2198 | env->isolate()->AutomaticallyRestoreInitialHeapLimit(0.95); | |
Collapse file Copy file name to clipboardExpand all lines: src/inspector_profiler.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -66,7 +66,7 @@ uint64_t V8ProfilerConnection::DispatchMessage(const char* method, | 66 | 66 | Debug(env(), | 67 | 67 | DebugCategory::INSPECTOR_PROFILER, | 68 | 68 | "Dispatching message %s\n", | 69 | | - message.c_str()); | | 69 | + message); | 70 | 70 | session_->Dispatch(StringView(message_data, message.length())); | 71 | 71 | return id; | 72 | 72 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_builtins.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -559,7 +559,7 @@ bool BuiltinLoader::CompileAllBuiltinsAndCopyCodeCache( | 559 | 559 | if (bootstrapCatch.HasCaught()) { | 560 | 560 | per_process::Debug(DebugCategory::CODE_CACHE, | 561 | 561 | "Failed to compile code cache for %s\n", | 562 | | - id.data()); | | 562 | + id); | 563 | 563 | all_succeeded = false; | 564 | 564 | PrintCaughtException(Isolate::GetCurrent(), context, bootstrapCatch); | 565 | 565 | } else { | |
Collapse file Copy file name to clipboardExpand all lines: src/node_config_file.cc +14-18Lines changed: 14 additions & 18 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ ParseResult ConfigReader::ProcessOptionValue( | 49 | 49 | case options_parser::OptionType::kBoolean: { | 50 | 50 | bool result; | 51 | 51 | 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); | 53 | 53 | return ParseResult::InvalidContent; | 54 | 54 | } | 55 | 55 |
| @@ -75,13 +75,13 @@ ParseResult ConfigReader::ProcessOptionValue( | 75 | 75 | std::vector<std::string> result; | 76 | 76 | simdjson::ondemand::array raw_imports; | 77 | 77 | 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); | 79 | 79 | return ParseResult::InvalidContent; | 80 | 80 | } | 81 | 81 | for (auto raw_import : raw_imports) { | 82 | 82 | std::string_view import; | 83 | 83 | 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); | 85 | 85 | return ParseResult::InvalidContent; | 86 | 86 | } | 87 | 87 | output->push_back(option_name + "=" + std::string(import)); | @@ -91,22 +91,22 @@ ParseResult ConfigReader::ProcessOptionValue( | 91 | 91 | case simdjson::ondemand::json_type::string: { | 92 | 92 | std::string result; | 93 | 93 | 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); | 95 | 95 | return ParseResult::InvalidContent; | 96 | 96 | } | 97 | 97 | output->push_back(option_name + "=" + result); | 98 | 98 | break; | 99 | 99 | } | 100 | 100 | default: | 101 | | - FPrintF(stderr, "Invalid value for %s\n", option_name.c_str()); | | 101 | + FPrintF(stderr, "Invalid value for %s\n", option_name); | 102 | 102 | return ParseResult::InvalidContent; | 103 | 103 | } | 104 | 104 | break; | 105 | 105 | } | 106 | 106 | case options_parser::OptionType::kString: { | 107 | 107 | std::string result; | 108 | 108 | 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); | 110 | 110 | return ParseResult::InvalidContent; | 111 | 111 | } | 112 | 112 | output->push_back(option_name + "=" + result); | @@ -115,7 +115,7 @@ ParseResult ConfigReader::ProcessOptionValue( | 115 | 115 | case options_parser::OptionType::kInteger: { | 116 | 116 | int64_t result; | 117 | 117 | 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); | 119 | 119 | return ParseResult::InvalidContent; | 120 | 120 | } | 121 | 121 | output->push_back(option_name + "=" + std::to_string(result)); | @@ -125,22 +125,19 @@ ParseResult ConfigReader::ProcessOptionValue( | 125 | 125 | case options_parser::OptionType::kUInteger: { | 126 | 126 | uint64_t result; | 127 | 127 | 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); | 129 | 129 | return ParseResult::InvalidContent; | 130 | 130 | } | 131 | 131 | output->push_back(option_name + "=" + std::to_string(result)); | 132 | 132 | break; | 133 | 133 | } | 134 | 134 | 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); | 138 | 137 | return ParseResult::InvalidContent; | 139 | 138 | } | 140 | 139 | 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); | 144 | 141 | return ParseResult::InvalidContent; | 145 | 142 | } | 146 | 143 | default: | @@ -189,8 +186,7 @@ ParseResult ConfigReader::ParseOptions( | 189 | 186 | if (option != options_map.end()) { | 190 | 187 | // If the option has already been set, return an error | 191 | 188 | 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); | 194 | 190 | return ParseResult::InvalidContent; | 195 | 191 | } | 196 | 192 | // Add the option to the unique set to prevent duplicates | @@ -206,7 +202,7 @@ ParseResult ConfigReader::ParseOptions( | 206 | 202 | FPrintF(stderr, | 207 | 203 | "Unknown or not allowed option %s for namespace %s\n", | 208 | 204 | option_key, | 209 | | - namespace_name.c_str()); | | 205 | + namespace_name); | 210 | 206 | return ParseResult::InvalidContent; | 211 | 207 | } | 212 | 208 | } | @@ -303,7 +299,7 @@ ParseResult ConfigReader::ParseConfig(const std::string_view& config_path) { | 303 | 299 | if (field_error) { | 304 | 300 | FPrintF(stderr, | 305 | 301 | "\"%s\" value unexpected for %s (should be an object)\n", | 306 | | - namespace_name.c_str(), | | 302 | + namespace_name, | 307 | 303 | config_path.data()); | 308 | 304 | return ParseResult::InvalidContent; | 309 | 305 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_errors.cc +2-4Lines changed: 2 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -156,10 +156,8 @@ static std::string GetErrorSource(Isolate* isolate, | 156 | 156 | end -= script_start; | 157 | 157 | } | 158 | 158 |
| 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); | 163 | 161 | CHECK_GT(buf.size(), 0); | 164 | 162 | *added_exception_line = true; | 165 | 163 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node_sea.cc +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -639,7 +639,7 @@ int BuildAssets(const std::unordered_map<std::string, std::string>& config, | 639 | 639 | int r = ReadFileSync(&blob, path.c_str()); | 640 | 640 | if (r != 0) { | 641 | 641 | 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); | 643 | 643 | return r; | 644 | 644 | } | 645 | 645 | assets->emplace(key, std::move(blob)); | |
|