summaryrefslogtreecommitdiffstats
path: root/src/msg/async/dpdk
diff options
context:
space:
mode:
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>2018-04-25 09:30:56 +0200
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>2018-05-02 17:01:58 +0200
commit39ffec281af577c766c619d568f7a7051d108b00 (patch)
tree79c527cc3871b9b113f1aabffb3cef9647ebb7be /src/msg/async/dpdk
parentMerge PR #21762 into master (diff)
downloadceph-39ffec281af577c766c619d568f7a7051d108b00.tar.xz
ceph-39ffec281af577c766c619d568f7a7051d108b00.zip
misc: mark constructors as explicit
Set 218 constructors as explicit to avoid implicit usage. Fix for cppcheck warning: Class has a constructor with 1 argument that is not explicit. Such constructors should in general be explicit for type safety reasons. Using the explicit keyword in the constructor means some mistakes when using the class can be avoided. For more information check: https://www.codeproject.com/Articles/28663/Explicit-Constructor-in-C Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Diffstat (limited to 'src/msg/async/dpdk')
-rw-r--r--src/msg/async/dpdk/EventDPDK.h2
-rw-r--r--src/msg/async/dpdk/Packet.h8
-rw-r--r--src/msg/async/dpdk/UserspaceEvent.h2
-rw-r--r--src/msg/async/dpdk/ethernet.h4
-rw-r--r--src/msg/async/dpdk/net.h2
5 files changed, 9 insertions, 9 deletions
diff --git a/src/msg/async/dpdk/EventDPDK.h b/src/msg/async/dpdk/EventDPDK.h
index 3e2aeb0e39e..9744b31a09f 100644
--- a/src/msg/async/dpdk/EventDPDK.h
+++ b/src/msg/async/dpdk/EventDPDK.h
@@ -26,7 +26,7 @@ class DPDKDriver : public EventDriver {
public:
UserspaceEventManager manager;
- DPDKDriver(CephContext *c): cct(c), manager(c) {}
+ explicit DPDKDriver(CephContext *c): cct(c), manager(c) {}
virtual ~DPDKDriver() { }
int init(EventCenter *c, int nevent) override;
diff --git a/src/msg/async/dpdk/Packet.h b/src/msg/async/dpdk/Packet.h
index 3daab3172d0..b22492db865 100644
--- a/src/msg/async/dpdk/Packet.h
+++ b/src/msg/async/dpdk/Packet.h
@@ -104,7 +104,7 @@ class Packet {
fragment frags[];
- impl(size_t nr_frags = default_nr_frags);
+ explicit impl(size_t nr_frags = default_nr_frags);
impl(const impl&) = delete;
impl(fragment frag, size_t nr_frags = default_nr_frags);
@@ -180,7 +180,7 @@ class Packet {
to->frags[0].base);
}
};
- Packet(std::unique_ptr<impl>&& impl) : _impl(std::move(impl)) {}
+ explicit Packet(std::unique_ptr<impl>&& impl) : _impl(std::move(impl)) {}
std::unique_ptr<impl> _impl;
public:
static Packet from_static_data(const char* data, size_t len) {
@@ -190,13 +190,13 @@ public:
// build empty Packet
Packet();
// build empty Packet with nr_frags allocated
- Packet(size_t nr_frags);
+ explicit Packet(size_t nr_frags);
// move existing Packet
Packet(Packet&& x) noexcept;
// copy data into Packet
Packet(const char* data, size_t len);
// copy data into Packet
- Packet(fragment frag);
+ explicit Packet(fragment frag);
// zero-copy single fragment
Packet(fragment frag, deleter del);
// zero-copy multiple fragments
diff --git a/src/msg/async/dpdk/UserspaceEvent.h b/src/msg/async/dpdk/UserspaceEvent.h
index 1a725a667d8..75f3abf78ab 100644
--- a/src/msg/async/dpdk/UserspaceEvent.h
+++ b/src/msg/async/dpdk/UserspaceEvent.h
@@ -46,7 +46,7 @@ class UserspaceEventManager {
std::list<uint32_t> unused_fds;
public:
- UserspaceEventManager(CephContext *c): cct(c) {
+ explicit UserspaceEventManager(CephContext *c): cct(c) {
waiting_fds.resize(1024);
}
diff --git a/src/msg/async/dpdk/ethernet.h b/src/msg/async/dpdk/ethernet.h
index 17546d73a10..4efd9416cf2 100644
--- a/src/msg/async/dpdk/ethernet.h
+++ b/src/msg/async/dpdk/ethernet.h
@@ -32,11 +32,11 @@
struct ethernet_address {
ethernet_address() {}
- ethernet_address(const uint8_t *eaddr) {
+ explicit ethernet_address(const uint8_t *eaddr) {
std::copy(eaddr, eaddr + 6, mac.begin());
}
- ethernet_address(std::initializer_list<uint8_t> eaddr) {
+ explicit ethernet_address(std::initializer_list<uint8_t> eaddr) {
assert(eaddr.size() == mac.size());
std::copy(eaddr.begin(), eaddr.end(), mac.begin());
}
diff --git a/src/msg/async/dpdk/net.h b/src/msg/async/dpdk/net.h
index c48815b8d33..53ef473cf95 100644
--- a/src/msg/async/dpdk/net.h
+++ b/src/msg/async/dpdk/net.h
@@ -105,7 +105,7 @@ class interface {
stream<Packet, ethernet_address> packet_stream;
std::function<bool (forward_hash&, Packet&, size_t)> forward;
bool ready() { return packet_stream.started(); }
- l3_rx_stream(std::function<bool (forward_hash&, Packet&, size_t)>&& fw) : forward(fw) {}
+ explicit l3_rx_stream(std::function<bool (forward_hash&, Packet&, size_t)>&& fw) : forward(fw) {}
};
std::unordered_map<uint16_t, l3_rx_stream> _proto_map;
std::shared_ptr<DPDKDevice> _dev;