Skip to content

Commit

Permalink
Use fstat instead of fseek
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Fonseca <fonseca@diku.dk>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Jonas Fonseca authored and Junio C Hamano committed Aug 28, 2006
1 parent 5ff9d11 commit c470701
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,15 @@ static int add_excludes_from_file_1(const char *fname,
int baselen,
struct exclude_list *which)
{
struct stat st;
int fd, i;
long size;
char *buf, *entry;

fd = open(fname, O_RDONLY);
if (fd < 0)
if (fd < 0 || fstat(fd, &st) < 0)
goto err;
size = lseek(fd, 0, SEEK_END);
if (size < 0)
goto err;
lseek(fd, 0, SEEK_SET);
size = st.st_size;
if (size == 0) {
close(fd);
return 0;
Expand Down

0 comments on commit c470701

Please sign in to comment.