summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2018-03-27 17:37:24 +0200
committerUlf Hermann <ulf.hermann@qt.io>2018-04-17 09:24:08 +0000
commit32c54dfdac7663897de1c88954307d46d4128537 (patch)
tree0262e9c4b5d0551cd0719ef94bd30f0a1449bfc0
parente0ba6f91ceac6e1fed5b143d39cebffc78f07245 (diff)
downloadqt-creator-32c54dfdac7663897de1c88954307d46d4128537.tar.gz
QmlProfiler: Fix some number conversion issues
Qt containers have int as size type, while std containers have size_t. We can use auto and decltype to deal with this. Also, memcpy and malloc expect size_t, not int. Change-Id: Id2942d14978c8a15f72967962d551ddb20905471 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
-rw-r--r--src/plugins/qmlprofiler/qmlevent.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/plugins/qmlprofiler/qmlevent.h b/src/plugins/qmlprofiler/qmlevent.h
index 9c680e95bb..5f17d202f4 100644
--- a/src/plugins/qmlprofiler/qmlevent.h
+++ b/src/plugins/qmlprofiler/qmlevent.h
@@ -240,7 +240,7 @@ private:
void assignData(const QmlEvent &other)
{
if (m_dataType & External) {
- int length = m_dataLength * (other.m_dataType / 8);
+ size_t length = m_dataLength * (other.m_dataType / 8);
m_data.external = malloc(length);
memcpy(m_data.external, other.m_data.external, length);
} else {
@@ -278,8 +278,9 @@ private:
void assignNumbers(const Container &numbers)
{
Number *data;
- m_dataLength = squeezable<size_t, quint16>(numbers.size()) ?
- static_cast<quint16>(numbers.size()) : std::numeric_limits<quint16>::max();
+ const auto size = numbers.size();
+ m_dataLength = squeezable<decltype(size), quint16>(size) ?
+ static_cast<quint16>(size) : std::numeric_limits<quint16>::max();
if (m_dataLength > sizeof(m_data) / sizeof(Number)) {
if (squeeze<Container, Number>(numbers))
return;