diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-05-29 14:59:09 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2019-06-25 10:45:28 +0200 |
commit | 4ccfd8de6462ce2ed938587eb0518038640c310f (patch) | |
tree | dbb4a1ff15a6729c2b4a213669f23861da779d3f /sources/shiboken2/libshiboken | |
parent | 3680a489521e4c13488b4f3f462b8e34cebd0e47 (diff) |
shiboken: Fix various clang warnings
- Avoid copying complex types by using const ref
- Use isEmpty() to check for container emptyness
- Use range-based for
- Use Q_DISABLE_COPY in 'public:' area
- Fix spelling error
- Use '= default' for trivial constructors/destructors
- Remove non-null checks before deletion
- Fix misleading indentation
- Fix else after return
- Simplify boolean expressions
- Fix unused parameters, streamline code
Change-Id: I8c6cadd8653e220ba8e5bdb4dd55524d13a81768
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/libshiboken')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 6 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/helper.cpp | 3 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/helper.h | 2 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/sbkarrayconverter.h | 11 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/sbkconverter_p.h | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/sbkenum.cpp | 3 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/signature.cpp | 4 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/voidptr.cpp | 6 |
9 files changed, 21 insertions, 22 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index 1762a969f..b9f6735d8 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -1260,10 +1260,8 @@ SbkObject *findColocatedChild(SbkObject *wrapper, if (!(child->d && child->d->cptr)) continue; if (child->d->cptr[0] == wrapper->d->cptr[0]) { - if (reinterpret_cast<const void *>(Py_TYPE(child)) == reinterpret_cast<const void *>(instanceType)) - return child; - else - return findColocatedChild(child, instanceType); + return reinterpret_cast<const void *>(Py_TYPE(child)) == reinterpret_cast<const void *>(instanceType) + ? child : findColocatedChild(child, instanceType); } } return nullptr; diff --git a/sources/shiboken2/libshiboken/helper.cpp b/sources/shiboken2/libshiboken/helper.cpp index 85ae2b133..fac72d56f 100644 --- a/sources/shiboken2/libshiboken/helper.cpp +++ b/sources/shiboken2/libshiboken/helper.cpp @@ -109,9 +109,8 @@ int *sequenceToIntArray(PyObject *obj, bool zeroTerminated) PyErr_SetString(PyExc_TypeError, "Sequence of ints expected"); delete[] array; return nullptr; - } else { - array[i] = PyInt_AsLong(item); } + array[i] = PyInt_AsLong(item); } if (zeroTerminated) diff --git a/sources/shiboken2/libshiboken/helper.h b/sources/shiboken2/libshiboken/helper.h index eca87b351..14aae8028 100644 --- a/sources/shiboken2/libshiboken/helper.h +++ b/sources/shiboken2/libshiboken/helper.h @@ -44,7 +44,7 @@ #include "shibokenmacros.h" #include "autodecref.h" -#define SBK_UNUSED(x) (void)x; +#define SBK_UNUSED(x) (void)(x); namespace Shiboken { diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index ed205626b..fe7157d24 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -67,7 +67,7 @@ datetime_struc *PyDateTimeAPI = NULL; #endif static PyObject * -dummy_func(PyObject *self, PyObject *args) +dummy_func(PyObject * /* self */, PyObject * /* args */) { Py_RETURN_NONE; } @@ -121,7 +121,7 @@ static PyType_Spec typeprobe_spec = { }; static void -check_PyTypeObject_valid(void) +check_PyTypeObject_valid() { auto *obtype = reinterpret_cast<PyObject *>(&PyType_Type); auto *probe_tp_base = reinterpret_cast<PyTypeObject *>( diff --git a/sources/shiboken2/libshiboken/sbkarrayconverter.h b/sources/shiboken2/libshiboken/sbkarrayconverter.h index 5b26c6e3c..84cb2f57f 100644 --- a/sources/shiboken2/libshiboken/sbkarrayconverter.h +++ b/sources/shiboken2/libshiboken/sbkarrayconverter.h @@ -73,10 +73,13 @@ enum : int { template <class T> class ArrayHandle { - ArrayHandle(const ArrayHandle &) = delete; - ArrayHandle &operator=(const ArrayHandle &) = delete; public: - ArrayHandle() {} + ArrayHandle(const ArrayHandle &) = delete; + ArrayHandle& operator=(const ArrayHandle &) = delete; + ArrayHandle(ArrayHandle &&) = delete; + ArrayHandle& operator=(ArrayHandle &&) = delete; + + ArrayHandle() = default; ~ArrayHandle() { destroy(); } void allocate(Py_ssize_t size); @@ -106,7 +109,7 @@ class Array2Handle public: typedef T RowType[columns]; - Array2Handle() {} + Array2Handle() = default; operator RowType *() const { return m_rows; } diff --git a/sources/shiboken2/libshiboken/sbkconverter_p.h b/sources/shiboken2/libshiboken/sbkconverter_p.h index 3490a5c38..d87162071 100644 --- a/sources/shiboken2/libshiboken/sbkconverter_p.h +++ b/sources/shiboken2/libshiboken/sbkconverter_p.h @@ -537,7 +537,7 @@ struct Primitive<std::string> : TwoPrimitive<std::string> template <> struct Primitive<std::nullptr_t> : TwoPrimitive<std::nullptr_t> { - static PyObject *toPython(const void *cppIn) + static PyObject *toPython(const void * /* cppIn */) { return Py_None; } @@ -551,7 +551,7 @@ struct Primitive<std::nullptr_t> : TwoPrimitive<std::nullptr_t> return toCpp; return nullptr; } - static void otherToCpp(PyObject *pyIn, void *cppOut) + static void otherToCpp(PyObject * /* pyIn */, void *cppOut) { *reinterpret_cast<std::nullptr_t *>(cppOut) = nullptr; } diff --git a/sources/shiboken2/libshiboken/sbkenum.cpp b/sources/shiboken2/libshiboken/sbkenum.cpp index 8f24cc19a..71fcf5f64 100644 --- a/sources/shiboken2/libshiboken/sbkenum.cpp +++ b/sources/shiboken2/libshiboken/sbkenum.cpp @@ -233,9 +233,8 @@ static PyObject *enum_richcompare(PyObject *self, PyObject *other, int op) if (!(enumA || enumB)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; - } else { - result = PyObject_RichCompare(valA, valB, op); } + result = PyObject_RichCompare(valA, valB, op); // Decreasing the reference of the used variables a and b. if (enumA) diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp index ad53458c3..e62f861a2 100644 --- a/sources/shiboken2/libshiboken/signature.cpp +++ b/sources/shiboken2/libshiboken/signature.cpp @@ -795,7 +795,7 @@ get_signature_intern(PyObject *ob, const char *modifier) } static PyObject * -get_signature(PyObject *self, PyObject *args) +get_signature(PyObject * /* self */, PyObject *args) { PyObject *ob; const char *modifier = nullptr; @@ -1123,7 +1123,7 @@ _build_func_to_type(PyObject *obtype) } int -SbkSpecial_Type_Ready(PyObject *module, PyTypeObject *type, +SbkSpecial_Type_Ready(PyObject * /* module */, PyTypeObject *type, const char *signatures[]) { if (PyType_Ready(type) < 0) diff --git a/sources/shiboken2/libshiboken/voidptr.cpp b/sources/shiboken2/libshiboken/voidptr.cpp index 1bba9b4f7..d4ce58c87 100644 --- a/sources/shiboken2/libshiboken/voidptr.cpp +++ b/sources/shiboken2/libshiboken/voidptr.cpp @@ -105,7 +105,7 @@ int SbkVoidPtrObject_init(PyObject *self, PyObject *args, PyObject *kwds) sbkSelf->cptr = bufferView.buf; sbkSelf->size = bufferView.len > 0 ? bufferView.len : size; - sbkSelf->isWritable = bufferView.readonly > 0 ? false : true; + sbkSelf->isWritable = bufferView.readonly <= 0; // Release the buffer. PyBuffer_Release(&bufferView); @@ -115,7 +115,7 @@ int SbkVoidPtrObject_init(PyObject *self, PyObject *args, PyObject *kwds) auto *sbkOther = reinterpret_cast<SbkObject *>(addressObject); sbkSelf->cptr = sbkOther->d->cptr[0]; sbkSelf->size = size; - sbkSelf->isWritable = isWritable > 0 ? true : false; + sbkSelf->isWritable = isWritable > 0; } // An integer representing an address. else { @@ -137,7 +137,7 @@ int SbkVoidPtrObject_init(PyObject *self, PyObject *args, PyObject *kwds) } sbkSelf->cptr = cptr; sbkSelf->size = size; - sbkSelf->isWritable = isWritable > 0 ? true : false; + sbkSelf->isWritable = isWritable > 0; } } |