projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Mark constexpr values needed within non-implicitly-capturing lambdas as static
[folly.git]
/
folly
/
SocketAddress.cpp
diff --git
a/folly/SocketAddress.cpp
b/folly/SocketAddress.cpp
index fe7b6f85b8939c2ec2cbacd0d8641e501104e2bd..2d12d787e74ae2d4c630b716063a29f9935ad039 100644
(file)
--- a/
folly/SocketAddress.cpp
+++ b/
folly/SocketAddress.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
6
Facebook, Inc.
+ * Copyright 201
7
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-20,6
+20,7
@@
#include <folly/SocketAddress.h>
#include <folly/SocketAddress.h>
+#include <folly/CppAttributes.h>
#include <folly/Exception.h>
#include <folly/Hash.h>
#include <folly/Exception.h>
#include <folly/Hash.h>
@@
-329,7
+330,7
@@
void SocketAddress::setFromSockaddr(const struct sockaddr_un* address,
storage_.un.init();
}
external_ = true;
storage_.un.init();
}
external_ = true;
- memcpy(storage_.un.addr, address,
addrlen
);
+ memcpy(storage_.un.addr, address,
size_t(addrlen)
);
updateUnixAddressLength(addrlen);
// Fill the rest with 0s, just for safety
updateUnixAddressLength(addrlen);
// Fill the rest with 0s, just for safety
@@
-458,12
+459,13
@@
std::string SocketAddress::getPath() const {
}
if (storage_.un.addr->sun_path[0] == '\0') {
// abstract namespace
}
if (storage_.un.addr->sun_path[0] == '\0') {
// abstract namespace
- return std::string(storage_.un.addr->sun_path, storage_.un.pathLength());
+ return std::string(
+ storage_.un.addr->sun_path, size_t(storage_.un.pathLength()));
}
}
- return std::string(
storage_.un.addr->sun_path,
-
strnlen(
storage_.un.addr->sun_path,
-
storage_.un.pathLength(
)));
+ return std::string(
+ storage_.un.addr->sun_path,
+
strnlen(storage_.un.addr->sun_path, size_t(storage_.un.pathLength()
)));
}
std::string SocketAddress::describe() const {
}
std::string SocketAddress::describe() const {
@@
-477,9
+479,9
@@
std::string SocketAddress::describe() const {
return "<abstract unix address>";
}
return "<abstract unix address>";
}
- return std::string(
storage_.un.addr->sun_path,
-
strnlen(
storage_.un.addr->sun_path,
-
storage_.un.pathLength(
)));
+ return std::string(
+ storage_.un.addr->sun_path,
+
strnlen(storage_.un.addr->sun_path, size_t(storage_.un.pathLength()
)));
}
switch (getFamily()) {
case AF_UNSPEC:
}
switch (getFamily()) {
case AF_UNSPEC:
@@
-525,9
+527,10
@@
bool SocketAddress::operator==(const SocketAddress& other) const {
if (storage_.un.len != other.storage_.un.len) {
return false;
}
if (storage_.un.len != other.storage_.un.len) {
return false;
}
- int cmp = memcmp(storage_.un.addr->sun_path,
- other.storage_.un.addr->sun_path,
- storage_.un.pathLength());
+ int cmp = memcmp(
+ storage_.un.addr->sun_path,
+ other.storage_.un.addr->sun_path,
+ size_t(storage_.un.pathLength()));
return cmp == 0;
}
return cmp == 0;
}
@@
-552,7
+555,7
@@
bool SocketAddress::prefixMatch(const SocketAddress& other,
switch (getFamily()) {
case AF_INET:
mask_length = 32;
switch (getFamily()) {
case AF_INET:
mask_length = 32;
- // fallthrough
+ FOLLY_FALLTHROUGH;
case AF_INET6:
{
auto prefix = folly::IPAddress::longestCommonPrefix(
case AF_INET6:
{
auto prefix = folly::IPAddress::longestCommonPrefix(
@@
-572,10
+575,10
@@
size_t SocketAddress::hash() const {
if (external_) {
enum { kUnixPathMax = sizeof(storage_.un.addr->sun_path) };
const char *path = storage_.un.addr->sun_path;
if (external_) {
enum { kUnixPathMax = sizeof(storage_.un.addr->sun_path) };
const char *path = storage_.un.addr->sun_path;
-
size_t
pathLength = storage_.un.pathLength();
+
auto
pathLength = storage_.un.pathLength();
// TODO: this probably could be made more efficient
// TODO: this probably could be made more efficient
- for (
unsigned in
t n = 0; n < pathLength; ++n) {
- boost::hash_combine(seed, folly::hash::twang_mix64(
path[n]
));
+ for (
off_
t n = 0; n < pathLength; ++n) {
+ boost::hash_combine(seed, folly::hash::twang_mix64(
uint64_t(path[n])
));
}
}
}
}
@@
-705,7
+708,7
@@
void SocketAddress::updateUnixAddressLength(socklen_t addrlen) {
// abstract namespace. honor the specified length
} else {
// Call strnlen(), just in case the length was overspecified.
// abstract namespace. honor the specified length
} else {
// Call strnlen(), just in case the length was overspecified.
- s
ocklen
_t maxLength = addrlen - offsetof(struct sockaddr_un, sun_path);
+ s
ize
_t maxLength = addrlen - offsetof(struct sockaddr_un, sun_path);
size_t pathLength = strnlen(storage_.un.addr->sun_path, maxLength);
storage_.un.len =
socklen_t(offsetof(struct sockaddr_un, sun_path) + pathLength);
size_t pathLength = strnlen(storage_.un.addr->sun_path, maxLength);
storage_.un.len =
socklen_t(offsetof(struct sockaddr_un, sun_path) + pathLength);
@@
-723,11
+726,11
@@
bool SocketAddress::operator<(const SocketAddress& other) const {
//
// Note that this still meets the requirements for a strict weak
// ordering, so we can use this operator<() with standard C++ containers.
//
// Note that this still meets the requirements for a strict weak
// ordering, so we can use this operator<() with standard C++ containers.
-
size_t
thisPathLength = storage_.un.pathLength();
+
auto
thisPathLength = storage_.un.pathLength();
if (thisPathLength == 0) {
return false;
}
if (thisPathLength == 0) {
return false;
}
-
size_t
otherPathLength = other.storage_.un.pathLength();
+
auto
otherPathLength = other.storage_.un.pathLength();
if (otherPathLength == 0) {
return true;
}
if (otherPathLength == 0) {
return true;
}
@@
-736,9
+739,10
@@
bool SocketAddress::operator<(const SocketAddress& other) const {
if (thisPathLength != otherPathLength) {
return thisPathLength < otherPathLength;
}
if (thisPathLength != otherPathLength) {
return thisPathLength < otherPathLength;
}
- int cmp = memcmp(storage_.un.addr->sun_path,
- other.storage_.un.addr->sun_path,
- thisPathLength);
+ int cmp = memcmp(
+ storage_.un.addr->sun_path,
+ other.storage_.un.addr->sun_path,
+ size_t(thisPathLength));
return cmp < 0;
}
switch (getFamily()) {
return cmp < 0;
}
switch (getFamily()) {