A fputc() wrapper that takes an Error argument. Signed-off-by: Luiz Capitulino <lcapitul...@redhat.com> --- cutils.c | 12 ++++++++++++ qemu-common.h | 1 + 2 files changed, 13 insertions(+)
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. */ -- 1.7.10.2.565.gbd578b5