Skip to content

Commit 7069642

Browse files
c-p-i-ofacebook-github-bot
authored andcommitted
add target and fix errors
Summary: Add a buck target for `gloo/transport/uv` to prevent CodeMod from deleting this stack. Also fix compile warnings that turn into errors with the code: 1. Remove unused variables or make use of unused variables. 2. Rename `struct` to `class`. 3. Prevent "declaration shadows a local variable". 4. Use manual to make linter happy Reviewed By: fduwjj Differential Revision: D65232668 fbshipit-source-id: a5156ba7a34eb84e5d09dd248df30f2a3f474426
1 parent 67655d3 commit 7069642

File tree

5 files changed

+19
-21
lines changed

5 files changed

+19
-21
lines changed

gloo/transport/uv/address.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#pragma once
1010

1111
#ifdef _WIN32
12-
#include "gloo/common/win.h"
12+
#include "gloo/common/win.h" // @manual
1313
#else
1414
#include <sys/socket.h>
1515
#endif

gloo/transport/uv/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include <stdio.h>
1212

13-
#include <uv.h>
13+
#include <uv.h> // @manual
1414

1515
#define UV_CHECK(rv, prefix) \
1616
{ \

gloo/transport/uv/device.cc

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
#include <iostream>
1515
#include <sstream>
1616

17-
#include <uv.h>
17+
#include <uv.h> // @manual
1818

1919
#include <gloo/common/error.h>
2020
#ifndef _WIN32
2121
#include <gloo/common/linux.h>
2222
#else
23-
#include <gloo/common/win.h>
23+
#include <gloo/common/win.h> // @manual
2424
#endif
2525
#include <gloo/common/logging.h>
2626
#include <gloo/transport/uv/common.h>
@@ -180,8 +180,6 @@ std::shared_ptr<transport::Device> CreateDevice(struct attr attr) {
180180
}
181181

182182
Device::Device(const struct attr& attr) : attr_(attr) {
183-
int rv;
184-
185183
loop_ = libuv::Loop::create();
186184

187185
// Use async handle to trigger the event loop to
@@ -195,7 +193,7 @@ Device::Device(const struct attr& attr) : attr_(attr) {
195193
// Initialize server handle and wait for incoming connections.
196194
listener_ = loop_->resource<libuv::TCP>();
197195
listener_->on<libuv::ErrorEvent>(
198-
[this](const libuv::ErrorEvent& event, const libuv::TCP&) {
196+
[](const libuv::ErrorEvent& event, const libuv::TCP&) {
199197
// Nothing we can do about errors on the listener socket...
200198
GLOO_ENFORCE(!event, "Error on listener socket: ", event.what());
201199
});
@@ -261,16 +259,16 @@ void Device::connect(
261259
if (family == AF_INET) {
262260
const struct sockaddr_in* sa = (struct sockaddr_in*)&ss1;
263261
const struct sockaddr_in* sb = (struct sockaddr_in*)&ss2;
264-
const auto addrlen = sizeof(struct sockaddr_in);
265-
rv = memcmp(&sa->sin_addr, &sb->sin_addr, sizeof(struct in_addr));
262+
const auto addrlen = sizeof(struct in_addr);
263+
rv = memcmp(&sa->sin_addr, &sb->sin_addr, addrlen);
266264
if (rv == 0) {
267265
rv = sa->sin_port - sb->sin_port;
268266
}
269267
} else if (family == AF_INET6) {
270268
const struct sockaddr_in6* sa = (struct sockaddr_in6*)&ss1;
271269
const struct sockaddr_in6* sb = (struct sockaddr_in6*)&ss2;
272-
const auto addrlen = sizeof(struct sockaddr_in6);
273-
rv = memcmp(&sa->sin6_addr, &sb->sin6_addr, sizeof(struct in6_addr));
270+
const auto addrlen = sizeof(struct in6_addr);
271+
rv = memcmp(&sa->sin6_addr, &sb->sin6_addr, addrlen);
274272
if (rv == 0) {
275273
rv = sa->sin6_port - sb->sin6_port;
276274
}

gloo/transport/uv/libuv.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <utility>
3434
#include <vector>
3535

36-
#include <uv.h>
36+
#include <uv.h> // @manual
3737

3838
#define UV_ASSERT(rv, prefix) \
3939
{ \
@@ -65,7 +65,7 @@ struct BaseHandle {};
6565
struct BaseRequest {};
6666

6767
// Event type for errors.
68-
struct ErrorEvent {
68+
class ErrorEvent {
6969
public:
7070
explicit ErrorEvent(int error) : error_(error) {}
7171

@@ -326,7 +326,7 @@ class Resource : public Emitter<T>, public std::enable_shared_from_this<T> {
326326
std::shared_ptr<T> leak_;
327327
};
328328

329-
struct CloseEvent {};
329+
class CloseEvent {};
330330

331331
template <typename T, typename U>
332332
class Handle : public Resource<T, U>, public BaseHandle {
@@ -440,11 +440,11 @@ class Timer : public Handle<Timer, uv_timer_t> {
440440
}
441441
};
442442

443-
struct EndEvent {};
443+
class EndEvent {};
444444

445-
struct ListenEvent {};
445+
class ListenEvent {};
446446

447-
struct ConnectEvent {};
447+
class ConnectEvent {};
448448

449449
class ReadEvent {
450450
public:
@@ -466,7 +466,7 @@ class ReadEvent {
466466
}
467467
};
468468

469-
struct WriteEvent {};
469+
class WriteEvent {};
470470

471471
namespace detail {
472472

gloo/transport/uv/pair.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ void Pair::onNotifyRecvReady(const Op& op) {
325325
if (it != localPendingSend_.end()) {
326326
auto& queue = it->second;
327327
GLOO_ENFORCE(!queue.empty());
328-
auto op = std::move(queue.front());
328+
auto nextOp = std::move(queue.front());
329329

330330
// Remove operation from queue, and potentially remove map entry
331331
// for this tag.
@@ -334,9 +334,9 @@ void Pair::onNotifyRecvReady(const Op& op) {
334334
localPendingSend_.erase(it);
335335
}
336336

337-
auto buf = NonOwningPtr<UnboundBuffer>(op.buf);
337+
auto buf = NonOwningPtr<UnboundBuffer>(nextOp.buf);
338338
GLOO_ENFORCE(buf, "Cannot lock pointer to unbound buffer");
339-
sendUnboundBuffer(tag, std::move(buf), op.offset, op.length);
339+
sendUnboundBuffer(tag, std::move(buf), nextOp.offset, nextOp.length);
340340
return;
341341
}
342342

0 commit comments

Comments
 (0)