mirror of
https://github.com/lh3/minimap2.git
synced 2026-09-15 13:07:55 +08:00
Report errno on file opening failures and I/O errors
Add the underlying operating system error (usually "No such file" or "Out of space" respectively, but highly informative when it is not) to these error messages.
This commit is contained in:
6
misc.c
6
misc.c
@@ -125,7 +125,7 @@ void mm_err_puts(const char *str)
|
||||
int ret;
|
||||
ret = puts(str);
|
||||
if (ret == EOF) {
|
||||
fprintf(stderr, "[ERROR] failed to write the results\n");
|
||||
perror("[ERROR] failed to write the results");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void mm_err_fwrite(const void *p, size_t size, size_t nitems, FILE *fp)
|
||||
int ret;
|
||||
ret = fwrite(p, size, nitems, fp);
|
||||
if (ret == EOF) {
|
||||
fprintf(stderr, "[ERROR] failed to write data\n");
|
||||
perror("[ERROR] failed to write data");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
@@ -145,7 +145,7 @@ void mm_err_fread(void *p, size_t size, size_t nitems, FILE *fp)
|
||||
int ret;
|
||||
ret = fread(p, size, nitems, fp);
|
||||
if (ret == EOF) {
|
||||
fprintf(stderr, "[ERROR] failed to read data\n");
|
||||
perror("[ERROR] failed to read data");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user