src/shrpx_config.cc: Code cleanup

This commit is contained in:
Tatsuhiro Tsujikawa 2013-10-02 23:13:25 +09:00
parent d90e0d4262
commit c7ce6d811e
1 changed files with 6 additions and 6 deletions

View File

@ -102,7 +102,7 @@ const char SHRPX_OPT_WRITE_BURST[] = "write-burst";
const char SHRPX_OPT_NPN_LIST[] = "npn-list"; const char SHRPX_OPT_NPN_LIST[] = "npn-list";
namespace { namespace {
Config *config = 0; Config *config = nullptr;
} // namespace } // namespace
const Config* get_config() const Config* get_config()
@ -308,8 +308,8 @@ int parse_config(const char *opt, const char *optarg)
} else if(util::strieq(opt, SHRPX_OPT_PID_FILE)) { } else if(util::strieq(opt, SHRPX_OPT_PID_FILE)) {
set_config_str(&mod_config()->pid_file, optarg); set_config_str(&mod_config()->pid_file, optarg);
} else if(util::strieq(opt, SHRPX_OPT_USER)) { } else if(util::strieq(opt, SHRPX_OPT_USER)) {
passwd *pwd = getpwnam(optarg); auto pwd = getpwnam(optarg);
if(pwd == 0) { if(!pwd) {
LOG(ERROR) << "--user: failed to get uid from " << optarg LOG(ERROR) << "--user: failed to get uid from " << optarg
<< ": " << strerror(errno); << ": " << strerror(errno);
return -1; return -1;
@ -319,7 +319,7 @@ int parse_config(const char *opt, const char *optarg)
} else if(util::strieq(opt, SHRPX_OPT_PRIVATE_KEY_FILE)) { } else if(util::strieq(opt, SHRPX_OPT_PRIVATE_KEY_FILE)) {
set_config_str(&mod_config()->private_key_file, optarg); set_config_str(&mod_config()->private_key_file, optarg);
} else if(util::strieq(opt, SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE)) { } else if(util::strieq(opt, SHRPX_OPT_PRIVATE_KEY_PASSWD_FILE)) {
std::string passwd = read_passwd_from_file(optarg); auto passwd = read_passwd_from_file(optarg);
if (passwd.empty()) { if (passwd.empty()) {
LOG(ERROR) << "Couldn't read key file's passwd from " << optarg; LOG(ERROR) << "Couldn't read key file's passwd from " << optarg;
return -1; return -1;
@ -335,7 +335,7 @@ int parse_config(const char *opt, const char *optarg)
if(sp) { if(sp) {
std::string keyfile(optarg, sp); std::string keyfile(optarg, sp);
// TODO Do we need private key for subcert? // TODO Do we need private key for subcert?
SSL_CTX *ssl_ctx = ssl::create_ssl_context(keyfile.c_str(), sp+1); auto ssl_ctx = ssl::create_ssl_context(keyfile.c_str(), sp+1);
if(!get_config()->cert_tree) { if(!get_config()->cert_tree) {
mod_config()->cert_tree = ssl::cert_lookup_tree_new(); mod_config()->cert_tree = ssl::cert_lookup_tree_new();
} }
@ -444,7 +444,7 @@ int load_config(const char *filename)
return -1; return -1;
} }
line[i] = '\0'; line[i] = '\0';
const char *s = line.c_str(); auto s = line.c_str();
if(parse_config(s, s+i+1) == -1) { if(parse_config(s, s+i+1) == -1) {
return -1; return -1;
} }