Skip to content

Commit 434e5a0

Browse files
committed
Removed -Wconversion warnings in part of framework
Primarily did lowest level packages such as most DataFormats maintained by Core and FWCore/Utilities.
1 parent 69407d5 commit 434e5a0

File tree

120 files changed

+468
-454
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+468
-454
lines changed

DataFormats/Common/interface/Association.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ namespace edm {
4343
size_t k = i;
4444
if (k >= ref_->size())
4545
throwIndexMapBound();
46-
return reference_type(ref_, k);
46+
return reference_type(ref_, static_cast<typename reference_type::key_type>(k));
4747
}
4848

4949
reference_type get(ProductID id, size_t idx) const { return get(rawIndexOf(id, idx)); }

DataFormats/Common/interface/AssociationMap.h

+11-12
Original file line numberDiff line numberDiff line change
@@ -175,31 +175,31 @@ namespace edm {
175175
const_iterator find(const key_type& k) const {
176176
if (ref_.key.id() != k.id())
177177
return end();
178-
return find(k.key());
178+
return find(static_cast<index_type>(k.key()));
179179
}
180180
/// erase the element whose key is k
181181
size_type erase(const key_type& k) {
182-
index_type i = k.key();
182+
index_type i = static_cast<index_type>(k.key());
183183
transientMap_.unsafe_erase(i);
184184
return map_.erase(i);
185185
}
186186
/// find element with specified reference key
187187
const result_type& operator[](const key_type& k) const {
188188
helpers::checkRef(ref_.key, k);
189-
return get(k.key()).val;
189+
return get(static_cast<index_type>(k.key())).val;
190190
}
191191

192192
template <typename K>
193193
const result_type& operator[](const K& k) const {
194194
helpers::checkRef(ref_.key, k);
195-
return get(k.key()).val;
195+
return get(static_cast<index_type>(k.key())).val;
196196
}
197197

198198
/// number of associations to a key
199199
size_type numberOfAssociations(const key_type& k) const {
200200
if (ref_.key.id() != k.id())
201201
return 0;
202-
typename map_type::const_iterator f = map_.find(k.key());
202+
auto f = map_.find(static_cast<index_type>(k.key()));
203203
if (f == map_.end())
204204
return 0;
205205
return Tag::size(f->second);
@@ -252,22 +252,21 @@ namespace edm {
252252
/// transient reference map
253253
mutable internal_transient_map_type transientMap_;
254254
/// find element with index i
255-
const_iterator find(size_type i) const {
256-
typename map_type::const_iterator f = map_.find(i);
255+
const_iterator find(index_type i) const {
256+
auto f = map_.find(i);
257257
if (f == map_.end())
258258
return end();
259259
return const_iterator(this, f);
260260
}
261261
/// return value_typeelement with key i
262-
const value_type& get(size_type i) const {
263-
typename internal_transient_map_type::const_iterator tf = transientMap_.find(i);
262+
const value_type& get(index_type i) const {
263+
auto tf = transientMap_.find(i);
264264
if (tf == transientMap_.end()) {
265-
typename map_type::const_iterator f = map_.find(i);
265+
auto f = map_.find(i);
266266
if (f == map_.end())
267267
Exception::throwThis(edm::errors::InvalidReference, "can't find reference in AssociationMap at position ", i);
268268
value_type v(key_type(ref_.key, i), Tag::val(ref_, f->second));
269-
std::pair<typename internal_transient_map_type::const_iterator, bool> ins =
270-
transientMap_.insert(std::make_pair(i, v));
269+
auto ins = transientMap_.insert(std::make_pair(i, v));
271270
return ins.first->second;
272271
} else {
273272
return tf->second;

DataFormats/Common/interface/AssociationVector.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ namespace edm {
225225
template <typename KeyRefProd, typename CVal, typename KeyRef, typename SizeType, typename KeyReferenceHelper>
226226
inline typename AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::size_type
227227
AssociationVector<KeyRefProd, CVal, KeyRef, SizeType, KeyReferenceHelper>::size() const {
228-
return data_.size();
228+
return static_cast<size_type>(data_.size());
229229
}
230230

231231
template <typename KeyRefProd, typename CVal, typename KeyRef, typename SizeType, typename KeyReferenceHelper>

DataFormats/Common/interface/ContainerMask.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace edm {
7979

8080
template <typename T>
8181
bool ContainerMask<T>::mask(const typename ContainerMaskTraits<T>::value_type* iElement) {
82-
unsigned int index = ContainerMaskTraits<T>::indexFor(iElement, m_prod.product());
82+
auto index = ContainerMaskTraits<T>::indexFor(iElement, m_prod.product());
8383
return this->mask(index);
8484
}
8585

DataFormats/Common/interface/ContainerMaskTraits.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace edm {
3232

3333
static size_t size(const T* iContainer) { return iContainer->size(); }
3434
static unsigned int indexFor(const value_type* iElement, const T* iContainer) {
35-
return iElement - &(iContainer->front());
35+
return static_cast<unsigned int>(iElement - &(iContainer->front()));
3636
}
3737

3838
ContainerMaskTraits() = delete;

DataFormats/Common/interface/DataFrameContainer.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ namespace edm {
6363
DataFrameContainer() : m_subdetId(0), m_stride(0), m_ids(), m_data() {}
6464

6565
explicit DataFrameContainer(size_t istride, int isubdet = 0, size_t isize = 0)
66-
: m_subdetId(isubdet), m_stride(istride), m_ids(isize), m_data(isize * m_stride) {}
66+
: m_subdetId(isubdet), m_stride(static_cast<size_type>(istride)), m_ids(isize), m_data(isize * m_stride) {}
6767

6868
void swap(DataFrameContainer& rh) {
6969
std::swap(m_subdetId, rh.m_subdetId);
@@ -126,17 +126,17 @@ namespace edm {
126126

127127
const_IterPair pair(size_t i) const { return const_IterPair(m_ids.begin() + i, m_data.begin() + i * m_stride); }
128128

129-
DataFrame operator[](size_t i) { return DataFrame(*this, i); }
129+
DataFrame operator[](size_t i) { return DataFrame(*this, static_cast<DataFrame::size_type>(i)); }
130130

131-
DataFrame operator[](size_t i) const { return DataFrame(*this, i); }
131+
DataFrame operator[](size_t i) const { return DataFrame(*this, static_cast<DataFrame::size_type>(i)); }
132132

133133
/// slow interface
134134
/// The iterator returned can not safely be used across threads
135135
const_iterator find(id_type i) const {
136136
const_IdIter p = std::lower_bound(m_ids.begin(), m_ids.end(), i);
137137
return (p == m_ids.end() || (*p) != i)
138138
? end()
139-
: boost::make_transform_iterator(boost::counting_iterator<int>(p - m_ids.begin()), IterHelp(*this));
139+
: boost::make_transform_iterator(boost::counting_iterator<int>(static_cast<int>(p - m_ids.begin())), IterHelp(*this));
140140
}
141141

142142
/// The iterator returned can not safely be used across threads
@@ -153,7 +153,7 @@ namespace edm {
153153

154154
bool empty() const { return m_ids.empty(); }
155155

156-
size_type size() const { return m_ids.size(); }
156+
size_type size() const { return static_cast<size_type>(m_ids.size()); }
157157

158158
data_type operator()(size_t cell, size_t frame) const { return m_data[cell * m_stride + frame]; }
159159

DataFormats/Common/interface/DetSetVectorNew.h

+11-11
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ namespace edmNew {
256256
void resize(size_type s) {
257257
checkCapacityExausted(s);
258258
m_v.m_data.resize(m_item.offset + s);
259-
m_v.m_dataSize = m_v.m_data.size();
259+
m_v.m_dataSize = static_cast<unsigned int>(m_v.m_data.size());
260260
m_item.size = s;
261261
}
262262

@@ -329,16 +329,16 @@ namespace edmNew {
329329
expected = false;
330330
nanosleep(nullptr, nullptr);
331331
}
332-
int offset = m_v.m_data.size();
332+
int offset = static_cast<int>(m_v.m_data.size());
333333
if (m_v.onDemand() && full()) {
334334
m_v.m_filling = false;
335335
dstvdetails::throwCapacityExausted();
336336
}
337337
std::move(m_lv.begin(), m_lv.end(), std::back_inserter(m_v.m_data));
338-
m_item.size = m_lv.size();
338+
m_item.size = static_cast<size_type>(m_lv.size());
339339
m_item.offset = offset;
340340

341-
m_v.m_dataSize = m_v.m_data.size();
341+
m_v.m_dataSize = static_cast<unsigned int>(m_v.m_data.size());
342342
assert(m_v.m_filling == true);
343343
m_v.m_filling = false;
344344
}
@@ -355,7 +355,7 @@ namespace edmNew {
355355
void resize(size_type s) { m_lv.resize(s); }
356356

357357
id_type id() const { return m_item.id; }
358-
size_type size() const { return m_lv.size(); }
358+
size_type size() const { return static_cast<size_type>(m_lv.size()); }
359359
bool empty() const { return m_lv.empty(); }
360360

361361
data_type& operator[](size_type i) { return m_lv[i]; }
@@ -451,7 +451,7 @@ namespace edmNew {
451451
void resize(size_t isize, size_t dsize) {
452452
m_ids.resize(isize);
453453
m_data.resize(dsize);
454-
m_dataSize = m_data.size();
454+
m_dataSize = static_cast<unsigned int>(m_data.size());
455455
}
456456

457457
void clean() {
@@ -463,14 +463,14 @@ namespace edmNew {
463463
Item& item = addItem(iid, isize);
464464
m_data.resize(m_data.size() + isize);
465465
std::copy(idata, idata + isize, m_data.begin() + item.offset);
466-
m_dataSize = m_data.size();
466+
m_dataSize = static_cast<unsigned int>(m_data.size());
467467
return DetSet(*this, item, false);
468468
}
469469
//make space for it
470470
DetSet insert(id_type iid, size_type isize) {
471471
Item& item = addItem(iid, isize);
472472
m_data.resize(m_data.size() + isize);
473-
m_dataSize = m_data.size();
473+
m_dataSize = static_cast<unsigned int>(m_data.size());
474474
return DetSet(*this, item, false);
475475
}
476476

@@ -485,7 +485,7 @@ namespace edmNew {
485485
// sanity checks... (shall we throw or assert?)
486486
if ((*p).isValid() && (*p).size > 0 && m_data.size() == (*p).offset + (*p).size) {
487487
m_data.resize((*p).offset);
488-
m_dataSize = m_data.size();
488+
m_dataSize = static_cast<size_type>(m_data.size());
489489
}
490490
m_ids.erase(m_ids.begin() + (p - m_ids.begin()));
491491
}
@@ -562,7 +562,7 @@ namespace edmNew {
562562

563563
size_type dataSize() const { return onDemand() ? size_type(m_dataSize) : size_type(m_data.size()); }
564564

565-
size_type size() const { return m_ids.size(); }
565+
size_type size() const { return static_cast<size_type>(m_ids.size()); }
566566

567567
//FIXME fast interfaces, not consistent with associative nature of container....
568568

@@ -718,7 +718,7 @@ namespace edm {
718718

719719
static size_t size(const edmNew::DetSetVector<T>* iContainer) { return iContainer->dataSize(); }
720720
static unsigned int indexFor(const value_type* iElement, const edmNew::DetSetVector<T>* iContainer) {
721-
return iElement - &(iContainer->data().front());
721+
return static_cast<unsigned int>(iElement - &(iContainer->data().front()));
722722
}
723723
};
724724
} // namespace edm

DataFormats/Common/interface/HLTGlobalStatus.h

+18-16
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ namespace edm {
3030
std::vector<HLTPathStatus> paths_;
3131

3232
public:
33+
using size_type = decltype(paths_)::size_type;
34+
3335
/// Constructor - for n paths
34-
HLTGlobalStatus(const unsigned int n = 0) : paths_(n) {}
36+
HLTGlobalStatus(size_type n = 0) : paths_(n) {}
3537

3638
/// Get number of paths stored
37-
unsigned int size() const { return paths_.size(); }
39+
auto size() const { return paths_.size(); }
3840

3941
/// Reset status for all paths
4042
void reset() {
41-
const unsigned int n(size());
42-
for (unsigned int i = 0; i != n; ++i)
43+
const auto n(size());
44+
for (decltype(size()) i = 0; i != n; ++i)
4345
paths_[i].reset();
4446
}
4547

@@ -54,32 +56,32 @@ namespace edm {
5456

5557
// accessors to ith element of paths_
5658

57-
const HLTPathStatus& at(const unsigned int i) const { return paths_.at(i); }
58-
HLTPathStatus& at(const unsigned int i) { return paths_.at(i); }
59-
const HLTPathStatus& operator[](const unsigned int i) const { return paths_[i]; }
60-
HLTPathStatus& operator[](const unsigned int i) { return paths_[i]; }
59+
const HLTPathStatus& at(size_type i) const { return paths_.at(i); }
60+
HLTPathStatus& at(size_type i) { return paths_.at(i); }
61+
const HLTPathStatus& operator[](size_type i) const { return paths_[i]; }
62+
HLTPathStatus& operator[](size_type i) { return paths_[i]; }
6163

6264
/// Was ith path run?
63-
bool wasrun(const unsigned int i) const { return at(i).wasrun(); }
65+
bool wasrun(size_type i) const { return at(i).wasrun(); }
6466
/// Has ith path accepted the event?
65-
bool accept(const unsigned int i) const { return at(i).accept(); }
67+
bool accept(size_type i) const { return at(i).accept(); }
6668
/// Has ith path encountered an error (exception)?
67-
bool error(const unsigned int i) const { return at(i).error(); }
69+
bool error(size_type i) const { return at(i).error(); }
6870

6971
/// Get status of ith path
70-
hlt::HLTState state(const unsigned int i) const { return at(i).state(); }
72+
hlt::HLTState state(size_type i) const { return at(i).state(); }
7173
/// Get index (slot position) of module giving the decision of the ith path
72-
unsigned int index(const unsigned int i) const { return at(i).index(); }
74+
unsigned int index(size_type i) const { return at(i).index(); }
7375
/// Reset the ith path
74-
void reset(const unsigned int i) { at(i).reset(); }
76+
void reset(size_type i) { at(i).reset(); }
7577
/// swap function
7678
void swap(HLTGlobalStatus& other) { paths_.swap(other.paths_); }
7779

7880
private:
7981
/// Global state variable calculated on the fly
8082
bool State(unsigned int icase) const {
8183
bool flags[3] = {false, false, false};
82-
const unsigned int n(size());
84+
const auto n(size());
8385
for (unsigned int i = 0; i != n; ++i) {
8486
const hlt::HLTState s(state(i));
8587
if (s != hlt::Ready) {
@@ -105,7 +107,7 @@ namespace edm {
105107
text[1] = "1";
106108
text[2] = "0";
107109
text[3] = "e";
108-
const unsigned int n(hlt.size());
110+
const auto n(hlt.size());
109111
for (unsigned int i = 0; i != n; ++i)
110112
ost << text[hlt.state(i)];
111113
return ost;

DataFormats/Common/interface/HLTPathStatus.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ namespace edm {
3939

4040
public:
4141
/// constructor
42-
HLTPathStatus(const hlt::HLTState state = hlt::Ready, const unsigned int index = 0) : status_(index * 4 + state) {
42+
HLTPathStatus(const hlt::HLTState state = hlt::Ready, const unsigned int index = 0)
43+
: status_(static_cast<uint16_t>(index * 4 + state)) {
4344
assert(((int)state) < 4);
4445
assert(index < 16384);
4546
}

DataFormats/Common/interface/MapOfVectors.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace edm {
7676
m_keys.reserve(it.size());
7777
m_offsets.reserve(it.size() + 1);
7878
m_offsets.push_back(0);
79-
size_type tot = 0;
79+
size_t tot = 0;
8080
for (typename TheMap::const_iterator p = it.begin(); p != it.end(); ++p)
8181
tot += (*p).second.size();
8282
m_data.reserve(tot);
@@ -88,10 +88,10 @@ namespace edm {
8888
m_keys.push_back(k);
8989
m_data.resize(m_offsets.back() + v.size());
9090
std::copy(v.begin(), v.end(), m_data.begin() + m_offsets.back());
91-
m_offsets.push_back(m_data.size());
91+
m_offsets.push_back(static_cast<unsigned int>(m_data.size()));
9292
}
9393

94-
size_type size() const { return m_keys.size(); }
94+
size_type size() const { return static_cast<size_type>(m_keys.size()); }
9595

9696
bool empty() const { return m_keys.empty(); }
9797

@@ -111,7 +111,7 @@ namespace edm {
111111
key_iterator p = findKey(k);
112112
if (p == m_keys.end())
113113
return emptyRange();
114-
size_type loc = p - m_keys.begin();
114+
auto loc = p - m_keys.begin();
115115
data_iterator b = m_data.begin() + m_offsets[loc];
116116
data_iterator e = m_data.begin() + m_offsets[loc + 1];
117117
return range(b, e);

0 commit comments

Comments
 (0)