Skip to content

Commit b8eaca6

Browse files
committed
PEP 7; make more things static
1 parent ba35c9d commit b8eaca6

File tree

5 files changed

+22
-37
lines changed

5 files changed

+22
-37
lines changed

Modules/_zstd/_zstdmodule.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ typedef struct {
6969
char parameter_name[32];
7070
} ParameterInfo;
7171

72-
static const ParameterInfo cp_list[] =
73-
{
72+
static const ParameterInfo cp_list[] = {
7473
{ZSTD_c_compressionLevel, "compression_level"},
7574
{ZSTD_c_windowLog, "window_log"},
7675
{ZSTD_c_hashLog, "hash_log"},
@@ -95,8 +94,7 @@ static const ParameterInfo cp_list[] =
9594
{ZSTD_c_overlapLog, "overlap_log"}
9695
};
9796

98-
static const ParameterInfo dp_list[] =
99-
{
97+
static const ParameterInfo dp_list[] = {
10098
{ZSTD_d_windowLogMax, "window_log_max"}
10199
};
102100

@@ -730,14 +728,14 @@ static struct PyModuleDef_Slot _zstd_slots[] = {
730728
};
731729

732730
struct PyModuleDef _zstdmodule = {
733-
PyModuleDef_HEAD_INIT,
731+
.m_base = PyModuleDef_HEAD_INIT,
734732
.m_name = "_zstd",
735733
.m_size = sizeof(_zstd_state),
736734
.m_slots = _zstd_slots,
737735
.m_methods = _zstd_methods,
738736
.m_traverse = _zstd_traverse,
739737
.m_clear = _zstd_clear,
740-
.m_free = _zstd_free
738+
.m_free = _zstd_free,
741739
};
742740

743741
PyMODINIT_FUNC

Modules/_zstd/_zstdmodule.h

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ extern PyModuleDef _zstdmodule;
2020

2121
/* For clinic type calculations */
2222
static inline _zstd_state *
23-
get_zstd_state_from_type(PyTypeObject *type) {
23+
get_zstd_state_from_type(PyTypeObject *type)
24+
{
2425
PyObject *module = PyType_GetModuleByDef(type, &_zstdmodule);
2526
if (module == NULL) {
2627
return NULL;
@@ -149,7 +150,8 @@ typedef enum {
149150
} dictionary_type;
150151

151152
static inline int
152-
mt_continue_should_break(ZSTD_inBuffer *in, ZSTD_outBuffer *out) {
153+
mt_continue_should_break(ZSTD_inBuffer *in, ZSTD_outBuffer *out)
154+
{
153155
return in->size == in->pos && out->size != out->pos;
154156
}
155157

@@ -163,13 +165,3 @@ set_parameter_error(const _zstd_state* const state, int is_compress,
163165
int key_v, int value_v);
164166

165167
static const char init_twice_msg[] = "__init__ method is called twice.";
166-
167-
extern PyObject *
168-
decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
169-
Py_ssize_t max_length,
170-
Py_ssize_t initial_size,
171-
decompress_type type);
172-
173-
extern PyObject *
174-
compress_impl(ZstdCompressor *self, Py_buffer *data,
175-
ZSTD_EndDirective end_directive);

Modules/_zstd/compressor.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,8 @@ _get_CDict(ZstdDict *self, int compressionLevel)
198198
}
199199

200200
static int
201-
_zstd_load_c_dict(ZstdCompressor *self, PyObject *dict) {
201+
_zstd_load_c_dict(ZstdCompressor *self, PyObject *dict)
202+
{
202203

203204
size_t zstd_ret;
204205
_zstd_state* const mod_state = PyType_GetModuleState(Py_TYPE(self));
@@ -412,7 +413,7 @@ _zstd_ZstdCompressor___init___impl(ZstdCompressor *self, PyObject *level,
412413
return 0;
413414
}
414415

415-
PyObject *
416+
static PyObject *
416417
compress_impl(ZstdCompressor *self, Py_buffer *data,
417418
ZSTD_EndDirective end_directive)
418419
{
@@ -667,7 +668,7 @@ PyDoc_STRVAR(ZstdCompressor_last_mode_doc,
667668
static PyMemberDef ZstdCompressor_members[] = {
668669
{"last_mode", Py_T_INT, offsetof(ZstdCompressor, last_mode),
669670
Py_READONLY, ZstdCompressor_last_mode_doc},
670-
{0}
671+
{NULL}
671672
};
672673

673674
static int
@@ -695,7 +696,7 @@ static PyType_Slot zstdcompressor_slots[] = {
695696
{Py_tp_doc, (char*)_zstd_ZstdCompressor___init____doc__},
696697
{Py_tp_traverse, ZstdCompressor_traverse},
697698
{Py_tp_clear, ZstdCompressor_clear},
698-
{0}
699+
{0, 0}
699700
};
700701

701702
PyType_Spec zstd_compressor_type_spec = {

Modules/_zstd/decompressor.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ _zstd_load_d_dict(ZstdDecompressor *self, PyObject *dict)
276276
output stream: ====================|
277277
^
278278
*/
279-
PyObject *
279+
static PyObject *
280280
decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
281281
Py_ssize_t max_length,
282282
Py_ssize_t initial_size,
@@ -374,7 +374,7 @@ decompress_impl(ZstdDecompressor *self, ZSTD_inBuffer *in,
374374
return NULL;
375375
}
376376

377-
void
377+
static void
378378
decompressor_reset_session(ZstdDecompressor *self,
379379
decompress_type type)
380380
{
@@ -399,7 +399,7 @@ decompressor_reset_session(ZstdDecompressor *self,
399399
ZSTD_DCtx_reset(self->dctx, ZSTD_reset_session_only);
400400
}
401401

402-
PyObject *
402+
static PyObject *
403403
stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length,
404404
decompress_type type)
405405
{
@@ -823,17 +823,14 @@ PyDoc_STRVAR(ZstdDecompressor_needs_input_doc,
823823
static PyMemberDef ZstdDecompressor_members[] = {
824824
{"eof", Py_T_BOOL, offsetof(ZstdDecompressor, eof),
825825
Py_READONLY, ZstdDecompressor_eof_doc},
826-
827826
{"needs_input", Py_T_BOOL, offsetof(ZstdDecompressor, needs_input),
828827
Py_READONLY, ZstdDecompressor_needs_input_doc},
829-
830-
{0}
828+
{NULL}
831829
};
832830

833831
static PyGetSetDef ZstdDecompressor_getset[] = {
834832
_ZSTD_ZSTDDECOMPRESSOR_UNUSED_DATA_GETSETDEF
835-
836-
{0}
833+
{NULL}
837834
};
838835

839836
static int
@@ -863,7 +860,7 @@ static PyType_Slot ZstdDecompressor_slots[] = {
863860
{Py_tp_doc, (char*)_zstd_ZstdDecompressor___init____doc__},
864861
{Py_tp_traverse, ZstdDecompressor_traverse},
865862
{Py_tp_clear, ZstdDecompressor_clear},
866-
{0}
863+
{0, 0}
867864
};
868865

869866
PyType_Spec zstd_decompressor_type_spec = {

Modules/_zstd/zstddict.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ ZstdDict_str(PyObject *ob)
161161
static PyMemberDef ZstdDict_members[] = {
162162
{"dict_id", Py_T_UINT, offsetof(ZstdDict, dict_id), Py_READONLY, ZstdDict_dictid_doc},
163163
{"dict_content", Py_T_OBJECT_EX, offsetof(ZstdDict, dict_content), Py_READONLY, ZstdDict_dictcontent_doc},
164-
{0}
164+
{NULL}
165165
};
166166

167167
/*[clinic input]
@@ -231,12 +231,9 @@ _zstd_ZstdDict_as_prefix_get_impl(ZstdDict *self)
231231

232232
static PyGetSetDef ZstdDict_getset[] = {
233233
_ZSTD_ZSTDDICT_AS_DIGESTED_DICT_GETSETDEF
234-
235234
_ZSTD_ZSTDDICT_AS_UNDIGESTED_DICT_GETSETDEF
236-
237235
_ZSTD_ZSTDDICT_AS_PREFIX_GETSETDEF
238-
239-
{0}
236+
{NULL}
240237
};
241238

242239
static Py_ssize_t
@@ -275,7 +272,7 @@ static PyType_Slot zstddict_slots[] = {
275272
{Py_sq_length, ZstdDict_length},
276273
{Py_tp_traverse, ZstdDict_traverse},
277274
{Py_tp_clear, ZstdDict_clear},
278-
{0}
275+
{0, 0}
279276
};
280277

281278
PyType_Spec zstd_dict_type_spec = {

0 commit comments

Comments
 (0)