Skip to content

Commit acba84f

Browse files
author
pluris
committed
src: modify int to uint16_t fori HostPort
1 parent 55fde47 commit acba84f

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/inspector_io.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ void InspectorIo::ThreadMain() {
293293
new InspectorIoDelegate(queue, main_thread_, id_,
294294
script_path, script_name_));
295295
std::string host;
296-
int port;
296+
uint16_t port;
297297
{
298298
ExclusiveAccess<HostPort>::Scoped host_port(host_port_);
299299
host = host_port->host();

src/inspector_js_api.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ void Open(const FunctionCallbackInfo<Value>& args) {
286286
uint32_t port = args[0].As<Uint32>()->Value();
287287
CHECK_LE(port, std::numeric_limits<uint16_t>::max());
288288
ExclusiveAccess<HostPort>::Scoped host_port(agent->host_port());
289-
host_port->set_port(static_cast<int>(port));
289+
host_port->set_port(static_cast<uint16_t>(port));
290290
}
291291

292292
if (args.Length() > 1 && args[1]->IsString()) {

src/node_options.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,20 @@ class HostPort {
2828

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

31-
void set_port(int port) { port_ = port; }
31+
void set_port(uint16_t port) { port_ = port; }
3232

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

35-
int port() const {
36-
// TODO(joyeecheung): make port a uint16_t
37-
CHECK_GE(port_, 0);
38-
return port_;
39-
}
35+
uint16_t port() const { return port_; }
4036

4137
void Update(const HostPort& other) {
4238
if (!other.host_name_.empty()) host_name_ = other.host_name_;
43-
if (other.port_ >= 0) port_ = other.port_;
39+
port_ = other.port_;
4440
}
4541

4642
private:
4743
std::string host_name_;
48-
int port_;
44+
uint16_t port_;
4945
};
5046

5147
class Options {

0 commit comments

Comments
 (0)