From: Michal Jarzabek Date: Sat, 18 Jun 2016 12:15:42 +0000 (+0100) Subject: common/address_helper.cc:move variables closer... X-Git-Tag: v11.0.0~123^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F9799%2Fhead;p=ceph.git common/address_helper.cc:move variables closer... ... to the point where they are first used. Signed-off-by: Michal Jarzabek --- diff --git a/src/common/address_helper.cc b/src/common/address_helper.cc index 4637935ebc7..9e46b4a99c6 100644 --- a/src/common/address_helper.cc +++ b/src/common/address_helper.cc @@ -27,19 +27,17 @@ int entity_addr_from_url(entity_addr_t *addr /* out */, const char *url) using namespace boost; using std::endl; - struct addrinfo hints; - struct addrinfo *res; - regex expr("(tcp|rdma)://([^:]*):([\\d]+)"); cmatch m; if (regex_match(url, m, expr)) { - int error; string host(m[2].first, m[2].second); string port(m[3].first, m[3].second); + addrinfo hints; memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; - error = getaddrinfo(host.c_str(), NULL, &hints, &res); + addrinfo *res; + int error = getaddrinfo(host.c_str(), NULL, &hints, &res); if (! error) { addr->set_sockaddr((sockaddr*)res->ai_addr); addr->set_port(std::atoi(port.c_str()));