Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(755)

Unified Diff: net/tools/quic/quic_client_bin.cc

Issue 938853002: quic_client should check return codes when parsing command-line flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/quic/quic_server_bin.cc ('K') | « net/quic/quic_server_bin.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/quic/quic_client_bin.cc
diff --git a/net/tools/quic/quic_client_bin.cc b/net/tools/quic/quic_client_bin.cc
index 38009448e29febf677a81fe7990035331397f0aa..66517ca9c197e33cfc3e201778eb41ab1210430f 100644
--- a/net/tools/quic/quic_client_bin.cc
+++ b/net/tools/quic/quic_client_bin.cc
@@ -128,6 +128,9 @@ int main(int argc, char *argv[]) {
int port;
if (base::StringToInt(line->GetSwitchValueASCII("port"), &port)) {
FLAGS_port = port;
+ } else {
+ std::cerr << "--port must be an integer\n";
+ return 1;
Ryan Hamilton 2015/02/18 23:51:13 Early return please: if (!base::StringToInt()) {
dougk 2015/02/19 00:29:19 Done.
}
}
if (line->HasSwitch("body")) {
@@ -170,8 +173,14 @@ int main(int argc, char *argv[]) {
GURL url(urls[0]);
string host = FLAGS_host;
// TODO(rtenneti): get ip_addr from hostname by doing host resolution.
- CHECK(!host.empty());
- net::ParseIPLiteralToNumber(host, &ip_addr);
+ if (host.empty()) {
+ LOG(ERROR) << "--host must be specified\n";
+ return 1;
+ }
+ if (!net::ParseIPLiteralToNumber(host, &ip_addr)) {
+ LOG(ERROR) << "--host could not be parsed as an IP address\n";
+ return 1;
+ }
string host_port = net::IPAddressToStringWithPort(ip_addr, FLAGS_port);
VLOG(1) << "Resolved " << host << " to " << host_port << endl;
« net/quic/quic_server_bin.cc ('K') | « net/quic/quic_server_bin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698