Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions mtbl/reader.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,17 @@ mtbl_reader_init(const char *fname, const struct mtbl_reader_options *opt)
int fd;

fd = open(fname, O_RDONLY);
if (fd < 0)
if (fd < 0) {
fprintf(stderr, "%s: ERROR: failed to open(2) '%s': %s\n", __func__, fname, strerror(errno));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is library code. Libraries should not be writing to stdout/stderr.

return (NULL);
}

r = mtbl_reader_init_fd(fd, opt);
close(fd);
if (r == NULL) {
fprintf(stderr, "%s: ERROR: failed to init mtbl fd for '%s'\n", __func__, fname);
}

close(fd);
return (r);
}

Expand Down
5 changes: 3 additions & 2 deletions src/mtbl_merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,9 @@ main(int argc, char **argv)
fprintf(stderr, "%s: opening input file %s\n", program_name, fname);
readers[i] = mtbl_reader_init(fname, NULL);
if (readers[i] == NULL) {
fprintf(stderr, "Error: mtbl_reader_init() failed.\n\n");
usage();
fprintf(stderr, "%s: ERROR: mtbl_reader_init() failed to open file %s\n\n",
program_name, fname);
exit(EXIT_FAILURE);
}
mtbl_merger_add_source(merger, mtbl_reader_source(readers[i]));
total_input_entries += mtbl_metadata_count_entries(mtbl_reader_metadata(readers[i]));
Expand Down