Skip to content

Commit

Permalink
src: set port in node_options to uint16_t
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Sep 27, 2023
1 parent 783f64b commit 404a7b3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,23 @@ 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
uint16_t port() const {
CHECK_GE(port_, 0);
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 404a7b3

Please sign in to comment.