[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v3 22/30] replay: check return values of fwrite
From: |
Pavel Dovgalyuk |
Subject: |
[Qemu-devel] [RFC PATCH v3 22/30] replay: check return values of fwrite |
Date: |
Thu, 11 Jan 2018 11:27:00 +0300 |
User-agent: |
StGit/0.17.1-dirty |
This patch adds error reporting when fwrite cannot completely
save the buffer to the file.
Signed-off-by: Pavel Dovgalyuk <address@hidden>
--
v3: also check putc() return value
---
replay/replay-internal.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index a1a7686..1034d8f 100644
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -24,12 +24,23 @@
static QemuMutex lock;
/* File for replay writing */
+static bool write_error;
FILE *replay_file;
+static void replay_write_error(void)
+{
+ if (!write_error) {
+ error_report("replay write error");
+ write_error = true;
+ }
+}
+
void replay_put_byte(uint8_t byte)
{
if (replay_file) {
- putc(byte, replay_file);
+ if (putc(byte, replay_file) == EOF) {
+ replay_write_error();
+ }
}
}
@@ -62,7 +73,9 @@ void replay_put_array(const uint8_t *buf, size_t size)
{
if (replay_file) {
replay_put_dword(size);
- fwrite(buf, 1, size, replay_file);
+ if (fwrite(buf, 1, size, replay_file) != size) {
+ replay_write_error();
+ }
}
}
- [Qemu-devel] [RFC PATCH v3 13/30] icount: fixed saving/restoring of icount warp timers, (continued)
- [Qemu-devel] [RFC PATCH v3 13/30] icount: fixed saving/restoring of icount warp timers, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 14/30] target/arm/arm-powertctl: drop BQL assertions, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 15/30] cpus: push BQL lock to qemu_*_wait_io_event, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 16/30] cpus: only take BQL for sleeping threads, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 17/30] replay/replay.c: bump REPLAY_VERSION again, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 18/30] replay/replay-internal.c: track holding of replay_lock, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 19/30] replay: make locking visible outside replay code, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 20/30] replay: push replay_mutex_lock up the call tree, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 21/30] replay: don't destroy mutex at exit, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 22/30] replay: check return values of fwrite,
Pavel Dovgalyuk <=
- [Qemu-devel] [RFC PATCH v3 23/30] replay: avoid recursive call of checkpoints, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 24/30] scripts/qemu-gdb: add simple tcg lock status helper, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 25/30] util/qemu-thread-*: add qemu_lock, locked and unlock trace events, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 26/30] scripts/analyse-locks-simpletrace.py: script to analyse lock times, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 27/30] scripts/replay-dump.py: replay log dumper, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 28/30] scripts/qemu-gdb/timers.py: new helper to dump timer state, Pavel Dovgalyuk, 2018/01/11
- [Qemu-devel] [RFC PATCH v3 29/30] replay: improve replay performance, Pavel Dovgalyuk, 2018/01/11