]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/address_helper.cc:move variables closer... 9799/head
authorMichal Jarzabek <stiopa@gmail.com>
Sat, 18 Jun 2016 12:15:42 +0000 (13:15 +0100)
committerMichal Jarzabek <stiopa@gmail.com>
Sat, 18 Jun 2016 12:15:42 +0000 (13:15 +0100)
... to the point where they are first used.

Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
src/common/address_helper.cc

index 4637935ebc7b23ea94f8d27394214f2fd75c3c89..9e46b4a99c6ecb0b87699d6b88c85c1fa1a7afbb 100644 (file)
@@ -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()));