Skip to content

Commit e6c1ad5

Browse files
refacktargos
authored andcommitted
src: fix warnings around node_options
* header explicit usage, order, and reduce use of `*-inl.h` * pointer -> const reference when possible * no variable recyclicng * `std::begin/end` prefered over `instance.begin/end` * `USE` for explicit unused resaults Backport-PR-URL: #26649 PR-URL: #26280 Fixes: #25593 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 62f9049 commit e6c1ad5

5 files changed

+15
-14
lines changed

src/node_options-inl.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,15 @@ auto OptionsParser<Options>::Convert(
213213
template <typename Options>
214214
template <typename ChildOptions>
215215
void OptionsParser<Options>::Insert(
216-
const OptionsParser<ChildOptions>* child_options_parser,
216+
const OptionsParser<ChildOptions>& child_options_parser,
217217
ChildOptions* (Options::* get_child)()) {
218-
aliases_.insert(child_options_parser->aliases_.begin(),
219-
child_options_parser->aliases_.end());
218+
aliases_.insert(std::begin(child_options_parser.aliases_),
219+
std::end(child_options_parser.aliases_));
220220

221-
for (const auto& pair : child_options_parser->options_)
221+
for (const auto& pair : child_options_parser.options_)
222222
options_.emplace(pair.first, Convert(pair.second, get_child));
223223

224-
for (const auto& pair : child_options_parser->implications_)
224+
for (const auto& pair : child_options_parser.implications_)
225225
implications_.emplace(pair.first, Convert(pair.second, get_child));
226226
}
227227

src/node_options.cc

+5-4
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class EnvironmentOptionsParser : public OptionsParser<EnvironmentOptions> {
121121
EnvironmentOptionsParser();
122122
explicit EnvironmentOptionsParser(const DebugOptionsParser& dop)
123123
: EnvironmentOptionsParser() {
124-
Insert(&dop, &EnvironmentOptions::get_debug_options);
124+
Insert(dop, &EnvironmentOptions::get_debug_options);
125125
}
126126
};
127127

@@ -386,7 +386,7 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
386386
kAllowedInEnvironment);
387387
#endif // NODE_REPORT
388388

389-
Insert(&eop, &PerIsolateOptions::get_per_env_options);
389+
Insert(eop, &PerIsolateOptions::get_per_env_options);
390390
}
391391

392392
PerProcessOptionsParser::PerProcessOptionsParser(
@@ -496,7 +496,7 @@ PerProcessOptionsParser::PerProcessOptionsParser(
496496
#endif
497497
#endif
498498

499-
Insert(&iop, &PerProcessOptions::get_per_isolate_options);
499+
Insert(iop, &PerProcessOptions::get_per_isolate_options);
500500
}
501501

502502
inline std::string RemoveBrackets(const std::string& host) {
@@ -510,7 +510,8 @@ inline int ParseAndValidatePort(const std::string& port,
510510
std::vector<std::string>* errors) {
511511
char* endptr;
512512
errno = 0;
513-
const long result = strtol(port.c_str(), &endptr, 10); // NOLINT(runtime/int)
513+
const unsigned long result = // NOLINT(runtime/int)
514+
strtoul(port.c_str(), &endptr, 10);
514515
if (errno != 0 || *endptr != '\0'||
515516
(result != 0 && result < 1024) || result > 65535) {
516517
errors->push_back(" must be 0 or in range 1024 to 65535.");

src/node_options.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ class OptionsParser {
297297
// a method that yields the target options type from this parser's options
298298
// type.
299299
template <typename ChildOptions>
300-
void Insert(const OptionsParser<ChildOptions>* child_options_parser,
300+
void Insert(const OptionsParser<ChildOptions>& child_options_parser,
301301
ChildOptions* (Options::* get_child)());
302302

303303
// Parse a sequence of options into an options struct, a list of

src/node_process_object.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include <climits> // PATH_MAX
2-
31
#include "env-inl.h"
42
#include "node_internals.h"
53
#include "node_options-inl.h"
@@ -8,6 +6,8 @@
86
#include "node_revert.h"
97
#include "util-inl.h"
108

9+
#include <climits> // PATH_MAX
10+
1111
namespace node {
1212
using v8::Context;
1313
using v8::DEFAULT;

src/node_worker.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -447,13 +447,13 @@ void Worker::New(const FunctionCallbackInfo<Value>& args) {
447447
// The first argument is program name.
448448
invalid_args.erase(invalid_args.begin());
449449
if (errors.size() > 0 || invalid_args.size() > 0) {
450-
v8::Local<v8::Value> value =
450+
v8::Local<v8::Value> error =
451451
ToV8Value(env->context(),
452452
errors.size() > 0 ? errors : invalid_args)
453453
.ToLocalChecked();
454454
Local<String> key =
455455
FIXED_ONE_BYTE_STRING(env->isolate(), "invalidExecArgv");
456-
args.This()->Set(env->context(), key, value).FromJust();
456+
USE(args.This()->Set(env->context(), key, error).FromJust());
457457
return;
458458
}
459459
}

0 commit comments

Comments
 (0)