Skip to content

Commit 190a5ba

Browse files
committed
Small code style changes
1 parent 2b83b17 commit 190a5ba

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

src/isal/_isalmodule.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ static struct PyModuleDef _isal_module = {
2727
PyMODINIT_FUNC
2828
PyInit__isal(void)
2929
{
30-
PyObject *m;
31-
32-
m = PyModule_Create(&_isal_module);
30+
PyObject *m = PyModule_Create(&_isal_module);
3331
if (m == NULL) {
3432
return NULL;
3533
}

src/isal/igzip_libmodule.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ decompress_buf(IgzipDecompressor *self, Py_ssize_t max_length)
5757
/* data_size is strictly positive, but because we repeatedly have to
5858
compare against max_length and PyBytes_GET_SIZE we declare it as
5959
signed */
60-
PyObject * RetVal = NULL;
60+
PyObject *RetVal = NULL;
6161
Py_ssize_t hard_limit;
6262

6363
Py_ssize_t obuflen;
@@ -187,11 +187,11 @@ decompress(IgzipDecompressor *self, uint8_t *data, size_t len, Py_ssize_t max_le
187187
self->needs_input = 0;
188188
Py_ssize_t bytes_in_bitbuffer = bitbuffer_size(&(self->state));
189189
if (self->avail_in_real + bytes_in_bitbuffer > 0) {
190-
PyObject * new_data = PyBytes_FromStringAndSize(
190+
PyObject *new_data = PyBytes_FromStringAndSize(
191191
NULL, self->avail_in_real + bytes_in_bitbuffer);
192192
if (new_data == NULL)
193193
goto error;
194-
char * new_data_ptr = PyBytes_AS_STRING(new_data);
194+
char *new_data_ptr = PyBytes_AS_STRING(new_data);
195195
bitbuffer_copy(&(self->state), new_data_ptr, bytes_in_bitbuffer);
196196
memcpy(new_data_ptr + bytes_in_bitbuffer, self->state.next_in,
197197
self->avail_in_real);
@@ -213,7 +213,7 @@ decompress(IgzipDecompressor *self, uint8_t *data, size_t len, Py_ssize_t max_le
213213
/* Discard buffer if it's too small
214214
(resizing it may needlessly copy the current contents) */
215215
if (self->input_buffer != NULL &&
216-
self->input_buffer_size < self->avail_in_real) {
216+
self->input_buffer_size < self->avail_in_real) {
217217
PyMem_Free(self->input_buffer);
218218
self->input_buffer = NULL;
219219
}
@@ -572,9 +572,7 @@ static struct PyModuleDef igzip_lib_module = {
572572
PyMODINIT_FUNC
573573
PyInit_igzip_lib(void)
574574
{
575-
PyObject *m;
576-
577-
m = PyModule_Create(&igzip_lib_module);
575+
PyObject *m = PyModule_Create(&igzip_lib_module);
578576
if (m == NULL)
579577
return NULL;
580578

src/isal/isal_shared.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static const uint32_t LEVEL_BUF_SIZES[24] = {
8484
};
8585

8686
static inline int mem_level_to_bufsize(int compression_level, int mem_level,
87-
uint32_t * bufsize)
87+
uint32_t *bufsize)
8888
{
8989
if (compression_level < 0 || compression_level > 3 ||
9090
mem_level < MEM_LEVEL_DEFAULT || mem_level > MEM_LEVEL_EXTRA_LARGE) {
@@ -96,7 +96,7 @@ static inline int mem_level_to_bufsize(int compression_level, int mem_level,
9696

9797
static void isal_deflate_error(int err)
9898
{
99-
const char * msg = NULL;
99+
const char *msg = NULL;
100100
switch (err) {
101101
case COMP_OK: return;
102102
case INVALID_FLUSH:
@@ -127,7 +127,7 @@ static void isal_deflate_error(int err)
127127
}
128128

129129
static void isal_inflate_error(int err){
130-
const char * msg = NULL;
130+
const char *msg = NULL;
131131
switch (err){
132132
case ISAL_DECOMP_OK:
133133
return;
@@ -199,8 +199,8 @@ static int bitbuffer_copy(struct inflate_state *state, char *to, size_t n){
199199
int remainder = bits_in_buffer % 8;
200200
// Shift the 8-byte bitbuffer read_in so that the bytes are aligned.
201201
uint64_t remaining_bytes = state->read_in >> remainder;
202-
char * remaining_bytes_ptr = (char *)(&remaining_bytes);
203-
memcpy(to, remaining_bytes_ptr, n);
202+
// memcpy works because of little-endianness
203+
memcpy(to, &remaining_bytes, n);
204204
return 0;
205205
}
206206

src/isal/isal_zlibmodule.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@ static const int ZLIB_MEM_LEVEL_TO_ISAL[10] = {
119119

120120
static inline int zlib_mem_level_to_isal(int mem_level) {
121121
if (mem_level < 1 || mem_level > 9) {
122-
PyErr_Format(PyExc_ValueError,
123-
"Invalid mem level: %d. Mem level should be between 1 and 9");
122+
PyErr_Format(
123+
PyExc_ValueError,
124+
"Invalid mem level: %d. Mem level should be between 1 and 9",
125+
mem_level
126+
);
124127
return -1;}
125128
return ZLIB_MEM_LEVEL_TO_ISAL[mem_level];
126129
}
@@ -614,7 +617,7 @@ save_unconsumed_input(decompobject *self, Py_buffer *data, int err)
614617
new_data = PyBytes_FromStringAndSize(NULL, new_size);
615618
if (new_data == NULL)
616619
return -1;
617-
char * new_data_ptr = PyBytes_AS_STRING(new_data);
620+
char *new_data_ptr = PyBytes_AS_STRING(new_data);
618621
memcpy(new_data_ptr,
619622
PyBytes_AS_STRING(self->unused_data), old_size);
620623
bitbuffer_copy(&(self->zst), new_data_ptr + old_size, bytes_in_bitbuffer);
@@ -1194,9 +1197,7 @@ static struct PyModuleDef isal_zlib_module = {
11941197
PyMODINIT_FUNC
11951198
PyInit_isal_zlib(void)
11961199
{
1197-
PyObject *m;
1198-
1199-
m = PyModule_Create(&isal_zlib_module);
1200+
PyObject *m = PyModule_Create(&isal_zlib_module);
12001201
if (m == NULL) {
12011202
return NULL;
12021203
}

0 commit comments

Comments
 (0)