aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2024-06-18 13:10:15 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2024-06-24 10:36:15 +0200
commitd326e40e8c52c9f74b6baa0d6f7f9a54ded0172a (patch)
treea459a06eafb612cd51fbff447f63b4e1b9772422 /sources/pyside6
parent1a4593f940b0eca4d0756092ed34c2b6a6962bd6 (diff)
libpysideqml: Fix static analysis warnings
- Initialize variables - Use auto * - Use nullptr - Remove repeated return types - Minor cleanups Change-Id: I26cacce81a4c8ebc885f8c34d59fdac5d0026af9 Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlattached.cpp6
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlextended.cpp2
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlforeign.cpp4
-rw-r--r--sources/pyside6/libpysideqml/pysideqmllistproperty.cpp6
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp4
-rw-r--r--sources/pyside6/libpysideqml/pysideqmlregistertype.cpp18
6 files changed, 21 insertions, 19 deletions
diff --git a/sources/pyside6/libpysideqml/pysideqmlattached.cpp b/sources/pyside6/libpysideqml/pysideqmlattached.cpp
index d484257e2..da0a2afd4 100644
--- a/sources/pyside6/libpysideqml/pysideqmlattached.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlattached.cpp
@@ -50,7 +50,7 @@ const char *PySideQmlAttachedPrivate::name() const
extern "C" {
-static PyTypeObject *createPySideQmlAttachedType(void)
+static PyTypeObject *createPySideQmlAttachedType()
{
auto typeSlots =
PySide::ClassDecorator::Methods<PySideQmlAttachedPrivate>::typeSlots();
@@ -92,7 +92,7 @@ static QObject *attachedFactoryHelper(PyTypeObject *attachingType, QObject *o)
static const char methodName[] = "qmlAttachedProperties";
static PyObject *const pyMethodName = Shiboken::String::createStaticString(methodName);
- PyObject *attachingTypeObj = reinterpret_cast<PyObject *>(attachingType);
+ auto *attachingTypeObj = reinterpret_cast<PyObject *>(attachingType);
Shiboken::AutoDecRef pyResult(PyObject_CallMethodObjArgs(attachingTypeObj, pyMethodName,
attachingTypeObj /* self */,
converter.toPython(&o),
@@ -178,7 +178,7 @@ PySide::Qml::QmlExtensionInfo qmlAttachedInfo(PyTypeObject *t,
if (!info || info->attachedType == nullptr)
return result;
- auto *name = reinterpret_cast<PyTypeObject *>(t)->tp_name;
+ const auto *name = reinterpret_cast<PyTypeObject *>(t)->tp_name;
if (nextAttachingType >= MAX_ATTACHING_TYPES) {
qWarning("Unable to initialize attached type \"%s\": "
"The limit %d of attached types has been reached.",
diff --git a/sources/pyside6/libpysideqml/pysideqmlextended.cpp b/sources/pyside6/libpysideqml/pysideqmlextended.cpp
index 23543d589..fdd71ded6 100644
--- a/sources/pyside6/libpysideqml/pysideqmlextended.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlextended.cpp
@@ -46,7 +46,7 @@ const char *PySideQmlExtendedPrivate::name() const
extern "C" {
-static PyTypeObject *createPySideQmlExtendedType(void)
+static PyTypeObject *createPySideQmlExtendedType()
{
auto typeSlots =
PySide::ClassDecorator::Methods<PySideQmlExtendedPrivate>::typeSlots();
diff --git a/sources/pyside6/libpysideqml/pysideqmlforeign.cpp b/sources/pyside6/libpysideqml/pysideqmlforeign.cpp
index 18d39d121..90136f0aa 100644
--- a/sources/pyside6/libpysideqml/pysideqmlforeign.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlforeign.cpp
@@ -35,7 +35,7 @@ PyObject *PySideQmlForeignPrivate::tp_call(PyObject *self, PyObject *args, PyObj
info->foreignType = data->type();
// Insert an alias to be used by the factory functions of Decorators like
// @QmlExtended and @QmlAttached.
- auto *foreignObj = reinterpret_cast<const PyObject *>(info->foreignType);
+ const auto *foreignObj = reinterpret_cast<const PyObject *>(info->foreignType);
PySide::Qml::insertQmlTypeInfoAlias(foreignObj, info);
Py_INCREF(klass);
@@ -49,7 +49,7 @@ const char *PySideQmlForeignPrivate::name() const
extern "C" {
-static PyTypeObject *createPySideQmlForeignType(void)
+static PyTypeObject *createPySideQmlForeignType()
{
auto typeSlots =
PySide::ClassDecorator::Methods<PySideQmlForeignPrivate>::typeSlots();
diff --git a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp
index 75bb5af96..c66d870b9 100644
--- a/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmllistproperty.cpp
@@ -47,7 +47,7 @@ static int propListTpInit(PyObject *self, PyObject *args, PyObject *kwds)
"designable", "scriptable", "stored",
"user", "constant", "final",
nullptr};
- PySideProperty *pySelf = reinterpret_cast<PySideProperty *>(self);
+ auto *pySelf = reinterpret_cast<PySideProperty *>(self);
auto *data = static_cast<QmlListPropertyPrivate *>(pySelf->d);
@@ -192,7 +192,7 @@ QObject *propListAt(QQmlListProperty<QObject> *propList, qsizetype index)
auto *data = reinterpret_cast<QmlListPropertyPrivate *>(propList->data);
Shiboken::AutoDecRef retVal(PyObject_CallObject(data->at, args));
- QObject *result = 0;
+ QObject *result = nullptr;
if (PyErr_Occurred())
PyErr_Print();
else if (PyType_IsSubtype(Py_TYPE(retVal), data->type))
@@ -262,7 +262,7 @@ void QmlListPropertyPrivate::metaCall(PyObject *source, QMetaObject::Call call,
if (call != QMetaObject::ReadProperty)
return;
- QObject *qobj;
+ QObject *qobj{};
PyTypeObject *qobjectType = qObjectType();
Shiboken::Conversions::pythonToCppPointer(qobjectType, source, &qobj);
QQmlListProperty<QObject> declProp(
diff --git a/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp b/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp
index 63cefedb5..431e44aa0 100644
--- a/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlmetacallerror.cpp
@@ -40,7 +40,9 @@ std::optional<int> qmlMetaCallErrorHandler(QObject *object)
if (engine->currentStackFrame == nullptr)
return {};
- PyObject *errType, *errValue, *errTraceback;
+ PyObject *errType{};
+ PyObject *errValue{};
+ PyObject *errTraceback{};
PyErr_Fetch(&errType, &errValue, &errTraceback);
// PYSIDE-464: The error is only valid before PyErr_Restore,
// PYSIDE-464: therefore we take local copies.
diff --git a/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp b/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp
index 4ccd459d5..9e1c570d4 100644
--- a/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp
+++ b/sources/pyside6/libpysideqml/pysideqmlregistertype.cpp
@@ -43,7 +43,7 @@ static void createInto(void *memory, void *type)
QMutexLocker locker(&PySide::nextQObjectMemoryAddrMutex());
PySide::setNextQObjectMemoryAddr(memory);
Shiboken::GilState state;
- PyObject *obj = PyObject_CallObject(reinterpret_cast<PyObject *>(type), 0);
+ PyObject *obj = PyObject_CallObject(reinterpret_cast<PyObject *>(type), nullptr);
if (!obj || PyErr_Occurred())
PyErr_Print();
PySide::setNextQObjectMemoryAddr(nullptr);
@@ -76,7 +76,7 @@ static PyTypeObject *qQJSValueType()
// Check if o inherits from baseClass
static bool inheritsFrom(const QMetaObject *o, const char *baseClass)
{
- for (auto *base = o->superClass(); base ; base = base->superClass()) {
+ for (const auto *base = o->superClass(); base ; base = base->superClass()) {
if (qstrcmp(base->className(), baseClass) == 0)
return true;
}
@@ -171,7 +171,7 @@ static PyTypeObject *checkTypeObject(PyObject *pyObj, const char *what)
static bool setClassInfo(PyTypeObject *type, const QByteArray &key, const QByteArray &value)
{
if (!PySide::ClassInfo::setClassInfo(type, key, value)) {
- PyErr_Format(PyExc_TypeError, "Setting class info \"%s\" to \"%s\" on \"%s\" failed.",
+ PyErr_Format(PyExc_TypeError, R"(Setting class info "%s" to "%s" on "%s" failed.)",
key.constData(), value.constData(), type->tp_name);
return false;
}
@@ -197,7 +197,7 @@ static int qmlRegisterType(PyObject *pyObj,
const QMetaObject *metaObject,
const QMetaObject *classInfoMetaObject = nullptr)
{
- PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
+ auto *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
if (classInfoMetaObject == nullptr)
classInfoMetaObject = metaObject;
@@ -270,7 +270,7 @@ static int qmlRegisterType(PyObject *pyObj,
static int qmlRegisterType(PyObject *pyObj, PyObject *pyClassInfoObj,
const ImportData &importData)
{
- PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
+ auto *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
if (!isQObjectDerived(pyObjType, true))
return -1;
@@ -456,7 +456,7 @@ static int qmlRegisterSingletonTypeV2(PyObject *pyObj, PyObject *pyClassInfoObj,
const ImportData &importData,
const SingletonQObjectCreation &callback)
{
- PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
+ auto *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
if (!isQObjectDerived(pyObjType, true))
return -1;
@@ -501,7 +501,7 @@ static int qmlRegisterSingletonType(PyObject *pyObj, const ImportData &importDat
const QMetaObject *metaObject = nullptr;
if (isQObject) {
- PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
+ auto *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
if (!isQObjectDerived(pyObjType, true))
return -1;
@@ -583,7 +583,7 @@ static int qmlRegisterSingletonInstance(PyObject *pyObj, const ImportData &impor
using namespace Shiboken;
// Check if the Python Type inherit from QObject
- PyTypeObject *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
+ auto *pyObjType = reinterpret_cast<PyTypeObject *>(pyObj);
if (!isQObjectDerived(pyObjType, true))
return -1;
@@ -698,7 +698,7 @@ PyObject *qmlElementMacro(PyObject *pyObj, const char *decoratorName,
const auto importDataO = getGlobalImportData(decoratorName);
if (!importDataO.has_value())
return nullptr;
- const auto importData = importDataO.value();
+ const auto &importData = importDataO.value();
int result{};
if (mode == RegisterMode::Singleton) {