Skip to content

Commit

Permalink
src: modify int to uint16_t fori HostPort
Browse files Browse the repository at this point in the history
  • Loading branch information
pluris committed Sep 25, 2023
1 parent 55fde47 commit c6c00ce
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
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
10 changes: 4 additions & 6 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,22 @@ 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);
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

0 comments on commit c6c00ce

Please sign in to comment.