This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] avoid stat/fstat in statvfs/fstatvfs
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Eric Wong <normalperson at yhbt dot net>
- Cc: libc-alpha at sourceware dot org, bug-gnulib at gnu dot org, Paul Eggert <eggert at cs dot ucla dot edu>
- Date: Thu, 7 Feb 2013 12:46:28 -0800 (PST)
- Subject: Re: [PATCH] avoid stat/fstat in statvfs/fstatvfs
- References: <20130130012802.GA17145@dcvr.yhbt.net><51088432.3070502@cs.ucla.edu><20130130024456.GA658@dcvr.yhbt.net><5108973C.5020408@cs.ucla.edu><20130130084928.GA23666@dcvr.yhbt.net><20130201023510.GA22735@dcvr.yhbt.net>
The substance of the change seems fine. It needs a proper ChangeLog entry.
See the glibc wiki for full instructions on posting patches.
> + struct stat64 st;
> + int r = fd >= 0 ? fstat64(fd, &st) : stat64(name, &st);
Put space before paren in those calls.
It's shorter and more common to invert the sense and use < 0.
> + if (r == -1)
> return 0;
There is no need for a variable here.
Also, it's more usual to test for failure with < 0:
if ((fd < 0 ? stat64 (name, &st) : fstat64 (fd, &st)) < 0)
return 0;
Thanks,
Roland