diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-02 08:58:45 -0800 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:24 +0200 |
commit | 26270ab1cf15520043b1d138916fce394780e279 (patch) | |
tree | 1d7dc93b9ce66e2f5b9b5233e68d82cfefe0ee5e /nx-X11/lib/X11 | |
parent | 563318af91403e1bd732141715e77c8caf6108f7 (diff) | |
download | nx-libs-26270ab1cf15520043b1d138916fce394780e279.tar.gz nx-libs-26270ab1cf15520043b1d138916fce394780e279.tar.bz2 nx-libs-26270ab1cf15520043b1d138916fce394780e279.zip |
Xrm.c: ReadInFile: refactor fstat error handling
We can simplify the fstat failure case now that the GetFileSize macro
has been expanded inline.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Julien Cristau <jcristau@debian.org>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11')
-rw-r--r-- | nx-X11/lib/X11/Xrm.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/nx-X11/lib/X11/Xrm.c b/nx-X11/lib/X11/Xrm.c index 4a47d2d0c..81fbfaf35 100644 --- a/nx-X11/lib/X11/Xrm.c +++ b/nx-X11/lib/X11/Xrm.c @@ -1599,18 +1599,13 @@ ReadInFile(_Xconst char *filename) */ { struct stat status_buffer; - if ( (fstat(fd, &status_buffer)) == -1 ) - size = -1; - else + if ( (fstat(fd, &status_buffer)) == -1 ) { + close (fd); + return (char *)NULL; + } else size = status_buffer.st_size; } - /* There might have been a problem trying to stat a file */ - if (size == -1) { - close (fd); - return (char *)NULL; - } - if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */ close(fd); return (char *)NULL; |