Use fstat instead of fseek
Signed-off-by: Jonas Fonseca <fonseca@diku.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>maint
parent
5ff9d11409
commit
c470701a98
8
dir.c
8
dir.c
|
@ -112,17 +112,15 @@ static int add_excludes_from_file_1(const char *fname,
|
||||||
int baselen,
|
int baselen,
|
||||||
struct exclude_list *which)
|
struct exclude_list *which)
|
||||||
{
|
{
|
||||||
|
struct stat st;
|
||||||
int fd, i;
|
int fd, i;
|
||||||
long size;
|
long size;
|
||||||
char *buf, *entry;
|
char *buf, *entry;
|
||||||
|
|
||||||
fd = open(fname, O_RDONLY);
|
fd = open(fname, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0 || fstat(fd, &st) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
size = lseek(fd, 0, SEEK_END);
|
size = st.st_size;
|
||||||
if (size < 0)
|
|
||||||
goto err;
|
|
||||||
lseek(fd, 0, SEEK_SET);
|
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue