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 Aug 13, 2023
1 parent b5da2f4 commit 3dafabd
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 3dafabd

Please # to comment.