Patchwork [05/14] cutils: introduce qemu_fputc_err()

login
register
mail settings
Submitter Luiz Capitulino
Date May 30, 2012, 2:14 p.m.
Message ID <1338387301-10074-6-git-send-email-lcapitulino@redhat.com>
Download mbox | patch
Permalink /patch/161997/
State New
Headers show

Comments

Luiz Capitulino - May 30, 2012, 2:14 p.m.
A fputc() wrapper that takes an Error argument.

Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
---
 cutils.c      | 12 ++++++++++++
 qemu-common.h |  1 +
 2 files changed, 13 insertions(+)

Patch

diff --git a/cutils.c b/cutils.c
index 7bbd1b7..c44ead9 100644
--- a/cutils.c
+++ b/cutils.c
@@ -625,3 +625,15 @@  int qemu_fprintf_err(Error **errp, FILE *stream, const char *format, ...)
 
     return ret;
 }
+
+int qemu_fputc_err(int c, FILE *stream, Error **errp)
+{
+    int ret;
+
+    ret = fputc(c, stream);
+    if (ret == EOF) {
+        set_write_err(errp, errno);
+    }
+
+    return ret;
+}
diff --git a/qemu-common.h b/qemu-common.h
index 58c5197..895bc2b 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -211,6 +211,7 @@  int qemu_sendv(int sockfd, struct iovec *iov, int len, int iov_offset);
 
 FILE *qemu_fopen_err(const char *path, const char *mode, Error **errp);
 int qemu_fprintf_err(Error **errp, FILE *stream, const char *format, ...);
+int qemu_fputc_err(int c, FILE *stream, Error **errp);
 
 /* Error handling.  */