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

Unified Diff: extensions/common/permissions/socket_permission_entry.cc

Issue 655063002: Use uint16 for port numbers more pervasively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert bad change Created 6 years, 1 month 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
« no previous file with comments | « extensions/common/permissions/socket_permission.h ('k') | media/cast/test/receiver.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/permissions/socket_permission_entry.cc
diff --git a/extensions/common/permissions/socket_permission_entry.cc b/extensions/common/permissions/socket_permission_entry.cc
index 76afe23771f3ba1f814aedfa9177830492f72a8a..0974ff8552382daf17a20336dc052b5ff5310358 100644
--- a/extensions/common/permissions/socket_permission_entry.cc
+++ b/extensions/common/permissions/socket_permission_entry.cc
@@ -24,8 +24,8 @@ using content::SocketPermissionRequest;
const char kColon = ':';
const char kDot = '.';
const char kWildcard[] = "*";
-const int kWildcardPortNumber = 0;
-const int kInvalidPort = -1;
+const uint16 kWildcardPortNumber = 0;
+const uint16 kInvalidPort = 65535;
bool StartsOrEndsWithWhitespace(const std::string& str) {
return !str.empty() &&
@@ -190,9 +190,10 @@ bool SocketPermissionEntry::ParseHostPattern(
if (StartsOrEndsWithWhitespace(pattern_tokens[1]))
return false;
- if (!base::StringToInt(pattern_tokens[1], &result.pattern_.port) ||
- result.pattern_.port < 1 || result.pattern_.port > 65535)
+ int port;
+ if (!base::StringToInt(pattern_tokens[1], &port) || port < 1 || port > 65535)
return false;
+ result.pattern_.port = static_cast<uint16>(port);
*entry = result;
return true;
« no previous file with comments | « extensions/common/permissions/socket_permission.h ('k') | media/cast/test/receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698