Skip to content

Commit 7634e5b

Browse files
committed
Another simplification of error handling in get_frame_info
1 parent da35da5 commit 7634e5b

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

Modules/_zstd/_zstdmodule.c

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,6 @@ _zstd__get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer)
496496
{
497497
uint64_t decompressed_size;
498498
uint32_t dict_id;
499-
PyObject *ret = NULL;
500499

501500
/* ZSTD_getFrameContentSize */
502501
decompressed_size = ZSTD_getFrameContentSize(frame_buffer->buf,
@@ -511,27 +510,17 @@ _zstd__get_frame_info_impl(PyObject *module, Py_buffer *frame_buffer)
511510
"a zstd frame. Make sure the frame_buffer argument "
512511
"starts from the beginning of a frame, and its length "
513512
"not less than the frame header (6~18 bytes).");
514-
goto error;
513+
return NULL;
515514
}
516515

517516
/* ZSTD_getDictID_fromFrame */
518517
dict_id = ZSTD_getDictID_fromFrame(frame_buffer->buf, frame_buffer->len);
519518

520519
/* Build tuple */
521520
if (decompressed_size == ZSTD_CONTENTSIZE_UNKNOWN) {
522-
ret = Py_BuildValue("OI", Py_None, dict_id);
523-
} else {
524-
ret = Py_BuildValue("KI", decompressed_size, dict_id);
521+
return Py_BuildValue("OI", Py_None, dict_id);
525522
}
526-
527-
if (ret == NULL) {
528-
goto error;
529-
}
530-
goto success;
531-
error:
532-
Py_CLEAR(ret);
533-
success:
534-
return ret;
523+
return Py_BuildValue("KI", decompressed_size, dict_id);
535524
}
536525

537526
/*[clinic input]

0 commit comments

Comments
 (0)