summaryrefslogtreecommitdiffstats
path: root/src/serialbus/qmodbuspdu.h
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@theqtcompany.com>2016-03-21 10:50:47 +0100
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2016-03-22 09:36:05 +0000
commitf94520d69da7701d0e82fccbe06b16e6c022bc23 (patch)
tree863424eb1f54621fa39f42d3f674f533b0f11049 /src/serialbus/qmodbuspdu.h
parent8a5a904441a9a60ab711721a0a6acd8089e74a79 (diff)
Replace hard-coded array size with real argument count.
Change-Id: If767a1526958a86df258e21215c70389d016abd3 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/serialbus/qmodbuspdu.h')
-rw-r--r--src/serialbus/qmodbuspdu.h7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/serialbus/qmodbuspdu.h b/src/serialbus/qmodbuspdu.h
index ac85b76..19a2d45 100644
--- a/src/serialbus/qmodbuspdu.h
+++ b/src/serialbus/qmodbuspdu.h
@@ -160,9 +160,10 @@ private:
template<typename ... Args> void encode(Args ... newData) {
m_data.clear();
- if (sizeof...(Args)) {
+ Q_CONSTEXPR quint32 argCount = sizeof...(Args);
+ if (argCount > 0) {
QDataStream stream(&m_data, QIODevice::WriteOnly);
- char tmp[1024] = { (encode(&stream, newData), void(), '0')... };
+ char tmp[argCount] = { (encode(&stream, newData), void(), '0')... };
Q_UNUSED(tmp)
}
}
@@ -170,7 +171,7 @@ private:
Q_CONSTEXPR quint32 argCount = sizeof...(Args);
if (argCount > 0 && !m_data.isEmpty()) {
QDataStream stream(m_data);
- char tmp[1024] = { (decode(&stream, newData), void(), '0')... };
+ char tmp[argCount] = { (decode(&stream, newData), void(), '0')... };
Q_UNUSED(tmp)
}
}