Skip to content

Commit

Permalink
Should fix most gcc warnings (#251)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuzu-Typ authored Oct 11, 2024
1 parent 417e3e2 commit 2f14bc6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions PyGLM/internal_functions/ctypes_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ static PyObject* PyGLM_ToCtypesP(bool* ptr) {
Py_DECREF(ptr_as_c_void_p);
return out;
}
/*
static PyObject* PyGLM_ToCtypesP(void* ptr) {
PyObject* ptr_as_c_void_p = PyGLM_CtypesVoidP_FromVoidP(ptr);
return ptr_as_c_void_p;
}
*/
#endif
2 changes: 2 additions & 0 deletions PyGLM/internal_functions/number_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static unsigned long PyLong_AsUnsignedLongAndOverflow(PyObject* arg, int* overfl
return out;
}

/*
static unsigned long long PyLong_AsUnsignedLongLongAndOverflow(PyObject* arg, int* overflow) {
unsigned long long out = PyLong_AsUnsignedLongLong(arg);
if (PyErr_Occurred()) {
Expand All @@ -50,6 +51,7 @@ static unsigned long long PyLong_AsUnsignedLongLongAndOverflow(PyObject* arg, in
}
return out;
}
*/

static int PyLong_Sign(PyObject* arg) {
int overflow;
Expand Down
6 changes: 3 additions & 3 deletions PyGLM/internal_functions/type_checkers.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static bool get_py_buffer(PyObject* arg, Py_buffer* out) {

bool buffer_found = false;

for (int i = 0; i < sizeof(accepted_buffer_flags) / sizeof(int); i++) {
for (size_t i = 0; i < sizeof(accepted_buffer_flags) / sizeof(int); i++) {
if (PyObject_GetBuffer(arg, out, accepted_buffer_flags[i]) == -1) {
PyErr_Clear();
} else {
Expand Down Expand Up @@ -147,7 +147,7 @@ static _FormatType getFormatType(char* format) {
if (format == NULL) {
return _FormatType::UINT8;
}
if (format[0] == '=' || is_big_endian() && format[0] == '>' || !is_big_endian() && format[0] == '<' || is_big_endian() && format[0] == '!') {
if (format[0] == '=' || (is_big_endian() && format[0] == '>') || (!is_big_endian() && format[0] == '<') || (is_big_endian() && format[0] == '!')) {
switch(format[1]) {
case 'b':
return _FormatType::INT8;
Expand Down Expand Up @@ -183,7 +183,7 @@ static _FormatType getFormatType(char* format) {

}
}
if (!is_big_endian() && format[0] == '>' || is_big_endian() && format[0] == '<' || !is_big_endian() && format[0] == '!') {
if ((!is_big_endian() && format[0] == '>') || (is_big_endian() && format[0] == '<') || (!is_big_endian() && format[0] == '!')) {
return _FormatType::NONE;
}

Expand Down
15 changes: 12 additions & 3 deletions PyGLM/type_methods/glmArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -5072,6 +5072,15 @@ static PyObject* glmArray_sub(PyObject* obj1, PyObject* obj2) {
return NULL;
}

template<typename T>
static inline T glmArray_simple_mul(T a, T b) {
return a * b;
}

static inline bool glmArray_simple_mul(bool a, bool b) {
return a && b;
}

template<typename T>
static PyObject* glmArray_mul_T_SEQ(glmArray* arr1, glmArray* arr2) {
glmArray* outArray = (glmArray*)glmArray_new(&glmArrayType, NULL, NULL);
Expand Down Expand Up @@ -5118,7 +5127,7 @@ static PyObject* glmArray_mul_T_SEQ(glmArray* arr1, glmArray* arr2) {
Py_ssize_t arr2Ratio = arr2->itemSize / outArray->dtSize;

for (Py_ssize_t j = 0; j < outArrayRatio; j++) {
outArrayDataPtr[outArrayIndex++] = arr1DataPtr[i * arr1Ratio + (j % arr1Ratio)] * arr2DataPtr[i * arr2Ratio + (j % arr2Ratio)];
outArrayDataPtr[outArrayIndex++] = glmArray_simple_mul(arr1DataPtr[i * arr1Ratio + (j % arr1Ratio)], arr2DataPtr[i * arr2Ratio + (j % arr2Ratio)]);
}
}

Expand Down Expand Up @@ -5241,7 +5250,7 @@ static PyObject* glmArray_mulO_T(glmArray* arr, T* o, Py_ssize_t o_size, PyGLMTy

for (Py_ssize_t i = 0; i < outArray->itemCount; i++) {
for (Py_ssize_t j = 0; j < outArrayRatio; j++) {
outArrayDataPtr[outArrayIndex++] = arrDataPtr[i * arrRatio + (j % arrRatio)] * o[j % o_size];
outArrayDataPtr[outArrayIndex++] = glmArray_simple_mul(arrDataPtr[i * arrRatio + (j % arrRatio)], o[j % o_size]);
}
}

Expand Down Expand Up @@ -5273,7 +5282,7 @@ static PyObject* glmArray_mulO_T(glmArray* arr, T* o, Py_ssize_t o_size, PyGLMTy

for (Py_ssize_t i = 0; i < outArray->itemCount; i++) {
for (Py_ssize_t j = 0; j < outArrayRatio; j++) {
outArrayDataPtr[outArrayIndex++] = arrDataPtr[i * arrRatio + (j % arrRatio)] * o[j % o_size];
outArrayDataPtr[outArrayIndex++] = glmArray_simple_mul(arrDataPtr[i * arrRatio + (j % arrRatio)], o[j % o_size]);
}
}

Expand Down

0 comments on commit 2f14bc6

Please sign in to comment.