summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-06-04 17:37:35 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-06-04 17:37:35 +0800
commite30f6eb6872d57f7da764690589c2f0c9ffdb53b (patch)
treeccb8e8f70bd491762341a2e3c89879e8ba96644e
parent5c995442909c4a7cb135088930925b7cfa8bc675 (diff)
fix: consolidate port number validation logic
-rw-r--r--src/main.cpp8
1 files changed, 2 insertions, 6 deletions
diff --git a/src/main.cpp b/src/main.cpp
index e23877c..0ee7b3a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -47,12 +47,8 @@ int main(int argc, char *argv[]) try {
return EXIT_SUCCESS;
} else if (std::ranges::all_of(arg, ::isdigit)) {
port = std::stoi(arg);
- if (port < 0) {
- log(ERR, "Port number must be greater than 0");
-
- return EXIT_FAILURE;
- } else if (port > 65535) {
- log(ERR, "Port number must be less than 65536");
+ if (port < 0 || port > 65535) {
+ log(ERR, "Port number must be between 0 and 65535");
return EXIT_FAILURE;
}