Commit 53edc275 authored by Igor Sugak's avatar Igor Sugak Committed by facebook-github-bot-0

folly: use -Wheader-hygiene with clang

Summary: `-Wheader-hygiene` warns on using namespace directive in global context in header.  Fix all of the violations.

Reviewed By: yfeldblum

Differential Revision: D2867655

fb-gh-sync-id: 46840f8ece99e7af262058e631635d870bd51149
parent 1ac421a5
......@@ -21,10 +21,6 @@
#include <boost/scoped_array.hpp>
#include <poll.h>
// This is a test-only header
/* using override */
using namespace folly;
enum StateEnum {
STATE_WAITING,
STATE_SUCCEEDED,
......@@ -33,11 +29,11 @@ enum StateEnum {
typedef std::function<void()> VoidCallback;
class ConnCallback : public AsyncSocket::ConnectCallback {
class ConnCallback : public folly::AsyncSocket::ConnectCallback {
public:
ConnCallback()
: state(STATE_WAITING)
, exception(AsyncSocketException::UNKNOWN, "none") {}
: state(STATE_WAITING),
exception(folly::AsyncSocketException::UNKNOWN, "none") {}
void connectSuccess() noexcept override {
state = STATE_SUCCEEDED;
......@@ -46,7 +42,7 @@ class ConnCallback : public AsyncSocket::ConnectCallback {
}
}
void connectErr(const AsyncSocketException& ex) noexcept override {
void connectErr(const folly::AsyncSocketException& ex) noexcept override {
state = STATE_FAILED;
exception = ex;
if (errorCallback) {
......@@ -55,17 +51,17 @@ class ConnCallback : public AsyncSocket::ConnectCallback {
}
StateEnum state;
AsyncSocketException exception;
folly::AsyncSocketException exception;
VoidCallback successCallback;
VoidCallback errorCallback;
};
class WriteCallback : public AsyncTransportWrapper::WriteCallback {
class WriteCallback : public folly::AsyncTransportWrapper::WriteCallback {
public:
WriteCallback()
: state(STATE_WAITING)
, bytesWritten(0)
, exception(AsyncSocketException::UNKNOWN, "none") {}
: state(STATE_WAITING),
bytesWritten(0),
exception(folly::AsyncSocketException::UNKNOWN, "none") {}
void writeSuccess() noexcept override {
state = STATE_SUCCEEDED;
......@@ -75,7 +71,7 @@ class WriteCallback : public AsyncTransportWrapper::WriteCallback {
}
void writeErr(size_t bytesWritten,
const AsyncSocketException& ex) noexcept override {
const folly::AsyncSocketException& ex) noexcept override {
state = STATE_FAILED;
this->bytesWritten = bytesWritten;
exception = ex;
......@@ -86,18 +82,18 @@ class WriteCallback : public AsyncTransportWrapper::WriteCallback {
StateEnum state;
size_t bytesWritten;
AsyncSocketException exception;
folly::AsyncSocketException exception;
VoidCallback successCallback;
VoidCallback errorCallback;
};
class ReadCallback : public AsyncTransportWrapper::ReadCallback {
class ReadCallback : public folly::AsyncTransportWrapper::ReadCallback {
public:
explicit ReadCallback(size_t _maxBufferSz = 4096)
: state(STATE_WAITING)
, exception(AsyncSocketException::UNKNOWN, "none")
, buffers()
, maxBufferSz(_maxBufferSz) {}
: state(STATE_WAITING),
exception(folly::AsyncSocketException::UNKNOWN, "none"),
buffers(),
maxBufferSz(_maxBufferSz) {}
~ReadCallback() {
for (std::vector<Buffer>::iterator it = buffers.begin();
......@@ -129,7 +125,7 @@ class ReadCallback : public AsyncTransportWrapper::ReadCallback {
state = STATE_SUCCEEDED;
}
void readErr(const AsyncSocketException& ex) noexcept override {
void readErr(const folly::AsyncSocketException& ex) noexcept override {
state = STATE_FAILED;
exception = ex;
}
......@@ -178,14 +174,14 @@ class ReadCallback : public AsyncTransportWrapper::ReadCallback {
};
StateEnum state;
AsyncSocketException exception;
folly::AsyncSocketException exception;
std::vector<Buffer> buffers;
Buffer currentBuffer;
VoidCallback dataAvailableCallback;
const size_t maxBufferSz;
};
class BufferCallback : public AsyncTransport::BufferCallback {
class BufferCallback : public folly::AsyncTransport::BufferCallback {
public:
BufferCallback() : buffered_(false), bufferCleared_(false) {}
......@@ -213,16 +209,21 @@ class TestServer {
: fd_(-1) {
fd_ = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (fd_ < 0) {
throw AsyncSocketException(AsyncSocketException::INTERNAL_ERROR,
"failed to create test server socket", errno);
throw folly::AsyncSocketException(
folly::AsyncSocketException::INTERNAL_ERROR,
"failed to create test server socket",
errno);
}
if (fcntl(fd_, F_SETFL, O_NONBLOCK) != 0) {
throw AsyncSocketException(AsyncSocketException::INTERNAL_ERROR,
throw folly::AsyncSocketException(
folly::AsyncSocketException::INTERNAL_ERROR,
"failed to put test server socket in "
"non-blocking mode", errno);
"non-blocking mode",
errno);
}
if (listen(fd_, 10) != 0) {
throw AsyncSocketException(AsyncSocketException::INTERNAL_ERROR,
throw folly::AsyncSocketException(
folly::AsyncSocketException::INTERNAL_ERROR,
"failed to listen on test server socket",
errno);
}
......@@ -244,17 +245,22 @@ class TestServer {
pfd.events = POLLIN;
int ret = poll(&pfd, 1, timeout);
if (ret == 0) {
throw AsyncSocketException(AsyncSocketException::INTERNAL_ERROR,
throw folly::AsyncSocketException(
folly::AsyncSocketException::INTERNAL_ERROR,
"test server accept() timed out");
} else if (ret < 0) {
throw AsyncSocketException(AsyncSocketException::INTERNAL_ERROR,
"test server accept() poll failed", errno);
throw folly::AsyncSocketException(
folly::AsyncSocketException::INTERNAL_ERROR,
"test server accept() poll failed",
errno);
}
int acceptedFd = ::accept(fd_, nullptr, nullptr);
if (acceptedFd < 0) {
throw AsyncSocketException(AsyncSocketException::INTERNAL_ERROR,
"test server accept() failed", errno);
throw folly::AsyncSocketException(
folly::AsyncSocketException::INTERNAL_ERROR,
"test server accept() failed",
errno);
}
return acceptedFd;
......@@ -265,9 +271,10 @@ class TestServer {
return std::shared_ptr<BlockingSocket>(new BlockingSocket(fd));
}
std::shared_ptr<AsyncSocket> acceptAsync(EventBase* evb, int timeout=50) {
std::shared_ptr<folly::AsyncSocket> acceptAsync(folly::EventBase* evb,
int timeout = 50) {
int fd = acceptFD(timeout);
return AsyncSocket::newSocket(evb, fd);
return folly::AsyncSocket::newSocket(evb, fd);
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment