summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2011-02-02 08:58:45 -0800
committerAlan Coopersmith <alan.coopersmith@oracle.com>2011-02-02 14:20:48 -0800
commit50f4107811249806718a100f9d34f996c58e5e25 (patch)
treebfef24b3ac738a96b6eabe39abab60791a97f6ab
parent5e9c40fcb5da43c9fdacf12967d090bf202daf2a (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.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/Xrm.c b/src/Xrm.c
index 4892b64b..c466cae7 100644
--- a/src/Xrm.c
+++ b/src/Xrm.c
@@ -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;