diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-02 08:58:45 -0800 |
---|---|---|
committer | Alan Coopersmith <alan.coopersmith@oracle.com> | 2011-02-02 14:20:48 -0800 |
commit | 50f4107811249806718a100f9d34f996c58e5e25 (patch) | |
tree | bfef24b3ac738a96b6eabe39abab60791a97f6ab | |
parent | 5e9c40fcb5da43c9fdacf12967d090bf202daf2a (diff) |
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>
-rw-r--r-- | src/Xrm.c | 13 |
1 files changed, 4 insertions, 9 deletions
@@ -1596,18 +1596,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; |