aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/libshiboken/helper.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2025-01-31 09:30:39 +0100
committerFriedemann Kleint <[email protected]>2025-02-03 18:12:40 +0100
commitaa9b918153a1414a10c48e996e8a36eccd94140b (patch)
treec5e0ef7c6db51a81e8f665ee777784671bf2feb4 /sources/shiboken6/libshiboken/helper.cpp
parent4fb8c5ddd8f840b14c65e1f225eb5c5ac4e5ad8b (diff)
libshiboken: Fix some clang-tidy warnings
- Use auto* for pointers - Remove duplicate includes - Use rang-based for - Remove superfluous inline - Use of std::string_view::data() (may not be null-terminated) Pick-to: 6.8 Change-Id: I663d630ad151526ad13546ad079d70635ff1e43d Reviewed-by: Shyamnath Premnadh <[email protected]>
Diffstat (limited to 'sources/shiboken6/libshiboken/helper.cpp')
-rw-r--r--sources/shiboken6/libshiboken/helper.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/sources/shiboken6/libshiboken/helper.cpp b/sources/shiboken6/libshiboken/helper.cpp
index 91337ba15..8ef5f6bfb 100644
--- a/sources/shiboken6/libshiboken/helper.cpp
+++ b/sources/shiboken6/libshiboken/helper.cpp
@@ -5,12 +5,10 @@
#include "basewrapper_p.h"
#include "sbkstring.h"
#include "sbkstaticstrings.h"
-#include "sbkstaticstrings.h"
#include "pep384impl.h"
#include <algorithm>
#include <optional>
-
#include <iomanip>
#include <iostream>
#include <climits>
@@ -176,8 +174,8 @@ static void formatPyTuple(PyObject *obj, std::ostream &str)
static void formatPyDict(PyObject *obj, std::ostream &str)
{
- PyObject *key;
- PyObject *value;
+ PyObject *key{};
+ PyObject *value{};
Py_ssize_t pos = 0;
str << '{';
while (PyDict_Next(obj, &pos, &key, &value) != 0) {
@@ -501,7 +499,7 @@ bool listToArgcArgv(PyObject *argList, int *argc, char ***argv, const char *defa
PyObject *appName = PyDict_GetItem(globals, Shiboken::PyMagicName::file());
(*argv)[0] = strdup(appName ? Shiboken::String::toCString(appName) : defaultAppName);
} else {
- for (int i = 0; i < numArgs; ++i) {
+ for (Py_ssize_t i = 0; i < numArgs; ++i) {
PyObject *item = PyList_GetItem(args.object(), i);
char *string = nullptr;
if (Shiboken::String::check(item)) {
@@ -527,7 +525,7 @@ int *sequenceToIntArray(PyObject *obj, bool zeroTerminated)
Py_ssize_t size = PySequence_Size(seq.object());
int *array = new int[size + (zeroTerminated ? 1 : 0)];
- for (int i = 0; i < size; i++) {
+ for (Py_ssize_t i = 0; i < size; i++) {
Shiboken::AutoDecRef item(PySequence_GetItem(seq.object(), i));
if (!PyLong_Check(item)) {
PyErr_SetString(PyExc_TypeError, "Sequence of ints expected");
@@ -557,7 +555,7 @@ int warning(PyObject *category, int stacklevel, const char *format, ...)
// check the necessary memory
int size = vsnprintf(nullptr, 0, format, args) + 1;
- auto message = new char[size];
+ auto *message = new char[size];
int result = 0;
if (message) {
// format the message