diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:36:23 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2023-02-08 15:46:02 -0500 |
commit | c583a2520616c2736cffc389c89a48b159366e6c (patch) | |
tree | b4925f26506fcee96c16119431c01760f05db95d /gdbsupport/netstuff.cc | |
parent | ca7f92c2f15b86b09c4a8ad14806bef666308d31 (diff) | |
download | binutils-users/simark/clang-format.zip binutils-users/simark/clang-format.tar.gz binutils-users/simark/clang-format.tar.bz2 |
Run clang-format.shusers/simark/clang-format
Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968
Diffstat (limited to 'gdbsupport/netstuff.cc')
-rw-r--r-- | gdbsupport/netstuff.cc | 93 |
1 files changed, 44 insertions, 49 deletions
diff --git a/gdbsupport/netstuff.cc b/gdbsupport/netstuff.cc index 55b142d..e2bae0f 100644 --- a/gdbsupport/netstuff.cc +++ b/gdbsupport/netstuff.cc @@ -50,41 +50,40 @@ parse_connection_spec_without_prefix (std::string spec, struct addrinfo *hint) - ai_family is not AF_INET, and - spec[0] is '[', or - the number of ':' on spec is greater than 1. */ - bool is_ipv6 = (hint->ai_family == AF_INET6 - || (hint->ai_family != AF_INET - && (spec[0] == '[' - || std::count (spec.begin (), - spec.end (), ':') > 1))); + bool is_ipv6 + = (hint->ai_family == AF_INET6 + || (hint->ai_family != AF_INET + && (spec[0] == '[' + || std::count (spec.begin (), spec.end (), ':') > 1))); if (is_ipv6) { if (spec[0] == '[') - { - /* IPv6 addresses can be written as '[ADDR]:PORT', and we + { + /* IPv6 addresses can be written as '[ADDR]:PORT', and we support this notation. */ - size_t close_bracket_pos = spec.find_first_of (']'); + size_t close_bracket_pos = spec.find_first_of (']'); - if (close_bracket_pos == std::string::npos) - error (_("Missing close bracket in hostname '%s'"), - spec.c_str ()); + if (close_bracket_pos == std::string::npos) + error (_ ("Missing close bracket in hostname '%s'"), + spec.c_str ()); - hint->ai_family = AF_INET6; + hint->ai_family = AF_INET6; - const char c = spec[close_bracket_pos + 1]; + const char c = spec[close_bracket_pos + 1]; - if (c == '\0') - last_colon_pos = std::string::npos; - else if (c != ':') - error (_("Invalid cruft after close bracket in '%s'"), - spec.c_str ()); + if (c == '\0') + last_colon_pos = std::string::npos; + else if (c != ':') + error (_ ("Invalid cruft after close bracket in '%s'"), + spec.c_str ()); - /* Erase both '[' and ']'. */ - spec.erase (0, 1); - spec.erase (close_bracket_pos - 1, 1); - } + /* Erase both '[' and ']'. */ + spec.erase (0, 1); + spec.erase (close_bracket_pos - 1, 1); + } else if (spec.find_first_of (']') != std::string::npos) - error (_("Missing open bracket in hostname '%s'"), - spec.c_str ()); + error (_ ("Missing open bracket in hostname '%s'"), spec.c_str ()); } if (last_colon_pos == 0) @@ -119,35 +118,31 @@ parse_connection_spec (const char *spec, struct addrinfo *hint) /* Struct to hold the association between valid prefixes, their family and socktype. */ struct host_prefix - { - /* The prefix. */ - const char *prefix; - - /* The 'ai_family'. */ - int family; - - /* The 'ai_socktype'. */ - int socktype; - }; - static const struct host_prefix prefixes[] = - { - { "udp:", AF_UNSPEC, SOCK_DGRAM }, - { "tcp:", AF_UNSPEC, SOCK_STREAM }, - { "udp4:", AF_INET, SOCK_DGRAM }, - { "tcp4:", AF_INET, SOCK_STREAM }, - { "udp6:", AF_INET6, SOCK_DGRAM }, - { "tcp6:", AF_INET6, SOCK_STREAM }, - }; + { + /* The prefix. */ + const char *prefix; + + /* The 'ai_family'. */ + int family; + + /* The 'ai_socktype'. */ + int socktype; + }; + static const struct host_prefix prefixes[] = { + { "udp:", AF_UNSPEC, SOCK_DGRAM }, { "tcp:", AF_UNSPEC, SOCK_STREAM }, + { "udp4:", AF_INET, SOCK_DGRAM }, { "tcp4:", AF_INET, SOCK_STREAM }, + { "udp6:", AF_INET6, SOCK_DGRAM }, { "tcp6:", AF_INET6, SOCK_STREAM }, + }; for (const host_prefix prefix : prefixes) if (startswith (spec, prefix.prefix)) { - spec += strlen (prefix.prefix); - hint->ai_family = prefix.family; - hint->ai_socktype = prefix.socktype; - hint->ai_protocol - = hint->ai_socktype == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP; - break; + spec += strlen (prefix.prefix); + hint->ai_family = prefix.family; + hint->ai_socktype = prefix.socktype; + hint->ai_protocol + = hint->ai_socktype == SOCK_DGRAM ? IPPROTO_UDP : IPPROTO_TCP; + break; } return parse_connection_spec_without_prefix (spec, hint); |