Skip to content

src: modify int to uint16_t for HostPort #49845

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/inspector_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void InspectorIo::ThreadMain() {
new InspectorIoDelegate(queue, main_thread_, id_,
script_path, script_name_));
std::string host;
int port;
uint16_t port;
{
ExclusiveAccess<HostPort>::Scoped host_port(host_port_);
host = host_port->host();
Expand Down
2 changes: 1 addition & 1 deletion src/inspector_js_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void Open(const FunctionCallbackInfo<Value>& args) {
uint32_t port = args[0].As<Uint32>()->Value();
CHECK_LE(port, std::numeric_limits<uint16_t>::max());
ExclusiveAccess<HostPort>::Scoped host_port(agent->host_port());
host_port->set_port(static_cast<int>(port));
host_port->set_port(static_cast<uint16_t>(port));
}

if (args.Length() > 1 && args[1]->IsString()) {
Expand Down
12 changes: 4 additions & 8 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,20 @@ class HostPort {

void set_host(const std::string& host) { host_name_ = host; }

void set_port(int port) { port_ = port; }
void set_port(uint16_t port) { port_ = port; }

const std::string& host() const { return host_name_; }

int port() const {
// TODO(joyeecheung): make port a uint16_t
CHECK_GE(port_, 0);
return port_;
}
uint16_t port() const { return port_; }

void Update(const HostPort& other) {
if (!other.host_name_.empty()) host_name_ = other.host_name_;
if (other.port_ >= 0) port_ = other.port_;
port_ = other.port_;
}

private:
std::string host_name_;
int port_;
uint16_t port_;
};

class Options {
Expand Down