Skip to content

Commit

Permalink
[fix][crcx][#148][error: invalid use of void expression]
Browse files Browse the repository at this point in the history
  • Loading branch information
hex-in committed Jun 21, 2024
1 parent 0463822 commit 7893ba6
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/crcx/_crcxmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ static PyObject * _crc5_usb( PyObject *self, PyObject *args )
static PyObject * _crc5_cs( PyObject *self, PyObject *args )
{
Py_buffer data = { NULL, NULL };
unsigned char *ptr = NULL;
unsigned int sum = 0, i = 0;

#if PY_MAJOR_VERSION >= 3
Expand All @@ -210,9 +211,13 @@ static PyObject * _crc5_cs( PyObject *self, PyObject *args )
return FALSE;
}

ptr = (unsigned char *)data.buf;
for ( i=0; i<(unsigned int)data.len; i++ ) {
sum += (unsigned char)data.buf[i];
sum += ptr[i];
}

if ( data.obj )
PyBuffer_Release( &data );

return Py_BuildValue( "B", sum % 31 );
}
Expand Down

0 comments on commit 7893ba6

Please sign in to comment.