Commit 26270ab1 authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

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: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com> Reviewed-by: 's avatarJulien Cristau <jcristau@debian.org> Backported-to-NX-by: 's avatarUlrich Sibiller <uli42@gmx.de>
parent 563318af
...@@ -1599,18 +1599,13 @@ ReadInFile(_Xconst char *filename) ...@@ -1599,18 +1599,13 @@ ReadInFile(_Xconst char *filename)
*/ */
{ {
struct stat status_buffer; struct stat status_buffer;
if ( (fstat(fd, &status_buffer)) == -1 ) if ( (fstat(fd, &status_buffer)) == -1 ) {
size = -1; close (fd);
else return (char *)NULL;
} else
size = status_buffer.st_size; 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' */ if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */
close(fd); close(fd);
return (char *)NULL; return (char *)NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment