Skip to content

Commit 9e3ae05

Browse files
committed
First review
1 parent 4238f7e commit 9e3ae05

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

Modules/_zstd/decompressor.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ typedef struct {
4343
PyObject *unused_data;
4444

4545
/* 0 if decompressor has (or may has) unconsumed input data, 0 or 1. */
46-
char needs_input;
46+
bool needs_input;
4747

4848
/* For ZstdDecompressor, 0 or 1.
4949
1 means the end of the first frame has been reached. */
50-
char eof;
50+
bool eof;
5151

5252
/* __init__ has been called, 0 or 1. */
5353
bool initialized;
@@ -368,7 +368,7 @@ decompressor_reset_session(ZstdDecompressor *self)
368368
self->needs_input = 1;
369369
self->eof = 0;
370370

371-
/* Resetting session never fail */
371+
/* Resetting session is guaranteed to never fail */
372372
ZSTD_DCtx_reset(self->dctx, ZSTD_reset_session_only);
373373
}
374374

@@ -384,7 +384,7 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
384384
if (self->eof) {
385385
PyErr_SetString(PyExc_EOFError, "Already at the end of a zstd frame.");
386386
assert(ret == NULL);
387-
goto success;
387+
return ret;
388388
}
389389

390390
/* Prepare input buffer w/wo unconsumed data */
@@ -471,8 +471,7 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
471471
assert(in.pos == 0);
472472

473473
/* Decompress */
474-
ret = decompress_impl(self, &in,
475-
max_length, initial_buffer_size);
474+
ret = decompress_impl(self, &in, max_length, initial_buffer_size);
476475
if (ret == NULL) {
477476
goto error;
478477
}
@@ -529,16 +528,14 @@ stream_decompress(ZstdDecompressor *self, Py_buffer *data, Py_ssize_t max_length
529528
}
530529
}
531530

532-
goto success;
531+
return ret;
533532

534533
error:
535534
/* Reset decompressor's states/session */
536535
decompressor_reset_session(self);
537536

538537
Py_CLEAR(ret);
539-
success:
540-
541-
return ret;
538+
return NULL;
542539
}
543540

544541

0 commit comments

Comments
 (0)