Commit 59861a1f authored by Antoine Kaufmann's avatar Antoine Kaufmann Committed by Antoine Kaufmann
Browse files

fix all cpplint warnings

make lint should pass again now
parent 34e5a23f
filter=-readability/casting,-runtime/references,-build/include_order,-runtime/printf,-runtime/arrays filter=-readability/casting,-runtime/references,-build/include_order
filter=-runtime/printf,-runtime/arrays,-build/c++11,-readability/todo
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef DIST_UTILS_H_ #ifndef DIST_COMMON_UTILS_H_
#define DIST_UTILS_H_ #define DIST_COMMON_UTILS_H_
#include <stddef.h> #include <stddef.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -36,4 +36,4 @@ int UxsocketSendFd(int connfd, void *data, size_t len, int fd); ...@@ -36,4 +36,4 @@ int UxsocketSendFd(int connfd, void *data, size_t len, int fd);
int ShmCreate(const char *path, size_t size, void **addr); int ShmCreate(const char *path, size_t size, void **addr);
void *ShmMap(int shm_fd, size_t *size); void *ShmMap(int shm_fd, size_t *size);
#endif // DIST_UTILS_H_ #endif // DIST_COMMON_UTILS_H_
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef DIST_NET_RDMA_H_ #ifndef DIST_RDMA_NET_RDMA_H_
#define DIST_NET_RDMA_H_ #define DIST_RDMA_NET_RDMA_H_
#include <arpa/inet.h> #include <arpa/inet.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -43,4 +43,4 @@ int RdmaListen(struct sockaddr_in *addr); ...@@ -43,4 +43,4 @@ int RdmaListen(struct sockaddr_in *addr);
int RdmaConnect(struct sockaddr_in *addr); int RdmaConnect(struct sockaddr_in *addr);
int RdmaEvent(); int RdmaEvent();
#endif // DIST_NET_RDMA_H_ #endif // DIST_RDMA_NET_RDMA_H_
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef DIST_RDMA_H_ #ifndef DIST_RDMA_RDMA_H_
#define DIST_RDMA_H_ #define DIST_RDMA_RDMA_H_
#include <infiniband/verbs.h> #include <infiniband/verbs.h>
...@@ -39,4 +39,4 @@ int RdmaIBListen(struct sockaddr_in *addr); ...@@ -39,4 +39,4 @@ int RdmaIBListen(struct sockaddr_in *addr);
int RdmaIBConnect(struct sockaddr_in *addr); int RdmaIBConnect(struct sockaddr_in *addr);
struct ibv_qp *RdmaIBCreateQP(struct ibv_pd *pd, struct ibv_qp_init_attr *attr); struct ibv_qp *RdmaIBCreateQP(struct ibv_pd *pd, struct ibv_qp_init_attr *attr);
#endif // DIST_RDMA_H_ #endif // DIST_RDMA_RDMA_H_
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
#include "dist/common/base.h" #include "dist/common/base.h"
#include "dist/common/utils.h" #include "dist/common/utils.h"
//#define SOCK_DEBUG // #define SOCK_DEBUG
#define MAX_PEERS 32 #define MAX_PEERS 32
#define RXBUF_SIZE (1024 * 1024) #define RXBUF_SIZE (1024 * 1024)
......
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef SIMBRICKS_BASEIF_GENERIC_H_ #ifndef SIMBRICKS_BASE_GENERIC_H_
#define SIMBRICKS_BASEIF_GENERIC_H_ #define SIMBRICKS_BASE_GENERIC_H_
#include <simbricks/base/if.h> #include <simbricks/base/if.h>
...@@ -103,4 +103,4 @@ ...@@ -103,4 +103,4 @@
return SimbricksBaseIfOutMsgLen(&base_if->base); \ return SimbricksBaseIfOutMsgLen(&base_if->base); \
} }
#endif // SIMBRICKS_BASEIF_BASEIF_H_ #endif // SIMBRICKS_BASE_GENERIC_H_
...@@ -807,8 +807,8 @@ void SimbricksBaseIfClose(struct SimbricksBaseIf *base_if) { ...@@ -807,8 +807,8 @@ void SimbricksBaseIfClose(struct SimbricksBaseIf *base_if) {
if (base_if->conn_state == kConnOpen) { if (base_if->conn_state == kConnOpen) {
// send out termination message // send out termination message
volatile union SimbricksProtoBaseMsg *msg; volatile union SimbricksProtoBaseMsg *msg;
while ((msg = SimbricksBaseIfOutAlloc(base_if, UINT64_MAX)) == NULL) while ((msg = SimbricksBaseIfOutAlloc(base_if, UINT64_MAX)) == NULL) {
; }
SimbricksBaseIfOutSend(base_if, msg, SIMBRICKS_PROTO_MSG_TYPE_TERMINATE); SimbricksBaseIfOutSend(base_if, msg, SIMBRICKS_PROTO_MSG_TYPE_TERMINATE);
} }
......
...@@ -389,4 +389,4 @@ static inline bool SimbricksBaseIfSyncEnabled(struct SimbricksBaseIf *base_if) { ...@@ -389,4 +389,4 @@ static inline bool SimbricksBaseIfSyncEnabled(struct SimbricksBaseIf *base_if) {
return base_if->sync; return base_if->sync;
} }
#endif // SIMBRICKS_BASEIF_BASEIF_H_ #endif // SIMBRICKS_BASE_IF_H_
...@@ -65,8 +65,8 @@ int MultiNicRunner::RunMain(int argc, char *argv[]) { ...@@ -65,8 +65,8 @@ int MultiNicRunner::RunMain(int argc, char *argv[]) {
std::vector<boost::fibers::fiber *> fibers; std::vector<boost::fibers::fiber *> fibers;
do { do {
int end; int end;
for (end = start + 1; end < argc && strcmp(argv[end], "--"); end++) for (end = start + 1; end < argc && strcmp(argv[end], "--"); end++) {
; }
argv[start] = argv[0]; argv[start] = argv[0];
CompRunner *r = new CompRunner(factory_.create()); CompRunner *r = new CompRunner(factory_.create());
......
...@@ -39,8 +39,8 @@ class MultiNicRunner { ...@@ -39,8 +39,8 @@ class MultiNicRunner {
protected: protected:
class CompRunner : public Runner { class CompRunner : public Runner {
protected: protected:
virtual void YieldPoll() override; void YieldPoll() override;
virtual int NicIfInit() override; int NicIfInit() override;
public: public:
explicit CompRunner(Device &dev_); explicit CompRunner(Device &dev_);
......
...@@ -41,7 +41,7 @@ extern "C" { ...@@ -41,7 +41,7 @@ extern "C" {
#include <simbricks/base/proto.h> #include <simbricks/base/proto.h>
} }
//#define DEBUG_NICBM 1 // #define DEBUG_NICBM 1
#define STAT_NICBM 1 #define STAT_NICBM 1
#define DMA_MAX_PENDING 64 #define DMA_MAX_PENDING 64
......
...@@ -93,7 +93,7 @@ int SimbricksNicIfInit(struct SimbricksNicIf *nicif, const char *shm_path, ...@@ -93,7 +93,7 @@ int SimbricksNicIfInit(struct SimbricksNicIf *nicif, const char *shm_path,
} }
return SimBricksBaseIfEstablish(ests, n_bifs); return SimBricksBaseIfEstablish(ests, n_bifs);
} } // NOLINT(whitespace/indent)
int SimbricksNicIfCleanup(struct SimbricksNicIf *nicif) { int SimbricksNicIfCleanup(struct SimbricksNicIf *nicif) {
SimbricksBaseIfClose(&nicif->pcie.base); SimbricksBaseIfClose(&nicif->pcie.base);
......
/*
* Copyright 2022 Max Planck Institute for Software Systems, and
* National University of Singapore
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <signal.h> #include <signal.h>
#include <verilated.h> #include <verilated.h>
#include <verilated_fst_c.h> #include <verilated_fst_c.h>
...@@ -10,8 +34,8 @@ ...@@ -10,8 +34,8 @@
#define MAX_PKT_SIZE 2048 #define MAX_PKT_SIZE 2048
//#define ETH_DEBUG // #define ETH_DEBUG
//#define TRACE_ENABLED // #define TRACE_ENABLED
class EthernetTx; class EthernetTx;
class EthernetRx; class EthernetRx;
......
#ifndef NET_MENSHEN_PORTS_H_ /*
#define NET_MENSHEN_PORTS_H_ * Copyright 2022 Max Planck Institute for Software Systems, and
* National University of Singapore
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PORTS_H_
#define PORTS_H_
#include <stdint.h> #include <stdint.h>
...@@ -44,7 +68,7 @@ class NetPort : public Port { ...@@ -44,7 +68,7 @@ class NetPort : public Port {
int sync_; int sync_;
public: public:
NetPort(struct SimbricksBaseIfParams *params) : params_(params), explicit NetPort(struct SimbricksBaseIfParams *params) : params_(params),
netif_(&netifObj_), rx_(nullptr), sync_(0) { netif_(&netifObj_), rx_(nullptr), sync_(0) {
memset(&netifObj_, 0, sizeof(netifObj_)); memset(&netifObj_, 0, sizeof(netifObj_));
} }
...@@ -52,24 +76,24 @@ class NetPort : public Port { ...@@ -52,24 +76,24 @@ class NetPort : public Port {
NetPort(const NetPort &other) : netifObj_(other.netifObj_), NetPort(const NetPort &other) : netifObj_(other.netifObj_),
netif_(&netifObj_), rx_(other.rx_), sync_(other.sync_) {} netif_(&netifObj_), rx_(other.rx_), sync_(other.sync_) {}
virtual bool Connect(const char *path, int sync) override { bool Connect(const char *path, int sync) override {
sync_ = sync; sync_ = sync;
return SimbricksNetIfInit(netif_, params_, path, &sync_) == 0; return SimbricksNetIfInit(netif_, params_, path, &sync_) == 0;
} }
virtual bool IsSync() override { bool IsSync() override {
return sync_; return sync_;
} }
virtual void Sync(uint64_t cur_ts) override { void Sync(uint64_t cur_ts) override {
while (SimbricksNetIfOutSync(netif_, cur_ts)); while (SimbricksNetIfOutSync(netif_, cur_ts)) {}
} }
virtual uint64_t NextTimestamp() override { uint64_t NextTimestamp() override {
return SimbricksNetIfInTimestamp(netif_); return SimbricksNetIfInTimestamp(netif_);
} }
virtual enum RxPollState RxPacket( enum RxPollState RxPacket(
const void *& data, size_t &len, uint64_t cur_ts) override { const void *& data, size_t &len, uint64_t cur_ts) override {
assert(rx_ == nullptr); assert(rx_ == nullptr);
...@@ -90,14 +114,14 @@ class NetPort : public Port { ...@@ -90,14 +114,14 @@ class NetPort : public Port {
} }
} }
virtual void RxDone() override { void RxDone() override {
assert(rx_ != nullptr); assert(rx_ != nullptr);
SimbricksNetIfInDone(netif_, rx_); SimbricksNetIfInDone(netif_, rx_);
rx_ = nullptr; rx_ = nullptr;
} }
virtual bool TxPacket( bool TxPacket(
const void *data, size_t len, uint64_t cur_ts) override { const void *data, size_t len, uint64_t cur_ts) override {
volatile union SimbricksProtoNetMsg *msg_to = volatile union SimbricksProtoNetMsg *msg_to =
SimbricksNetIfOutAlloc(netif_, cur_ts); SimbricksNetIfOutAlloc(netif_, cur_ts);
...@@ -118,4 +142,4 @@ class NetPort : public Port { ...@@ -118,4 +142,4 @@ class NetPort : public Port {
} }
}; };
#endif // NET_MENSHEN_PORTS_H_ #endif // PORTS_H_
\ No newline at end of file
...@@ -44,7 +44,7 @@ extern "C" { ...@@ -44,7 +44,7 @@ extern "C" {
#include <simbricks/nicif/nicif.h> #include <simbricks/nicif/nicif.h>
}; };
//#define NETSWITCH_DEBUG // #define NETSWITCH_DEBUG
#define NETSWITCH_STAT #define NETSWITCH_STAT
struct SimbricksBaseIfParams netParams; struct SimbricksBaseIfParams netParams;
...@@ -155,25 +155,25 @@ class NetPort : public Port { ...@@ -155,25 +155,25 @@ class NetPort : public Port {
sync_(other.sync_) { sync_(other.sync_) {
} }
virtual bool Connect(const char *path, int sync) override { bool Connect(const char *path, int sync) override {
sync_ = sync; sync_ = sync;
return SimbricksNetIfInit(netif_, &netParams, path, &sync_) == 0; return SimbricksNetIfInit(netif_, &netParams, path, &sync_) == 0;
} }
virtual bool IsSync() override { bool IsSync() override {
return sync_; return sync_;
} }
virtual void Sync(uint64_t cur_ts) override { void Sync(uint64_t cur_ts) override {
while (SimbricksNetIfOutSync(netif_, cur_ts)) while (SimbricksNetIfOutSync(netif_, cur_ts)) {
; }
} }
virtual uint64_t NextTimestamp() override { uint64_t NextTimestamp() override {
return SimbricksNetIfInTimestamp(netif_); return SimbricksNetIfInTimestamp(netif_);
} }
virtual enum RxPollState RxPacket(const void *&data, size_t &len, enum RxPollState RxPacket(const void *&data, size_t &len,
uint64_t cur_ts) override { uint64_t cur_ts) override {
assert(rx_ == nullptr); assert(rx_ == nullptr);
...@@ -194,15 +194,14 @@ class NetPort : public Port { ...@@ -194,15 +194,14 @@ class NetPort : public Port {
} }
} }
virtual void RxDone() override { void RxDone() override {
assert(rx_ != nullptr); assert(rx_ != nullptr);
SimbricksNetIfInDone(netif_, rx_); SimbricksNetIfInDone(netif_, rx_);
rx_ = nullptr; rx_ = nullptr;
} }
virtual bool TxPacket(const void *data, size_t len, bool TxPacket(const void *data, size_t len, uint64_t cur_ts) override {
uint64_t cur_ts) override {
volatile union SimbricksProtoNetMsg *msg_to = volatile union SimbricksProtoNetMsg *msg_to =
SimbricksNetIfOutAlloc(netif_, cur_ts); SimbricksNetIfOutAlloc(netif_, cur_ts);
if (!msg_to && !sync_) { if (!msg_to && !sync_) {
...@@ -237,7 +236,7 @@ class NetHostPort : public NetPort { ...@@ -237,7 +236,7 @@ class NetHostPort : public NetPort {
netif_ = &nicif_.net; netif_ = &nicif_.net;
} }
virtual bool Connect(const char *path, int sync) override { bool Connect(const char *path, int sync) override {
sync_ = sync; sync_ = sync;
std::string shm_path = path; std::string shm_path = path;
shm_path += "-shm"; shm_path += "-shm";
...@@ -251,7 +250,7 @@ class NetHostPort : public NetPort { ...@@ -251,7 +250,7 @@ class NetHostPort : public NetPort {
return ret == 0; return ret == 0;
} }
virtual bool IsSync() override { bool IsSync() override {
return sync_; return sync_;
} }
}; };
......
...@@ -44,7 +44,7 @@ extern "C" { ...@@ -44,7 +44,7 @@ extern "C" {
#include <simbricks/nicif/nicif.h> #include <simbricks/nicif/nicif.h>
}; };
//#define NETSWITCH_DEBUG // #define NETSWITCH_DEBUG
#define NETSWITCH_STAT #define NETSWITCH_STAT
struct SimbricksBaseIfParams netParams; struct SimbricksBaseIfParams netParams;
...@@ -157,8 +157,8 @@ class NetPort { ...@@ -157,8 +157,8 @@ class NetPort {
} }
void Sync(uint64_t cur_ts) { void Sync(uint64_t cur_ts) {
while (SimbricksNetIfOutSync(&netif_, cur_ts)) while (SimbricksNetIfOutSync(&netif_, cur_ts)) {
; }
} }
uint64_t NextTimestamp() { uint64_t NextTimestamp() {
...@@ -226,7 +226,7 @@ class NetListenPort : public NetPort { ...@@ -226,7 +226,7 @@ class NetListenPort : public NetPort {
: NetPort(other), pool_(other.pool_) { : NetPort(other), pool_(other.pool_) {
} }
virtual bool Prepare() override { bool Prepare() override {
if (!Init()) if (!Init())
return false; return false;
......
...@@ -51,11 +51,11 @@ extern "C" { ...@@ -51,11 +51,11 @@ extern "C" {
}; };
#include <utils/json.hpp> #include <utils/json.hpp>
//#define DEBUG // #define DEBUG
using json = nlohmann::json; using json = nlohmann::json;
typedef long long int ts_t; typedef int64_t ts_t;
static const int log_wait_limit_ms = 10; // 10ms static const int log_wait_limit_ms = 10; // 10ms
static ts_t cur_ts = 0; static ts_t cur_ts = 0;
...@@ -63,7 +63,7 @@ static int exiting = 0; ...@@ -63,7 +63,7 @@ static int exiting = 0;
static std::vector<struct SimbricksNetIf> nsifs; static std::vector<struct SimbricksNetIf> nsifs;
static std::vector<int> tofino_fds; static std::vector<int> tofino_fds;
static std::ifstream log_ifs; static std::ifstream log_ifs;
static std::string log_line; static std::string log_line; // NOLINT(runtime/string)
static const int flush_msg_sz = 14; static const int flush_msg_sz = 14;
static char flush_msg[flush_msg_sz] = {0x0}; static char flush_msg[flush_msg_sz] = {0x0};
...@@ -174,7 +174,6 @@ static void switch_to_dev(int port) { ...@@ -174,7 +174,6 @@ static void switch_to_dev(int port) {
while ((n = recvfrom(tofino_fds.at(port), buf, BUFFER_SIZE, 0, while ((n = recvfrom(tofino_fds.at(port), buf, BUFFER_SIZE, 0,
(struct sockaddr *)&addr, &addr_len)) <= 0 || (struct sockaddr *)&addr, &addr_len)) <= 0 ||
addr.sll_pkttype == PACKET_OUTGOING) { addr.sll_pkttype == PACKET_OUTGOING) {
;
} }
msg_to = SimbricksNetIfOutAlloc(&nsifs[port], cur_ts); msg_to = SimbricksNetIfOutAlloc(&nsifs[port], cur_ts);
...@@ -198,7 +197,7 @@ static void process_event(const struct event &e) { ...@@ -198,7 +197,7 @@ static void process_event(const struct event &e) {
e.time); e.time);
#endif #endif
if (send(tofino_fds.at(e.port), e.msg.data(), e.msg.length(), 0) < if (send(tofino_fds.at(e.port), e.msg.data(), e.msg.length(), 0) <
(long int)e.msg.length()) { (ssize_t)e.msg.length()) {
fprintf(stderr, "tofino: failed to forward packet to switch\n"); fprintf(stderr, "tofino: failed to forward packet to switch\n");
abort(); abort();
} }
......
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