[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 3/8] tools/xenalyze: Handle fstat errors properly
They're pretty unlikely to fail, but doesn't hurt to check. CID 1311502 CID 1311501 Signed-off-by: George Dunlap <george.dunlap@xxxxxxxxxx> --- CC: Ian Jackson <ian.jackson@xxxxxxxxxx> CC: Wei Liu <wei.liu2@xxxxxxxxxx> --- tools/xentrace/mread.c | 9 ++++++++- tools/xentrace/xenalyze.c | 5 ++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/xentrace/mread.c b/tools/xentrace/mread.c index a22c4ea..c6f6ec6 100644 --- a/tools/xentrace/mread.c +++ b/tools/xentrace/mread.c @@ -24,9 +24,16 @@ mread_handle_t mread_init(int fd) h->fd = fd; - fstat(fd, &s); + if ( fstat(fd, &s) ) { + perror("fstat"); + free(h); + h = NULL; + goto out; + } + h->file_size = s.st_size; +out: return h; } diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 33f8129..9f8c065 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -10348,7 +10348,10 @@ int main(int argc, char *argv[]) { error(ERR_SYSTEM, NULL); } else { struct stat s; - fstat(G.fd, &s); + if ( fstat(G.fd, &s) ) { + perror("fstat"); + error(ERR_SYSTEM, NULL); + } G.file_size = s.st_size; } -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |