From: Anthony PERARD <anthony.perard@citrix.com>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: qemu-devel@nongnu.org, alistair23@gmail.com, armbru@redhat.com,
Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: [Qemu-devel] [PATCH v2 42/47] hw/xen*: Replace fprintf(stderr, "*\n" with error_report()
Date: Tue, 10 Oct 2017 16:13:20 +0100 [thread overview]
Message-ID: <20171010151320.GK1771@perard.uk.xensource.com> (raw)
In-Reply-To: <73617234cd9894007428b8aaaa46b0744b997e0c.1506730372.git.alistair.francis@xilinx.com>
On Fri, Sep 29, 2017 at 05:17:12PM -0700, Alistair Francis wrote:
> Replace a large number of the fprintf(stderr, "*\n" calls with
> error_report(). The functions were renamed with these commands and then
> compiler issues where manually fixed.
> diff --git a/hw/xen/xen-common.c b/hw/xen/xen-common.c
> index 632a938dcc..42ada2ac05 100644
> --- a/hw/xen/xen-common.c
> +++ b/hw/xen/xen-common.c
> @@ -9,6 +9,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/error-report.h"
> #include "hw/xen/xen_backend.h"
> #include "qmp-commands.h"
> #include "chardev/char.h"
> @@ -47,19 +48,19 @@ static int store_dev_info(int domid, Chardev *cs, const char *string)
> /* We now have everything we need to set the xenstore entry. */
> xs = xs_open(0);
> if (xs == NULL) {
> - fprintf(stderr, "Could not contact XenStore\n");
> + error_report("Could not contact XenStore");
> goto out;
> }
>
> path = xs_get_domain_path(xs, domid);
> if (path == NULL) {
> - fprintf(stderr, "xs_get_domain_path() error\n");
> + error_report("xs_get_domain_path() error");
> goto out;
> }
> newpath = realloc(path, (strlen(path) + strlen(string) +
> strlen("/tty") + 1));
> if (newpath == NULL) {
> - fprintf(stderr, "realloc error\n");
> + error_report("realloc error");
> goto out;
> }
> path = newpath;
> @@ -96,13 +97,13 @@ static void xenstore_record_dm_state(struct xs_handle *xs, const char *state)
> char path[50];
>
> if (xs == NULL) {
> - fprintf(stderr, "xenstore connection not initialized\n");
> + error_report("xenstore connection not initialized");
> exit(1);
> }
>
> snprintf(path, sizeof (path), "device-model/%u/state", xen_domid);
> if (!xs_write(xs, XBT_NULL, path, state, strlen(state))) {
> - fprintf(stderr, "error recording dm state\n");
> + error_report("error recording dm state");
> exit(1);
> }
> }
> diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
> index 375efa68f6..e86d380d02 100644
> --- a/hw/xen/xen_pt.c
> +++ b/hw/xen/xen_pt.c
> @@ -73,7 +73,7 @@ void xen_pt_log(const PCIDevice *d, const char *f, ...)
>
> va_start(ap, f);
> if (d) {
> - fprintf(stderr, "[%02x:%02x.%d] ", pci_bus_num(d->bus),
> + error_report("[%02x:%02x.%d] ", pci_bus_num(d->bus),
This is only part of a line of a comment, this is going to be more
complecated that just calling error_repport, right?
> PCI_SLOT(d->devfn), PCI_FUNC(d->devfn));
> }
> vfprintf(stderr, f, ap);
The second part of the line is printed here.
> @@ -87,7 +87,7 @@ static int xen_pt_pci_config_access_check(PCIDevice *d, uint32_t addr, int len)
> /* check offset range */
> if (addr > 0xFF) {
> XEN_PT_ERR(d, "Failed to access register with offset exceeding 0xFF. "
> - "(addr: 0x%02x, len: %d)\n", addr, len);
> + "(addr: 0x%02x, len: %d)", addr, len);
If xen_pt_log is changed, there would be many more of the XEN_PT_ERR
call to change. (as well as XEN_PT_LOG and XEN_PT_WARN.)
> return -1;
> }
>
> diff --git a/hw/xenpv/xen_domainbuild.c b/hw/xenpv/xen_domainbuild.c
> index 027f76fad1..f5514ffec2 100644
> --- a/hw/xenpv/xen_domainbuild.c
> +++ b/hw/xenpv/xen_domainbuild.c
> @@ -25,22 +25,22 @@ static int xenstore_domain_mkdir(char *path)
> int i;
>
> if (!xs_mkdir(xenstore, 0, path)) {
> - fprintf(stderr, "%s: xs_mkdir %s: failed\n", __func__, path);
> - return -1;
> + error_report("%s: xs_mkdir %s: failed", __func__, path);
> + return -1;
> }
> if (!xs_set_permissions(xenstore, 0, path, perms_ro, 2)) {
> - fprintf(stderr, "%s: xs_set_permissions failed\n", __func__);
> - return -1;
> + error_report("%s: xs_set_permissions failed", __func__);
> + return -1;
> }
>
> for (i = 0; writable[i]; i++) {
> snprintf(subpath, sizeof(subpath), "%s/%s", path, writable[i]);
> if (!xs_mkdir(xenstore, 0, subpath)) {
> - fprintf(stderr, "%s: xs_mkdir %s: failed\n", __func__, subpath);
> + error_report("%s: xs_mkdir %s: failed", __func__, subpath);
> return -1;
> }
> if (!xs_set_permissions(xenstore, 0, subpath, perms_rw, 2)) {
> - fprintf(stderr, "%s: xs_set_permissions failed\n", __func__);
> + error_report("%s: xs_set_permissions failed", __func__);
> return -1;
> }
> }
> @@ -235,7 +235,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
> memcpy(uuid, &qemu_uuid, sizeof(uuid));
> rc = xen_domain_create(xen_xc, ssidref, uuid, flags, &xen_domid);
> if (rc < 0) {
> - fprintf(stderr, "xen: xc_domain_create() failed\n");
> + error_report("xen: xc_domain_create() failed");
> goto err;
> }
> qemu_log("xen: created domain %d\n", xen_domid);
> @@ -248,21 +248,21 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
>
> rc = xc_domain_max_vcpus(xen_xc, xen_domid, smp_cpus);
> if (rc < 0) {
> - fprintf(stderr, "xen: xc_domain_max_vcpus() failed\n");
> + error_report("xen: xc_domain_max_vcpus() failed");
> goto err;
> }
>
> #if 0
> rc = xc_domain_setcpuweight(xen_xc, xen_domid, 256);
> if (rc < 0) {
> - fprintf(stderr, "xen: xc_domain_setcpuweight() failed\n");
> + error_report("xen: xc_domain_setcpuweight() failed");
> goto err;
> }
> #endif
>
> rc = xc_domain_setmaxmem(xen_xc, xen_domid, ram_size >> 10);
> if (rc < 0) {
> - fprintf(stderr, "xen: xc_domain_setmaxmem() failed\n");
> + error_report("xen: xc_domain_setmaxmem() failed");
> goto err;
> }
>
> @@ -275,7 +275,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
> xenstore_port, &xenstore_mfn,
> console_port, &console_mfn);
> if (rc < 0) {
> - fprintf(stderr, "xen: xc_linux_build() failed\n");
> + error_report("xen: xc_linux_build() failed");
> goto err;
> }
>
> @@ -285,7 +285,7 @@ int xen_domain_build_pv(const char *kernel, const char *ramdisk,
> qemu_log("xen: unpausing domain %d\n", xen_domid);
> rc = xc_domain_unpause(xen_xc, xen_domid);
> if (rc < 0) {
> - fprintf(stderr, "xen: xc_domain_unpause() failed\n");
> + error_report("xen: xc_domain_unpause() failed");
> goto err;
> }
>
> diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c
> index 69a52a9f93..44d67b87c4 100644
> --- a/hw/xenpv/xen_machine_pv.c
> +++ b/hw/xenpv/xen_machine_pv.c
> @@ -23,6 +23,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/error-report.h"
> #include "hw/hw.h"
> #include "hw/boards.h"
> #include "hw/xen/xen_backend.h"
> @@ -36,7 +37,7 @@ static void xen_init_pv(MachineState *machine)
>
> /* Initialize backend core & drivers */
> if (xen_be_init() != 0) {
> - fprintf(stderr, "%s: xen backend core setup failed\n", __func__);
> + error_report("%s: xen backend core setup failed", __func__);
> exit(1);
> }
>
> @@ -51,18 +52,18 @@ static void xen_init_pv(MachineState *machine)
> const char *initrd_filename = machine->initrd_filename;
> if (xen_domain_build_pv(kernel_filename, initrd_filename,
> kernel_cmdline) < 0) {
> - fprintf(stderr, "xen pv domain creation failed\n");
> + error_report("xen pv domain creation failed");
> exit(1);
> }
> break;
> }
> #endif
> case XEN_EMULATE:
> - fprintf(stderr, "xen emulation not implemented (yet)\n");
> + error_report("xen emulation not implemented (yet)");
> exit(1);
> break;
> default:
> - fprintf(stderr, "unhandled xen_mode %d\n", xen_mode);
> + error_report("unhandled xen_mode %d", xen_mode);
> exit(1);
> break;
> }
The rest of the patch looks good.
Thanks,
--
Anthony PERARD
next prev parent reply other threads:[~2017-10-10 21:31 UTC|newest]
Thread overview: 99+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-30 0:14 [Qemu-devel] [PATCH v2 00/47] Remove some of the fprintf(stderr, "* Alistair Francis
2017-09-30 0:14 ` [Qemu-devel] [PATCH v2 01/47] Replace all occurances of __FUNCTION__ with __func__ Alistair Francis
2017-10-02 14:11 ` Stefan Hajnoczi
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 02/47] Fixes after renaming __FUNCTION__ to __func__ Alistair Francis
2017-09-30 6:31 ` Thomas Huth
2017-10-02 14:00 ` Eric Blake
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 03/47] audio: Replace AUDIO_FUNC with __func__ Alistair Francis
2017-09-30 6:35 ` Thomas Huth
2017-10-02 14:08 ` Eric Blake
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 04/47] tests: Replace fprintf(stderr, "*\n" with error_report() Alistair Francis
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 05/47] hw/arm: " Alistair Francis
2017-09-30 2:46 ` [Qemu-devel] [Qemu-arm] " Philippe Mathieu-Daudé
2017-10-16 11:41 ` [Qemu-devel] " Thomas Huth
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 06/47] hw/block: " Alistair Francis
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 07/47] hw/bt: " Alistair Francis
2017-10-01 14:06 ` Thomas Huth
2017-10-17 18:32 ` Alistair Francis
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 08/47] hw/char: " Alistair Francis
2017-10-01 14:09 ` Thomas Huth
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 09/47] hw/core: " Alistair Francis
2017-10-01 1:56 ` Philippe Mathieu-Daudé
2017-10-01 14:11 ` Thomas Huth
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 10/47] hw/cris: " Alistair Francis
2017-10-01 14:13 ` Thomas Huth
2017-10-16 11:42 ` Thomas Huth
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 11/47] hw/display: " Alistair Francis
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 12/47] hw/dma: " Alistair Francis
2017-10-01 1:55 ` Philippe Mathieu-Daudé
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 13/47] hw/gpio: " Alistair Francis
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 14/47] hw/i2c: " Alistair Francis
2017-10-01 1:52 ` Philippe Mathieu-Daudé
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 16/47] hw/ide: " Alistair Francis
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 17/47] hw/input: " Alistair Francis
2017-10-16 11:43 ` Thomas Huth
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 18/47] hw/intc: " Alistair Francis
2017-10-04 7:34 ` Cornelia Huck
2017-09-30 0:15 ` [Qemu-devel] [PATCH v2 19/47] hw/ipmi: " Alistair Francis
2017-10-01 1:50 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 20/47] hw/isa: " Alistair Francis
2017-10-01 1:48 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 21/47] hw/lm32: " Alistair Francis
2017-10-01 1:48 ` Philippe Mathieu-Daudé
2017-10-16 11:45 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 22/47] hw/m68k: " Alistair Francis
2017-09-30 6:42 ` Thomas Huth
2017-10-16 11:25 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 23/47] hw/microblaze: " Alistair Francis
2017-09-30 2:43 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 24/47] hw/mips: " Alistair Francis
2017-09-30 2:36 ` Philippe Mathieu-Daudé
2017-10-16 11:46 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 25/47] hw/misc: " Alistair Francis
2017-10-01 1:47 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 26/47] hw/moxie: " Alistair Francis
2017-10-01 1:46 ` Philippe Mathieu-Daudé
2017-10-16 11:47 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 27/47] hw/net: " Alistair Francis
2017-10-01 1:46 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 28/47] hw/nios2: " Alistair Francis
2017-09-30 2:39 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 29/47] hw/nvram: " Alistair Francis
2017-09-30 6:50 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 30/47] hw/openrisc: " Alistair Francis
2017-09-30 19:05 ` Stafford Horne
2017-10-16 11:50 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 31/47] hw/pci*: " Alistair Francis
2017-10-01 1:43 ` Philippe Mathieu-Daudé
2017-10-01 8:11 ` Marcel Apfelbaum
2017-10-02 18:15 ` Alistair Francis
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 32/47] hw/ppc: " Alistair Francis
2017-10-04 6:11 ` David Gibson
2017-10-16 11:53 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 33/47] hw/s390x: " Alistair Francis
2017-10-16 11:55 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 34/47] hw/scsi: " Alistair Francis
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 35/47] hw/sd: " Alistair Francis
2017-10-01 1:41 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 36/47] hw/sh4: " Alistair Francis
2017-10-16 11:56 ` Thomas Huth
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 37/47] hw/sparc*: " Alistair Francis
2017-09-30 2:40 ` Philippe Mathieu-Daudé
2017-09-30 0:16 ` [Qemu-devel] [PATCH v2 38/47] hw/ssi: " Alistair Francis
2017-10-01 1:38 ` Philippe Mathieu-Daudé
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 39/47] hw/timer: " Alistair Francis
2017-10-01 1:37 ` Philippe Mathieu-Daudé
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 40/47] hw/usb: " Alistair Francis
2017-10-01 1:36 ` Philippe Mathieu-Daudé
2017-10-01 14:16 ` Thomas Huth
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 41/47] hw/watchdog: " Alistair Francis
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 42/47] hw/xen*: " Alistair Francis
2017-10-10 15:13 ` Anthony PERARD [this message]
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 43/47] util: " Alistair Francis
2017-09-30 2:43 ` Philippe Mathieu-Daudé
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 44/47] ui: " Alistair Francis
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 45/47] tcg: " Alistair Francis
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 46/47] target: Use qemu_log() instead of fprintf(stderr, ...) Alistair Francis
2017-09-30 0:17 ` [Qemu-devel] [PATCH v2 47/47] target: Replace fprintf(stderr, "*\n" with error_report() Alistair Francis
2017-10-04 7:41 ` Cornelia Huck
[not found] ` <ade26715c9bde1fe921959823de08da582fce58f.1506730372.git.alistair.francis@xilinx.com>
2017-10-10 14:51 ` [Qemu-devel] [PATCH v2 15/47] hw/i386: " Anthony PERARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171010151320.GK1771@perard.uk.xensource.com \
--to=anthony.perard@citrix.com \
--cc=alistair.francis@xilinx.com \
--cc=alistair23@gmail.com \
--cc=armbru@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sstabellini@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).