Skip to content

Commit a46faa4

Browse files
committed
Address line length in C files
1 parent 7a34a42 commit a46faa4

File tree

4 files changed

+63
-31
lines changed

4 files changed

+63
-31
lines changed

src/isal/_isalmodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
// This file is part of python-isal which is distributed under the
66
// PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2.
77

8-
// This file is not originally from the CPython distribution. But it does contain mostly example code
9-
// from the Python docs. Also dual licensing just for this one file seemed silly.
8+
// This file is not originally from the CPython distribution. But it does
9+
// contain mostly example code from the Python docs. Also dual licensing just
10+
// for this one file seemed silly.
1011

1112
#define PY_SSIZE_T_CLEAN
1213
#include <Python.h>

src/isal/igzip_libmodule.c

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ decompress_buf(IgzipDecompressor *self, Py_ssize_t max_length)
102102
isal_inflate_error(err);
103103
goto error;
104104
}
105-
} while (self->state.avail_out == 0 && self->state.block_state != ISAL_BLOCK_FINISH);
106-
} while(self->avail_in_real != 0 && self->state.block_state != ISAL_BLOCK_FINISH);
105+
} while (self->state.avail_out == 0 &&
106+
self->state.block_state != ISAL_BLOCK_FINISH);
107+
} while(self->avail_in_real != 0 &&
108+
self->state.block_state != ISAL_BLOCK_FINISH);
107109

108110
if (self->state.block_state == ISAL_BLOCK_FINISH)
109111
self->eof = 1;
@@ -189,7 +191,8 @@ decompress(IgzipDecompressor *self, uint8_t *data, size_t len, Py_ssize_t max_le
189191
goto error;
190192
char * new_data_ptr = PyBytes_AS_STRING(new_data);
191193
bitbuffer_copy(&(self->state), new_data_ptr, bytes_in_bitbuffer);
192-
memcpy(new_data_ptr + bytes_in_bitbuffer, self->state.next_in, self->avail_in_real);
194+
memcpy(new_data_ptr + bytes_in_bitbuffer, self->state.next_in,
195+
self->avail_in_real);
193196
Py_XSETREF(self->unused_data, new_data);
194197
}
195198
}
@@ -257,7 +260,8 @@ PyDoc_STRVAR(igzip_lib_compress__doc__,
257260
" the header and trailer are controlled by the flag parameter.");
258261

259262
#define IGZIP_LIB_COMPRESS_METHODDEF \
260-
{"compress", (PyCFunction)(void(*)(void))igzip_lib_compress, METH_VARARGS|METH_KEYWORDS, igzip_lib_compress__doc__}
263+
{"compress", (PyCFunction)(void(*)(void))igzip_lib_compress, \
264+
METH_VARARGS|METH_KEYWORDS, igzip_lib_compress__doc__}
261265

262266
static PyObject *
263267
igzip_lib_compress(PyObject *module, PyObject *args, PyObject *kwargs)
@@ -298,7 +302,8 @@ PyDoc_STRVAR(igzip_lib_decompress__doc__,
298302
" The initial output buffer size.");
299303

300304
#define IGZIP_LIB_DECOMPRESS_METHODDEF \
301-
{"decompress", (PyCFunction)(void(*)(void))igzip_lib_decompress, METH_VARARGS|METH_KEYWORDS, igzip_lib_decompress__doc__}
305+
{"decompress", (PyCFunction)(void(*)(void))igzip_lib_decompress, \
306+
METH_VARARGS|METH_KEYWORDS, igzip_lib_decompress__doc__}
302307

303308
static PyObject *
304309
igzip_lib_decompress(PyObject *module, PyObject *args, PyObject *kwargs)
@@ -340,10 +345,13 @@ PyDoc_STRVAR(igzip_lib_IgzipDecompressor_decompress__doc__,
340345
"the unused_data attribute.");
341346

342347
#define IGZIP_LIB_IGZIPDECOMPRESSOR_DECOMPRESS_METHODDEF \
343-
{"decompress", (PyCFunction)(void(*)(void))igzip_lib_IgzipDecompressor_decompress, METH_VARARGS|METH_KEYWORDS, igzip_lib_IgzipDecompressor_decompress__doc__}
348+
{"decompress", (PyCFunction)(void(*)(void))igzip_lib_IgzipDecompressor_decompress, \
349+
METH_VARARGS|METH_KEYWORDS, igzip_lib_IgzipDecompressor_decompress__doc__}
344350

