Cleanup: Various clang-tidy warnings in python

Pull Request: https://projects.blender.org/blender/blender/pulls/133734
This commit is contained in:
Brecht Van Lommel
2025-01-26 20:08:04 +01:00
parent 2b1dc0a44e
commit 27accea53e
29 changed files with 68 additions and 96 deletions

View File

@@ -240,7 +240,7 @@ static const char *pygpu_shader_check_compatibility(blender::gpu::Batch *batch)
}
/* Check batch compatibility with shader. */
for (auto vert : blender::Span(batch->verts, ARRAY_SIZE(batch->verts))) {
for (auto *vert : blender::Span(batch->verts, ARRAY_SIZE(batch->verts))) {
if (!vert) {
continue;
}

View File

@@ -13,6 +13,8 @@
#include <Python.h>
#include <algorithm>
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
@@ -327,15 +329,9 @@ static int pygpu_buffer_ass_slice(BPyGPUBuffer *self,
PyObject *item;
int count, err = 0;
if (begin < 0) {
begin = 0;
}
if (end > self->shape[0]) {
end = self->shape[0];
}
if (begin > end) {
begin = end;
}
begin = std::max<Py_ssize_t>(begin, 0);
end = std::min(end, self->shape[0]);
begin = std::min(begin, end);
if (!PySequence_Check(seq)) {
PyErr_Format(PyExc_TypeError,
@@ -447,15 +443,9 @@ static PyObject *pygpu_buffer_slice(BPyGPUBuffer *self, Py_ssize_t begin, Py_ssi
PyObject *list;
Py_ssize_t count;
if (begin < 0) {
begin = 0;
}
if (end > self->shape[0]) {
end = self->shape[0];
}
if (begin > end) {
begin = end;
}
begin = std::max<Py_ssize_t>(begin, 0);
end = std::min(end, self->shape[0]);
begin = std::min(begin, end);
list = PyList_New(end - begin);
@@ -636,7 +626,7 @@ static int pygpu_buffer__bf_getbuffer(BPyGPUBuffer *self, Py_buffer *view, int f
memset(view, 0, sizeof(*view));
view->obj = (PyObject *)self;
view->buf = (void *)self->buf.as_void;
view->buf = self->buf.as_void;
view->len = bpygpu_Buffer_size(self);
view->readonly = 0;
view->itemsize = GPU_texture_dataformat_size(eGPUDataFormat(self->format));

View File

@@ -13,7 +13,6 @@
#include "BLI_utildefines.h"
#include "GPU_capabilities.hh"
#include "GPU_shader.hh"
#include "GPU_texture.hh"
#include "GPU_uniform_buffer.hh"

View File

@@ -233,7 +233,7 @@ static bool pygpu_interface_info_get_args(BPyGPUStageInterfaceInfo *self,
}
#ifdef USE_GPU_PY_REFERENCES
PyList_Append(self->references, (PyObject *)py_name);
PyList_Append(self->references, py_name);
#endif
*r_type = (Type)pygpu_type.value_found;
@@ -425,7 +425,7 @@ static void pygpu_interface_info__tp_dealloc(PyObject *self)
}
#endif
Py_TYPE(self)->tp_free((PyObject *)self);
Py_TYPE(self)->tp_free(self);
}
PyDoc_STRVAR(
@@ -1296,7 +1296,7 @@ static void pygpu_shader_info__tp_dealloc(PyObject *self)
#endif
Py_TYPE(self)->tp_free((PyObject *)self);
Py_TYPE(self)->tp_free(self);
}
PyDoc_STRVAR(