From e86679d56127d4d30fcc71ccbb8090425b280539 Mon Sep 17 00:00:00 2001 From: Michal Jarzabek Date: Sat, 18 Jun 2016 13:15:42 +0100 Subject: [PATCH] common/address_helper.cc:move variables closer... ... to the point where they are first used. Signed-off-by: Michal Jarzabek --- src/common/address_helper.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/common/address_helper.cc b/src/common/address_helper.cc index 4637935ebc7b2..9e46b4a99c6ec 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())); -- 2.39.5