345351
static PyObject *
346-
igzip_lib_IgzipDecompressor_decompress(IgzipDecompressor *self, PyObject *args, PyObject *kwargs)
352+
igzip_lib_IgzipDecompressor_decompress(IgzipDecompressor *self,
353+
PyObject *args,
354+
PyObject *kwargs)
347355
{
348356
static char *keywords[] = {"", "max_length", NULL};
349357
static char *format = "y*|n:decompress";
@@ -458,8 +466,9 @@ static PyMemberDef IgzipDecompressor_members[] = {
458466
READONLY, IgzipDecompressor_unused_data__doc__},
459467
{"needs_input", T_BOOL, offsetof(IgzipDecompressor, needs_input), READONLY,
460468
IgzipDecompressor_needs_input_doc},
461-
{"crc", T_UINT, offsetof(IgzipDecompressor, state) + offsetof(struct inflate_state, crc), READONLY,
462-
IgzipDecompressor_crc_doc},
469+
{"crc", T_UINT,
470+
offsetof(IgzipDecompressor, state) + offsetof(struct inflate_state, crc),
471+
READONLY, IgzipDecompressor_crc_doc},
463472
{NULL}
464473
};
465474

@@ -584,7 +593,8 @@ PyInit_igzip_lib(void)
584593
return NULL;
585594
}
586595
Py_INCREF(&IgzipDecompressor_Type);
587-
if (PyModule_AddObject(m, "IgzipDecompressor", (PyObject *)&IgzipDecompressor_Type) < 0) {
596+
if (PyModule_AddObject(m, "IgzipDecompressor",
597+
(PyObject *)&IgzipDecompressor_Type) < 0) {
588598
return NULL;
589599
}
590600

src/isal/isal_shared.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ static const uint32_t LEVEL_BUF_SIZES[24] = {
8585
static inline int mem_level_to_bufsize(int compression_level, int mem_level,
8686
uint32_t * bufsize)
8787
{
88-
if (compression_level < 0 || compression_level > 3 || mem_level < MEM_LEVEL_DEFAULT || mem_level > MEM_LEVEL_EXTRA_LARGE) {
88+
if (compression_level < 0 || compression_level > 3 ||
89+
mem_level < MEM_LEVEL_DEFAULT || mem_level > MEM_LEVEL_EXTRA_LARGE) {
8990
*bufsize = 0; return -1;
9091
}
9192
*bufsize = LEVEL_BUF_SIZES[compression_level * 6 + mem_level];
@@ -121,7 +122,8 @@ static void isal_inflate_error(int err){
121122
else if (err == ISAL_INVALID_SYMBOL) msg = "Invalid deflate symbol found";
122123
else if (err == ISAL_INVALID_LOOKBACK) msg = "Invalid lookback distance found";
123124
else if (err == ISAL_INVALID_WRAPPER) msg = "Invalid gzip/zlib wrapper found";
124-
else if (err == ISAL_UNSUPPORTED_METHOD) msg = "Gzip/zlib wrapper specifies unsupported compress method";
125+
else if (err == ISAL_UNSUPPORTED_METHOD) msg = "Gzip/zlib wrapper specifies"
126+
"unsupported compress method";
125127
else if (err == ISAL_INCORRECT_CHECKSUM) msg = "Incorrect checksum found";
126128
else msg = "Unknown error";
127129

@@ -268,7 +270,8 @@ igzip_lib_compress_impl(Py_buffer *data,
268270
else zst.flush = NO_FLUSH;
269271

270272
do {
271-
obuflen = arrange_output_buffer(&(zst.avail_out), &(zst.next_out), &RetVal, obuflen);
273+
obuflen = arrange_output_buffer(&(zst.avail_out), &(zst.next_out),
274+
&RetVal, obuflen);
272275
if (obuflen < 0) {
273276
PyErr_SetString(PyExc_MemoryError,
274277
"Unsufficient memory for buffer allocation");

src/isal/isal_zlibmodule.c

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ static const int ZLIB_MEM_LEVEL_TO_ISAL[10] = {
109109
MEM_LEVEL_MEDIUM, // 4-6 -> MEDIUM
110110
MEM_LEVEL_MEDIUM,
111111
MEM_LEVEL_MEDIUM,
112-
MEM_LEVEL_LARGE, // 7-8 LARGE. The zlib module default = 8. Large is the ISA-L default value.
112+
// 7-8 LARGE. The zlib module default = 8. Large is the ISA-L default value.
113+
MEM_LEVEL_LARGE,
113114
MEM_LEVEL_LARGE,
114115
MEM_LEVEL_EXTRA_LARGE, // 9 -> EXTRA_LARGE.
115116
};
@@ -435,7 +436,8 @@ isal_zlib_compressobj_impl(PyObject *module, int level, int method, int wbits,
435436
if (strategy != Z_DEFAULT_STRATEGY){
436437
err = PyErr_WarnEx(
437438
PyExc_UserWarning,
438-
"Only one strategy is supported when using isal_zlib. Using the default strategy.",
439+
"Only one strategy is supported when using isal_zlib. Using the "
440+
"default strategy.",
439441
1);
440442
if (err == -1)
441443
// Warning was turned into an exception.
@@ -456,7 +458,8 @@ isal_zlib_compressobj_impl(PyObject *module, int level, int method, int wbits,
456458
if (mem_level_to_bufsize(
457459
level, isal_mem_level, &level_buf_size) == -1) {
458460
PyErr_Format(PyExc_ValueError,
459-
"Invalid compression level: %d. Compression level should be between 0 and 3",
461+
"Invalid compression level: %d. Compression level should "
462+
"be between 0 and 3",
460463
level);
461464
goto error;
462465
}
@@ -690,7 +693,8 @@ isal_zlib_Decompress_decompress_impl(decompobject *self, Py_buffer *data,
690693
goto abort;
691694
}
692695

693-
} while (self->zst.avail_out == 0 && self->zst.block_state != ISAL_BLOCK_FINISH);
696+
} while (self->zst.avail_out == 0 &&
697+
self->zst.block_state != ISAL_BLOCK_FINISH);
694698

695699
} while (self->zst.block_state != ISAL_BLOCK_FINISH && ibuflen != 0);
696700

@@ -802,7 +806,8 @@ isal_zlib_Decompress_flush_impl(decompobject *self, Py_ssize_t length)
802806

803807
do {
804808
length = arrange_output_buffer(&(self->zst.avail_out),
805-
&(self->zst.next_out), &RetVal, length);
809+
&(self->zst.next_out),
810+
&RetVal, length);
806811
if (length < 0)
807812
goto abort;
808813

@@ -813,7 +818,8 @@ isal_zlib_Decompress_flush_impl(decompobject *self, Py_ssize_t length)
813818
goto abort;
814819
}
815820

816-
} while (self->zst.avail_out == 0 && self->zst.block_state != ISAL_BLOCK_FINISH);
821+
} while (self->zst.avail_out == 0 &&
822+
self->zst.block_state != ISAL_BLOCK_FINISH);
817823

818824
} while (self->zst.block_state != ISAL_BLOCK_FINISH && ibuflen != 0);
819825

@@ -868,13 +874,15 @@ PyDoc_STRVAR(isal_zlib_compressobj__doc__,
868874
" containing subsequences that are likely to occur in the input data.");
869875

870876
#define ISAL_ZLIB_COMPRESSOBJ_METHODDEF \
871-
{"compressobj", (PyCFunction)(void(*)(void))isal_zlib_compressobj, METH_VARARGS|METH_KEYWORDS, isal_zlib_compressobj__doc__}
877+
{"compressobj", (PyCFunction)(void(*)(void))isal_zlib_compressobj, \
878+
METH_VARARGS|METH_KEYWORDS, isal_zlib_compressobj__doc__}
872879

873880
static PyObject *
874881
isal_zlib_compressobj(PyObject *module, PyObject *args, PyObject *kwargs)
875882
{
876883
PyObject *return_value = NULL;
877-
static char *keywords[] = {"level", "method", "wbits", "memLevel", "strategy", "zdict", NULL};
884+
static char *keywords[] = {"level", "method", "wbits", "memLevel",
885+
"strategy", "zdict", NULL};
878886
static char *format = "|iiiiiy*:compressobj";
879887
int level = ISAL_DEFAULT_COMPRESSION;
880888
int method = Z_DEFLATED;
@@ -888,7 +896,8 @@ isal_zlib_compressobj(PyObject *module, PyObject *args, PyObject *kwargs)
888896
&level, &method, &wbits, &memLevel, &strategy, &zdict)) {
889897
return NULL;
890898
}
891-
return_value = isal_zlib_compressobj_impl(module, level, method, wbits, memLevel, strategy, &zdict);
899+
return_value = isal_zlib_compressobj_impl(module, level, method, wbits,
900+
memLevel, strategy, &zdict);
892901
PyBuffer_Release(&zdict);
893902
return return_value;
894903
}
@@ -906,7 +915,8 @@ PyDoc_STRVAR(isal_zlib_decompressobj__doc__,
906915
" dictionary as used by the compressor that produced the input data.");
907916

908917
#define ISAL_ZLIB_DECOMPRESSOBJ_METHODDEF \
909-
{"decompressobj", (PyCFunction)(void(*)(void))isal_zlib_decompressobj, METH_VARARGS|METH_KEYWORDS, isal_zlib_decompressobj__doc__}
918+
{"decompressobj", (PyCFunction)(void(*)(void))isal_zlib_decompressobj, \
919+
METH_VARARGS|METH_KEYWORDS, isal_zlib_decompressobj__doc__}
910920

911921
static PyObject *
912922
isal_zlib_decompressobj(PyObject *module, PyObject *args, PyObject *kwargs)
@@ -938,7 +948,8 @@ PyDoc_STRVAR(isal_zlib_Compress_compress__doc__,
938948
"Call the flush() method to clear these buffers.");
939949

940950
#define ISAL_ZLIB_COMPRESS_COMPRESS_METHODDEF \
941-
{"compress", (PyCFunction)(void(*)(void))isal_zlib_Compress_compress, METH_O, isal_zlib_Compress_compress__doc__}
951+
{"compress", (PyCFunction)(void(*)(void))isal_zlib_Compress_compress, \
952+
METH_O, isal_zlib_Compress_compress__doc__}
942953

943954

944955
static PyObject *
@@ -971,7 +982,8 @@ PyDoc_STRVAR(isal_zlib_Decompress_decompress__doc__,
971982
"Call the flush() method to clear these buffers.");
972983

973984
#define ISAL_ZLIB_DECOMPRESS_DECOMPRESS_METHODDEF \
974-
{"decompress", (PyCFunction)(void(*)(void))isal_zlib_Decompress_decompress, METH_VARARGS|METH_KEYWORDS, isal_zlib_Decompress_decompress__doc__}
985+
{"decompress", (PyCFunction)(void(*)(void))isal_zlib_Decompress_decompress, \
986+
METH_VARARGS|METH_KEYWORDS, isal_zlib_Decompress_decompress__doc__}
975987

976988

977989
static PyObject *
@@ -986,7 +998,8 @@ isal_zlib_Decompress_decompress(decompobject *self, PyObject *args, PyObject *kw
986998
args, kwargs, format, keywords, &data, &max_length)) {
987999
return NULL;
9881000
}
989-
PyObject *return_value = isal_zlib_Decompress_decompress_impl(self, &data, max_length);
1001+
PyObject *return_value = isal_zlib_Decompress_decompress_impl(self, &data,
1002+
max_length);
9901003
PyBuffer_Release(&data);
9911004
return return_value;
9921005
}
@@ -1004,11 +1017,15 @@ PyDoc_STRVAR(isal_zlib_Compress_flush__doc__,
10041017
" can still be compressed.");
10051018

