Skip to content

Commit

Permalink
Address code review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriuo committed Apr 28, 2020
1 parent 445de25 commit a4fab45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -3220,8 +3220,10 @@ int sam_format1(const bam_hdr_t *h, const bam1_t *b, kstring_t *str)
// reference count the structure.
int sam_write1(htsFile *fp, const sam_hdr_t *hdr, const bam1_t *b)
{
const sam_hdr_t *h = hdr;
if (!h) h = fp->bam_header;
if (!fp || !b) { errno = EINVAL; return -1; }
const sam_hdr_t *h = hdr ? hdr : fp->bam_header;
if (!h) { hts_log_error("No header available for file \"%s\"", fp->fn); return -1; }

switch (fp->format.format) {
case binary_format:
fp->format.category = sequence_data;
Expand Down
12 changes: 10 additions & 2 deletions vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3296,7 +3296,11 @@ static int vcf_idx_init(htsFile *fp, bcf_hdr_t *h, int min_shift, const char *fn
return -1;
}
fp->fnidx = strdup(fnidx);
if (!fp->fnidx) return -1;
if (!fp->fnidx) {
hts_idx_destroy(fp->idx);
fp->idx = NULL;
return -1;
}

return 0;
}
Expand All @@ -3317,7 +3321,11 @@ int bcf_idx_init(htsFile *fp, bcf_hdr_t *h, int min_shift, const char *fnidx) {
fp->idx = hts_idx_init(nids, HTS_FMT_CSI, bgzf_tell(fp->fp.bgzf), min_shift, n_lvls);
if (!fp->idx) return -1;
fp->fnidx = strdup(fnidx);
if (!fp->fnidx) return -1;
if (!fp->fnidx) {
hts_idx_destroy(fp->idx);
fp->idx = NULL;
return -1;
}

return 0;
}
Expand Down

0 comments on commit a4fab45

Please sign in to comment.