From: Bruno Haible Date: Tue, 31 Dec 2002 13:02:48 +0000 (+0000) Subject: Don't call ftruncate() when it's not needed. X-Git-Tag: cvs-readonly~5071 X-Git-Url: http://erislabs.org.uk/gitweb/?a=commitdiff_plain;h=d2dc6c7414311181fd59bb1aa84ad4720058533e;p=gnulib.git Don't call ftruncate() when it's not needed. --- diff --git a/lib/ChangeLog b/lib/ChangeLog index 1ff4fefa5..4cbc90336 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,8 @@ +2002-12-22 Bruno Haible + + * utime.c (utime_null): No need to call ftruncate if the file was + nonempty. + 2002-12-23 Bruno Haible * memcoll.c (STRCOLL): New macro. diff --git a/lib/utime.c b/lib/utime.c index 237afde50..f5507cbcd 100644 --- a/lib/utime.c +++ b/lib/utime.c @@ -65,7 +65,7 @@ utime_null (const char *file) of patches, but that system doesn't use this code: it has utimes. || fsync (fd) < 0 */ - || ftruncate (fd, st.st_size) < 0 + || (st.st_size == 0 && ftruncate (fd, st.st_size) < 0) || close (fd) < 0) status = -1; return status;