Commit 87cd095e authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

String literals are |const char*| - avoid casting them to |char*|.

Trying to assign a string literal to a |char*| pointer results in the
following compilation error:

    error: ISO C++11 does not allow conversion from string literal to
    'char *' [-Werror,-Wwritable-strings]

This CL:
*) Avoids (char*)"string literal" casts
*) Changes the type of corresponding fields from |char*| to |const char*|

Bug: 1080832
Change-Id: Ie92eed766acec232a9e6b971f5f5d5569914dba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2287911
Auto-Submit: Łukasz Anforowicz <lukasza@chromium.org>
Commit-Queue: Josh Karlin <jkarlin@chromium.org>
Reviewed-by: default avatarJosh Karlin <jkarlin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786350}
parent 3f0f1d80
...@@ -23,8 +23,8 @@ ...@@ -23,8 +23,8 @@
namespace internal { namespace internal {
typedef struct { typedef struct {
char* url; const char* url;
char* host_ip; const char* host_ip;
uint16_t port; uint16_t port;
} PageAddressInfo; } PageAddressInfo;
...@@ -35,42 +35,31 @@ typedef struct { ...@@ -35,42 +35,31 @@ typedef struct {
} UkmMetricInfo; } UkmMetricInfo;
static const PageAddressInfo static const PageAddressInfo
kPublicPage = {(char*)"https://foo.com/", (char*)"216.58.195.78", 443}, kPublicPage = {"https://foo.com/", "216.58.195.78", 443},
kPublicPageIPv6 = {(char*)"https://google.com/", kPublicPageIPv6 = {"https://google.com/", "2607:f8b0:4005:809::200e", 443},
(char*)"2607:f8b0:4005:809::200e", 443}, kPrivatePage = {"http://test.local/", "192.168.10.123", 80},
kPrivatePage = {(char*)"http://test.local/", (char*)"192.168.10.123", 80}, kLocalhostPage = {"http://localhost/", "127.0.0.1", 80},
kLocalhostPage = {(char*)"http://localhost/", (char*)"127.0.0.1", 80}, kLocalhostPageIPv6 = {"http://[::1]/", "::1", 80},
kLocalhostPageIPv6 = {(char*)"http://[::1]/", (char*)"::1", 80}, kPublicRequest1 = {"http://bar.com/", "100.150.200.250", 80},
kPublicRequest1 = {(char*)"http://bar.com/", (char*)"100.150.200.250", 80}, kPublicRequest2 = {"https://www.baz.com/", "192.10.20.30", 443},
kPublicRequest2 = {(char*)"https://www.baz.com/", (char*)"192.10.20.30", kSameSubnetRequest1 = {"http://test2.local:9000/", "192.168.10.200", 9000},
443}, kSameSubnetRequest2 = {"http://test2.local:8000/index.html",
kSameSubnetRequest1 = {(char*)"http://test2.local:9000/", "192.168.10.200", 8000},
(char*)"192.168.10.200", 9000}, kSameSubnetRequest3 = {"http://test2.local:8000/bar.html", "192.168.10.200",
kSameSubnetRequest2 = {(char*)"http://test2.local:8000/index.html", 8000},
(char*)"192.168.10.200", 8000}, kDiffSubnetRequest1 = {"http://10.0.10.200/", "10.0.10.200", 80},
kSameSubnetRequest3 = {(char*)"http://test2.local:8000/bar.html", kDiffSubnetRequest2 = {"http://172.16.0.85:8181/", "172.16.0.85", 8181},
(char*)"192.168.10.200", 8000}, kDiffSubnetRequest3 = {"http://10.15.20.25:12345/", "10.15.20.25", 12345},
kDiffSubnetRequest1 = {(char*)"http://10.0.10.200/", (char*)"10.0.10.200", kDiffSubnetRequest4 = {"http://172.31.100.20:515/", "172.31.100.20", 515},
80}, kLocalhostRequest1 = {"http://localhost:8080/", "127.0.0.1", 8080}, // WEB
kDiffSubnetRequest2 = {(char*)"http://172.16.0.85:8181/", kLocalhostRequest2 = {"http://127.0.1.1:3306/", "127.0.1.1", 3306}, // DB
(char*)"172.16.0.85", 8181}, kLocalhostRequest3 = {"http://localhost:515/", "127.0.2.1", 515}, // PRINT
kDiffSubnetRequest3 = {(char*)"http://10.15.20.25:12345/", kLocalhostRequest4 = {"http://127.100.150.200:9000/", "127.100.150.200",
(char*)"10.15.20.25", 12345}, 9000}, // DEV
kDiffSubnetRequest4 = {(char*)"http://172.31.100.20:515/", kLocalhostRequest5 = {"http://127.0.0.1:9876/", "127.0.0.1",
(char*)"172.31.100.20", 515},
kLocalhostRequest1 = {(char*)"http://localhost:8080/", (char*)"127.0.0.1",
8080}, // WEB
kLocalhostRequest2 = {(char*)"http://127.0.1.1:3306/", (char*)"127.0.1.1",
3306}, // DB
kLocalhostRequest3 = {(char*)"http://localhost:515/", (char*)"127.0.2.1",
515}, // PRINT
kLocalhostRequest4 = {(char*)"http://127.100.150.200:9000/",
(char*)"127.100.150.200", 9000}, // DEV
kLocalhostRequest5 = {(char*)"http://127.0.0.1:9876/", (char*)"127.0.0.1",
9876}, // OTHER 9876}, // OTHER
kRouterRequest1 = {(char*)"http://10.0.0.1/", (char*)"10.0.0.1", 80}, kRouterRequest1 = {"http://10.0.0.1/", "10.0.0.1", 80},
kRouterRequest2 = {(char*)"https://192.168.10.1/", (char*)"192.168.10.1", kRouterRequest2 = {"https://192.168.10.1/", "192.168.10.1", 443};
443};
} // namespace internal } // namespace internal
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment