[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH] pc: Use fstat in get_file_size()
From: |
Fabien Siron |
Subject: |
[Qemu-trivial] [PATCH] pc: Use fstat in get_file_size() |
Date: |
Wed, 1 Jun 2016 14:23:04 +0000 |
As mentioned in the comment, fstat is quite simpler than playing with
ftell() and fseek().
Signed-off-by: Fabien Siron <address@hidden>
---
hw/i386/pc.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 99437e0..fecb067 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -801,16 +801,13 @@ static FWCfgState *bochs_bios_init(AddressSpace *as,
PCMachineState *pcms)
static long get_file_size(FILE *f)
{
- long where, size;
+ struct stat stat;
+ int fd;
- /* XXX: on Unix systems, using fstat() probably makes more sense */
+ fd = fileno(f);
+ fstat(fd, &stat);
- where = ftell(f);
- fseek(f, 0, SEEK_END);
- size = ftell(f);
- fseek(f, where, SEEK_SET);
-
- return size;
+ return stat.st_size;
}
static void load_linux(PCMachineState *pcms,
--
2.8.0
- [Qemu-trivial] [PATCH] pc: Use fstat in get_file_size(),
Fabien Siron <=