Skip to content

Commit b4e08b1

Browse files
committed
fix(bcf): interpretation of indexed reader initialisation return code
1 parent 0168666 commit b4e08b1

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/bcf/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,12 @@ impl IndexedReader {
295295
// Create reader and require existence of index file.
296296
let ser_reader = unsafe { htslib::bcf_sr_init() };
297297
unsafe {
298+
// 0: BCF_SR_REQUIRE_IDX
298299
htslib::bcf_sr_set_opt(ser_reader, 0);
299-
} // 0: BCF_SR_REQUIRE_IDX
300-
// Attach a file with the path from the arguments.
301-
if unsafe { htslib::bcf_sr_add_reader(ser_reader, path.as_ptr()) } >= 0 {
300+
}
301+
// Attach a file with the path from the arguments. 1 = success, 0 = fail
302+
// https://github.com/samtools/htslib/blob/develop/htslib/synced_bcf_reader.h#L232
303+
if unsafe { htslib::bcf_sr_add_reader(ser_reader, path.as_ptr()) } != 0 {
302304
let header = Arc::new(unsafe {
303305
HeaderView::from_ptr(htslib::bcf_hdr_dup(
304306
(*(*ser_reader).readers.offset(0)).header,

0 commit comments

Comments
 (0)