summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-07-21 11:24:17 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-07-31 08:00:11 -0700
commitf1457b7b4742a3903b441d04c12cf500038f80b8 (patch)
treea2368b07922293708f5db4bf001e434cf92eeb3e /tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
parente9c9e9225c333799258bb75c98f8722e074f272e (diff)
tst_QMetaType: fix warning that buffer may be unused
We pass a pointer to uninitialized memory to QMetaType::create(). There's no harm because we're using the invalid QMetaType, but GCC is actually right to complain for any other type. qtestcase.h:54:25: warning: ‘buf’ may be used uninitialized [-Wmaybe-uninitialized] qmetatype.h:454:11: note: by argument 2 of type ‘const void*’ to ‘void* QMetaType::create(const void*) const’ declared here Pick-to: 6.3 6.4 Change-Id: I3859764fed084846bcb0fffd1703eb7967acf0d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp')
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index dc7936cb23..4565e78985 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -817,7 +817,7 @@ void tst_QMetaType::createCopy()
switch (type) {
case QMetaType::UnknownType:
return []() {
- char buf[1];
+ char buf[1] = {};
QCOMPARE(QMetaType().create(&buf), nullptr);
};
#define RETURN_CREATE_COPY_FUNCTION(MetaTypeName, MetaTypeId, RealType) \
@@ -1412,7 +1412,7 @@ void tst_QMetaType::constructCopy()
switch (type) {
case QMetaType::UnknownType:
return []() {
- char buf[1], buf2[1];
+ char buf[1], buf2[1] = {};
QCOMPARE(QMetaType().construct(&buf, &buf2), nullptr);
};
#define RETURN_CONSTRUCT_COPY_FUNCTION(MetaTypeName, MetaTypeId, RealType) \