Make ImmutableString(const char*) explicit
This commit is contained in:
parent
0d4d1a63d4
commit
39c068974d
21
src/shrpx.cc
21
src/shrpx.cc
|
@ -574,7 +574,7 @@ int create_unix_domain_server_socket(UpstreamAddr &faddr,
|
|||
<< (faddr.tls ? ", tls" : "");
|
||||
(*found).used = true;
|
||||
faddr.fd = (*found).fd;
|
||||
faddr.hostport = "localhost";
|
||||
faddr.hostport = ImmutableString::from_lit("localhost");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ int create_unix_domain_server_socket(UpstreamAddr &faddr,
|
|||
<< (faddr.tls ? ", tls" : "");
|
||||
|
||||
faddr.fd = fd;
|
||||
faddr.hostport = "localhost";
|
||||
faddr.hostport = ImmutableString::from_lit("localhost");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -855,7 +855,7 @@ get_inherited_addr_from_config(const Config *config) {
|
|||
continue;
|
||||
}
|
||||
|
||||
iaddr.host = host.data();
|
||||
iaddr.host = ImmutableString{host.data()};
|
||||
}
|
||||
|
||||
return iaddrs;
|
||||
|
@ -947,7 +947,7 @@ std::vector<InheritedAddr> get_inherited_addr_from_env() {
|
|||
}
|
||||
|
||||
InheritedAddr addr{};
|
||||
addr.host = path;
|
||||
addr.host = ImmutableString{path};
|
||||
addr.host_unix = true;
|
||||
addr.fd = static_cast<int>(fd);
|
||||
iaddrs.push_back(std::move(addr));
|
||||
|
@ -1001,7 +1001,7 @@ std::vector<InheritedAddr> get_inherited_addr_from_env() {
|
|||
}
|
||||
|
||||
InheritedAddr addr{};
|
||||
addr.host = host.data();
|
||||
addr.host = ImmutableString{host.data()};
|
||||
addr.port = static_cast<uint16_t>(port);
|
||||
addr.fd = static_cast<int>(fd);
|
||||
iaddrs.push_back(std::move(addr));
|
||||
|
@ -1273,7 +1273,7 @@ constexpr auto DEFAULT_ACCESSLOG_FORMAT = StringRef::from_lit(
|
|||
namespace {
|
||||
void fill_default_config(Config *config) {
|
||||
config->num_worker = 1;
|
||||
config->conf_path = "/etc/nghttpx/nghttpx.conf";
|
||||
config->conf_path = ImmutableString::from_lit("/etc/nghttpx/nghttpx.conf");
|
||||
config->pid = getpid();
|
||||
|
||||
if (ev_supported_backends() & ~ev_recommended_backends() & EVBACKEND_KQUEUE) {
|
||||
|
@ -1304,7 +1304,8 @@ void fill_default_config(Config *config) {
|
|||
auto &ocspconf = tlsconf.ocsp;
|
||||
// ocsp update interval = 14400 secs = 4 hours, borrowed from h2o
|
||||
ocspconf.update_interval = 4_h;
|
||||
ocspconf.fetch_ocsp_response_file = PKGDATADIR "/fetch-ocsp-response";
|
||||
ocspconf.fetch_ocsp_response_file =
|
||||
ImmutableString::from_lit(PKGDATADIR "/fetch-ocsp-response");
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1375,7 +1376,7 @@ void fill_default_config(Config *config) {
|
|||
accessconf.format = parse_log_format(DEFAULT_ACCESSLOG_FORMAT);
|
||||
|
||||
auto &errorconf = loggingconf.error;
|
||||
errorconf.file = "/dev/stderr";
|
||||
errorconf.file = ImmutableString::from_lit("/dev/stderr");
|
||||
}
|
||||
|
||||
loggingconf.syslog_facility = LOG_DAEMON;
|
||||
|
@ -2397,7 +2398,7 @@ int process_options(Config *config,
|
|||
|
||||
if (listenerconf.addrs.empty()) {
|
||||
UpstreamAddr addr{};
|
||||
addr.host = "*";
|
||||
addr.host = ImmutableString::from_lit("*");
|
||||
addr.port = 3000;
|
||||
addr.tls = true;
|
||||
addr.family = AF_INET;
|
||||
|
@ -2937,7 +2938,7 @@ int main(int argc, char **argv) {
|
|||
break;
|
||||
case 12:
|
||||
// --conf
|
||||
mod_config()->conf_path = optarg;
|
||||
mod_config()->conf_path = ImmutableString{optarg};
|
||||
break;
|
||||
case 14:
|
||||
// --syslog-facility
|
||||
|
|
|
@ -2032,7 +2032,7 @@ int parse_config(Config *config, int optid, const StringRef &opt,
|
|||
<< strerror(errno);
|
||||
return -1;
|
||||
}
|
||||
config->user = pwd->pw_name;
|
||||
config->user = ImmutableString{pwd->pw_name};
|
||||
config->uid = pwd->pw_uid;
|
||||
config->gid = pwd->pw_gid;
|
||||
|
||||
|
@ -2484,14 +2484,14 @@ int parse_config(Config *config, int optid, const StringRef &opt,
|
|||
switch (optid) {
|
||||
case SHRPX_OPTID_TLS_SESSION_CACHE_MEMCACHED: {
|
||||
auto &memcachedconf = config->tls.session_cache.memcached;
|
||||
memcachedconf.host = host;
|
||||
memcachedconf.host = ImmutableString{host};
|
||||
memcachedconf.port = port;
|
||||
memcachedconf.tls = params.tls;
|
||||
break;
|
||||
}
|
||||
case SHRPX_OPTID_TLS_TICKET_KEY_MEMCACHED: {
|
||||
auto &memcachedconf = config->tls.ticket.memcached;
|
||||
memcachedconf.host = host;
|
||||
memcachedconf.host = ImmutableString{host};
|
||||
memcachedconf.port = port;
|
||||
memcachedconf.tls = params.tls;
|
||||
break;
|
||||
|
@ -3005,7 +3005,7 @@ int configure_downstream_group(Config *config, bool http2_proxy,
|
|||
// for AF_UNIX socket, we use "localhost" as host for backend
|
||||
// hostport. This is used as Host header field to backend and
|
||||
// not going to be passed to any syscalls.
|
||||
addr.hostport = "localhost";
|
||||
addr.hostport = ImmutableString::from_lit("localhost");
|
||||
|
||||
auto path = addr.host.c_str();
|
||||
auto pathlen = addr.host.size();
|
||||
|
|
|
@ -255,7 +255,8 @@ public:
|
|||
ImmutableString() : len(0), base("") {}
|
||||
ImmutableString(const char *s, size_t slen)
|
||||
: len(slen), base(copystr(s, s + len)) {}
|
||||
ImmutableString(const char *s) : len(strlen(s)), base(copystr(s, s + len)) {}
|
||||
explicit ImmutableString(const char *s)
|
||||
: len(strlen(s)), base(copystr(s, s + len)) {}
|
||||
ImmutableString(const std::string &s)
|
||||
: len(s.size()), base(copystr(std::begin(s), std::end(s))) {}
|
||||
template <typename InputIt>
|
||||
|
|
|
@ -156,7 +156,7 @@ void test_template_string_ref(void) {
|
|||
CU_ASSERT(5 == from_lit.size());
|
||||
|
||||
// from ImmutableString
|
||||
ImmutableString im = "bravo";
|
||||
auto im = ImmutableString::from_lit("bravo");
|
||||
|
||||
StringRef imref(im);
|
||||
|
||||
|
|
Loading…
Reference in New Issue