use std chr functions
The ones in std have overloads for const char/char. Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:

committed by
Max Kellermann

parent
99afe8e6d1
commit
e4dad42ca1
@@ -124,7 +124,7 @@ ExtractHost(const char *src) noexcept
|
||||
/* "[hostname]:port" (IPv6?) */
|
||||
|
||||
hostname = ++src;
|
||||
const char *end = strchr(hostname, ']');
|
||||
const char *end = std::strchr(hostname, ']');
|
||||
if (end == nullptr || end == hostname)
|
||||
/* failed, return nullptr */
|
||||
return result;
|
||||
|
@@ -65,7 +65,7 @@ ai_is_passive(const struct addrinfo *ai)
|
||||
static void
|
||||
FindAndResolveInterfaceName(char *host, size_t size)
|
||||
{
|
||||
char *percent = strchr(host, '%');
|
||||
char *percent = std::strchr(host, '%');
|
||||
if (percent == nullptr || percent + 64 > host + size)
|
||||
return;
|
||||
|
||||
|
@@ -84,7 +84,7 @@ SocketAddress::GetLocalPath() const noexcept
|
||||
/* must be null-terminated */
|
||||
raw.back() == 0 &&
|
||||
/* there must not be any other null byte */
|
||||
memchr(raw.data, 0, raw.size - 1) == nullptr
|
||||
std::memchr(raw.data, 0, raw.size - 1) == nullptr
|
||||
? raw.data
|
||||
: nullptr;
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <ws2tcpip.h>
|
||||
@@ -49,8 +50,6 @@
|
||||
#include <sys/un.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_UN
|
||||
|
||||
static std::string
|
||||
@@ -104,7 +103,7 @@ ToString(SocketAddress address) noexcept
|
||||
return "unknown";
|
||||
|
||||
#ifdef HAVE_IPV6
|
||||
if (strchr(host, ':') != nullptr) {
|
||||
if (std::strchr(host, ':') != nullptr) {
|
||||
std::string result("[");
|
||||
result.append(host);
|
||||
result.append("]:");
|
||||
|
Reference in New Issue
Block a user