commit - 6861dde0464effde4b407fc83b9d01d94838645c
commit + 794a213ff7f2e0fada025ef53a9b5cfeecf17b94
blob - 625f497531de7bc06ad51021e0ae869462e875da
blob + 1446cf88c13ccf1495280a5f9e2ddb1321872824
--- lib/worktree.c
+++ lib/worktree.c
static const struct got_error *
file_is_binary(int *is_binary , FILE *f)
{
- const struct got_error *err = NULL;
char buf[8192];
size_t r;
- off_t pos = ftello(f);
+ off_t pos;
*is_binary = 0;
- if (fseek(f, 0L, SEEK_SET) == -1)
+ pos = ftello(f);
+ if (pos == -1)
+ return got_error_from_errno("ftello");
+
+ if (fseeko(f, 0L, SEEK_SET) == -1)
return got_ferror(f, GOT_ERR_IO);
r = fread(buf, 1, sizeof(buf), f);
if (r > 0)
*is_binary = memchr(buf, '\0', r) != NULL;
- if (fseek(f, pos, SEEK_SET) == -1 && err == NULL)
- err = got_ferror(f, GOT_ERR_IO);
+ if (fseeko(f, pos, SEEK_SET) == -1)
+ return got_ferror(f, GOT_ERR_IO);
- return err;
+ return NULL;
}
static const struct got_error *