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

@@ -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));