10061019
#define ISAL_ZLIB_COMPRESS_FLUSH_METHODDEF \
1007-
{"flush", (PyCFunction)(void(*)(void))isal_zlib_Compress_flush, METH_FASTCALL|METH_KEYWORDS, isal_zlib_Compress_flush__doc__}
1020+
{"flush", (PyCFunction)(void(*)(void))isal_zlib_Compress_flush, \
1021+
METH_FASTCALL|METH_KEYWORDS, isal_zlib_Compress_flush__doc__}
10081022

10091023

10101024
static PyObject *
1011-
isal_zlib_Compress_flush(compobject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
1025+
isal_zlib_Compress_flush(compobject *self,
1026+
PyObject *const *args,
1027+
Py_ssize_t nargs,
1028+
PyObject *kwnames)
10121029
{
10131030
Py_ssize_t mode;
10141031
if (nargs == 0) {
@@ -1047,7 +1064,8 @@ PyDoc_STRVAR(isal_zlib_Decompress_flush__doc__,
10471064

10481065

10491066
#define ISAL_ZLIB_DECOMPRESS_FLUSH_METHODDEF \
1050-
{"flush", (PyCFunction)(void(*)(void))isal_zlib_Decompress_flush, METH_FASTCALL, isal_zlib_Decompress_flush__doc__}
1067+
{"flush", (PyCFunction)(void(*)(void))isal_zlib_Decompress_flush, \
1068+
METH_FASTCALL, isal_zlib_Decompress_flush__doc__}
10511069

10521070
static PyObject *
10531071
isal_zlib_Decompress_flush(decompobject *self, PyObject *const *args, Py_ssize_t nargs)

0 commit comments

Comments
 (0)