From 579fbc8d5b120242d42a7177dc276c974995ecfa Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Fri, 29 Jan 2016 17:19:33 +0100 Subject: [PATCH] add some cppcheck-suppress noExplicitConstructor comments Signed-off-by: Danny Al-Gaaf --- src/common/DecayCounter.h | 1 + src/common/WorkQueue.h | 1 + src/common/buffer.cc | 1 + src/include/buffer.h | 4 ++++ src/include/object.h | 3 +++ src/include/types.h | 8 ++++++++ src/mon/MonCap.h | 3 +++ src/msg/msg_types.h | 1 + src/osd/OSD.h | 1 + src/osd/OSDCap.h | 1 + src/osd/PGLog.h | 1 + src/osd/osd_types.h | 4 ++++ src/rgw/rgw_basic_types.h | 1 + src/rgw/rgw_common.h | 4 ++++ src/test/objectstore_bench.cc | 1 + 15 files changed, 35 insertions(+) diff --git a/src/common/DecayCounter.h b/src/common/DecayCounter.h index 529e50a30b3de..5abbeb394b39d 100644 --- a/src/common/DecayCounter.h +++ b/src/common/DecayCounter.h @@ -35,6 +35,7 @@ class DecayRate { public: DecayRate() : k(0) {} + // cppcheck-suppress noExplicitConstructor DecayRate(double hl) { set_halflife(hl); } void set_halflife(double hl) { k = ::log(.5) / hl; diff --git a/src/common/WorkQueue.h b/src/common/WorkQueue.h index 67c1a87b783b8..097942af4ff90 100644 --- a/src/common/WorkQueue.h +++ b/src/common/WorkQueue.h @@ -443,6 +443,7 @@ private: // threads struct WorkThread : public Thread { ThreadPool *pool; + // cppcheck-suppress noExplicitConstructor WorkThread(ThreadPool *p) : pool(p) {} void *entry() { pool->worker(this); diff --git a/src/common/buffer.cc b/src/common/buffer.cc index bd97b01cd88f3..cbb9549c3e340 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -176,6 +176,7 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; virtual ~raw() {} // no copying. + // cppcheck-suppress noExplicitConstructor raw(const raw &other); const raw& operator=(const raw &other); diff --git a/src/include/buffer.h b/src/include/buffer.h index 5a8b05f5125f9..9bbe79d039aca 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -168,7 +168,9 @@ namespace buffer CEPH_BUFFER_API { public: ptr() : _raw(0), _off(0), _len(0) {} + // cppcheck-suppress noExplicitConstructor ptr(raw *r); + // cppcheck-suppress noExplicitConstructor ptr(unsigned l); ptr(const char *d, unsigned l); ptr(const ptr& p); @@ -354,6 +356,7 @@ namespace buffer CEPH_BUFFER_API { public: // cons/des list() : _len(0), _memcopy_count(0), last_p(this) {} + // cppcheck-suppress noExplicitConstructor list(unsigned prealloc) : _len(0), _memcopy_count(0), last_p(this) { append_buffer = buffer::create(prealloc); append_buffer.set_length(0); // unused, so far. @@ -543,6 +546,7 @@ namespace buffer CEPH_BUFFER_API { public: hash() : crc(0) { } + // cppcheck-suppress noExplicitConstructor hash(uint32_t init) : crc(init) { } void update(buffer::list& bl) { diff --git a/src/include/object.h b/src/include/object.h index 0f511435b9b64..bdc15b52cbc2c 100644 --- a/src/include/object.h +++ b/src/include/object.h @@ -33,7 +33,9 @@ struct object_t { string name; object_t() {} + // cppcheck-suppress noExplicitConstructor object_t(const char *s) : name(s) {} + // cppcheck-suppress noExplicitConstructor object_t(const string& s) : name(s) {} void swap(object_t& o) { @@ -110,6 +112,7 @@ struct file_object_t { struct snapid_t { uint64_t val; + // cppcheck-suppress noExplicitConstructor snapid_t(uint64_t v=0) : val(v) {} snapid_t operator+=(snapid_t o) { val += o.val; return *this; } snapid_t operator++() { ++val; return *this; } diff --git a/src/include/types.h b/src/include/types.h index aebdc5237f7bb..19982db6d2a1e 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -280,6 +280,7 @@ typedef __u32 epoch_t; // map epoch (32bits -> 13 epochs/second for 10 ye struct client_t { int64_t v; + // cppcheck-suppress noExplicitConstructor client_t(int64_t _v = -2) : v(_v) {} void encode(bufferlist& bl) const { @@ -315,6 +316,7 @@ typedef uint64_t _inodeno_t; struct inodeno_t { _inodeno_t val; inodeno_t() : val(0) {} + // cppcheck-suppress noExplicitConstructor inodeno_t(_inodeno_t v) : val(v) {} inodeno_t operator+=(inodeno_t o) { val += o.val; return *this; } operator _inodeno_t() const { return val; } @@ -366,6 +368,7 @@ void dump(const ceph_dir_layout& l, ceph::Formatter *f); struct prettybyte_t { uint64_t v; + // cppcheck-suppress noExplicitConstructor prettybyte_t(uint64_t _v) : v(_v) {} }; @@ -389,6 +392,7 @@ inline ostream& operator<<(ostream& out, const prettybyte_t& b) struct si_t { uint64_t v; + // cppcheck-suppress noExplicitConstructor si_t(uint64_t _v) : v(_v) {} }; @@ -412,6 +416,7 @@ inline ostream& operator<<(ostream& out, const si_t& b) struct pretty_si_t { uint64_t v; + // cppcheck-suppress noExplicitConstructor pretty_si_t(uint64_t _v) : v(_v) {} }; @@ -435,6 +440,7 @@ inline ostream& operator<<(ostream& out, const pretty_si_t& b) struct kb_t { uint64_t v; + // cppcheck-suppress noExplicitConstructor kb_t(uint64_t _v) : v(_v) {} }; @@ -483,6 +489,7 @@ inline ostream& operator<<(ostream &oss, health_status_t status) { struct weightf_t { float v; + // cppcheck-suppress noExplicitConstructor weightf_t(float _v) : v(_v) {} }; @@ -530,6 +537,7 @@ struct errorcode32_t { int32_t code; errorcode32_t() {} + // cppcheck-suppress noExplicitConstructor errorcode32_t(int32_t i) : code(i) {} operator int() const { return code; } diff --git a/src/mon/MonCap.h b/src/mon/MonCap.h index 400a4bbbe3ecd..2501f442af6c3 100644 --- a/src/mon/MonCap.h +++ b/src/mon/MonCap.h @@ -21,6 +21,7 @@ static const __u8 MON_CAP_ANY = 0xff; // * struct mon_rwxa_t { __u8 val; + // cppcheck-suppress noExplicitConstructor mon_rwxa_t(__u8 v = 0) : val(v) {} mon_rwxa_t& operator=(__u8 v) { val = v; @@ -79,8 +80,10 @@ struct MonCapGrant { void expand_profile(EntityName name) const; MonCapGrant() : allow(0) {} + // cppcheck-suppress noExplicitConstructor MonCapGrant(mon_rwxa_t a) : allow(a) {} MonCapGrant(string s, mon_rwxa_t a) : service(s), allow(a) {} + // cppcheck-suppress noExplicitConstructor MonCapGrant(string c) : command(c) {} MonCapGrant(string c, string a, StringConstraint co) : command(c) { command_args[a] = co; diff --git a/src/msg/msg_types.h b/src/msg/msg_types.h index 55a865b7454ba..3acad775ff733 100644 --- a/src/msg/msg_types.h +++ b/src/msg/msg_types.h @@ -424,6 +424,7 @@ struct entity_inst_t { entity_addr_t addr; entity_inst_t() {} entity_inst_t(entity_name_t n, const entity_addr_t& a) : name(n), addr(a) {} + // cppcheck-suppress noExplicitConstructor entity_inst_t(const ceph_entity_inst& i) : name(i.name), addr(i.addr) { } entity_inst_t(const ceph_entity_name& n, const ceph_entity_addr &a) : name(n), addr(a) {} operator ceph_entity_inst() { diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 9e149032a4ad7..7561d133f71f2 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -364,6 +364,7 @@ class PGQueueable { void operator()(PGScrub &op); }; public: + // cppcheck-suppress noExplicitConstructor PGQueueable(OpRequestRef op) : qvariant(op), cost(op->get_req()->get_cost()), priority(op->get_req()->get_priority()), diff --git a/src/osd/OSDCap.h b/src/osd/OSDCap.h index 55f362692fc09..55d7e9cc65b3a 100644 --- a/src/osd/OSDCap.h +++ b/src/osd/OSDCap.h @@ -42,6 +42,7 @@ static const __u8 OSD_CAP_ANY = 0xff; // * struct osd_rwxa_t { __u8 val; + // cppcheck-suppress noExplicitConstructor osd_rwxa_t(__u8 v = 0) : val(v) {} osd_rwxa_t& operator=(__u8 v) { val = v; diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h index 87e7ab26bbc05..3a9b6979125a2 100644 --- a/src/osd/PGLog.h +++ b/src/osd/PGLog.h @@ -478,6 +478,7 @@ protected: check(); } public: + // cppcheck-suppress noExplicitConstructor PGLog(CephContext *cct = 0) : dirty_from(eversion_t::max()), writeout_from(eversion_t::max()), diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 5b1330608c1b9..84770d3e92afb 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -303,9 +303,11 @@ struct pg_t { pg_t() : m_pool(0), m_seed(0), m_preferred(-1) {} pg_t(ps_t seed, uint64_t pool, int pref=-1) : m_pool(pool), m_seed(seed), m_preferred(pref) {} + // cppcheck-suppress noExplicitConstructor pg_t(const ceph_pg& cpg) : m_pool(cpg.pool), m_seed(cpg.ps), m_preferred((__s16)cpg.preferred) {} + // cppcheck-suppress noExplicitConstructor pg_t(const old_pg_t& opg) { *this = opg.v; } @@ -712,6 +714,7 @@ public: eversion_t() : version(0), epoch(0), __pad(0) {} eversion_t(epoch_t e, version_t v) : version(v), epoch(e), __pad(0) {} + // cppcheck-suppress noExplicitConstructor eversion_t(const ceph_eversion& ce) : version(ce.version), epoch(ce.epoch), @@ -2100,6 +2103,7 @@ struct pg_info_t { last_backfill(hobject_t::get_max()), last_backfill_bitwise(false) { } + // cppcheck-suppress noExplicitConstructor pg_info_t(spg_t p) : pgid(p), last_epoch_started(0), last_user_version(0), diff --git a/src/rgw/rgw_basic_types.h b/src/rgw/rgw_basic_types.h index 4a9c42cbe103e..8538af643705f 100644 --- a/src/rgw/rgw_basic_types.h +++ b/src/rgw/rgw_basic_types.h @@ -10,6 +10,7 @@ struct rgw_user { std::string id; rgw_user() {} + // cppcheck-suppress noExplicitConstructor rgw_user(const std::string& s) { from_str(s); } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 302767eb14c53..85405de51fcb4 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -622,10 +622,12 @@ struct rgw_bucket { */ rgw_bucket() { } + // cppcheck-suppress noExplicitConstructor rgw_bucket(const cls_user_bucket& b) : name(b.name), data_pool(b.data_pool), data_extra_pool(b.data_extra_pool), index_pool(b.index_pool), marker(b.marker), bucket_id(b.bucket_id) {} + // cppcheck-suppress noExplicitConstructor rgw_bucket(const char *n) : name(n) { assert(*n == '.'); // only rgw private buckets should be initialized without pool data_pool = index_pool = n; @@ -986,6 +988,7 @@ struct rgw_obj_key { string instance; rgw_obj_key() {} + // cppcheck-suppress noExplicitConstructor rgw_obj_key(const string& n) { set(n); } @@ -993,6 +996,7 @@ struct rgw_obj_key { set(n, i); } + // cppcheck-suppress noExplicitConstructor rgw_obj_key(const cls_rgw_obj_key& k) { set(k); } diff --git a/src/test/objectstore_bench.cc b/src/test/objectstore_bench.cc index 9754cecf999f2..d8cd16675b9ed 100644 --- a/src/test/objectstore_bench.cc +++ b/src/test/objectstore_bench.cc @@ -36,6 +36,7 @@ static void usage() // helper class for bytes with units struct byte_units { size_t v; + // cppcheck-suppress noExplicitConstructor byte_units(size_t v) : v(v) {} bool parse(const std::string &val, std::string *err); -- 2.39.5