[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v4 28/45] hw/nvram: Replace fprintf(stderr, "*\n
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH v4 28/45] hw/nvram: Replace fprintf(stderr, "*\n" with error_report() |
Date: |
Wed, 8 Nov 2017 20:39:49 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 11/08/2017 07:58 PM, 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.
>
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N;N; {s|fprintf(stderr,
> "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}'
> \
> {} +
> find ./* -type f -exec sed -i \
> 'N;N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
> find ./* -type f -exec sed -i \
> 'N; {s|fprintf(stderr, "\(.*\)\\n"\(.*\));|error_report("\1"\2);|Ig}' \
> {} +
>
> Some lines where then manually tweaked to pass checkpatch.
>
> Some of the message in put_unused() was removed and replaced with
> g_assert_not_reached().
>
> Signed-off-by: Alistair Francis <address@hidden>
> ---
> V3:
> - Add g_assert_not_reached() in unused function
> V2:
> - Split hw patch into individual directories
>
> hw/nvram/eeprom93xx.c | 5 +++--
> hw/nvram/fw_cfg.c | 5 +++--
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/hw/nvram/eeprom93xx.c b/hw/nvram/eeprom93xx.c
> index 2fd0e3c29f..5cad031eba 100644
> --- a/hw/nvram/eeprom93xx.c
> +++ b/hw/nvram/eeprom93xx.c
> @@ -36,6 +36,7 @@
> */
>
> #include "qemu/osdep.h"
> +#include "qemu/error-report.h"
> #include "hw/hw.h"
> #include "hw/nvram/eeprom93xx.h"
>
> @@ -105,8 +106,8 @@ static int get_uint16_from_uint8(QEMUFile *f, void *pv,
> size_t size,
> static int put_unused(QEMUFile *f, void *pv, size_t size, VMStateField
> *field,
> QJSON *vmdesc)
> {
> - fprintf(stderr, "uint16_from_uint8 is used only for backwards
> compatibility.\n");
> - fprintf(stderr, "Never should be used to write a new state.\n");
> + error_report("uint16_from_uint8 is used only for backwards
> compatibility.");
> + error_report("Never should be used to write a new state.");
Sounds like funny english :)
> exit(0);
Why not use g_assert_not_reached() for consistency?
>
> return 0;
> diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
> index 753ac0e4ea..1c66052f1f 100644
> --- a/hw/nvram/fw_cfg.c
> +++ b/hw/nvram/fw_cfg.c
> @@ -518,8 +518,9 @@ static int get_uint32_as_uint16(QEMUFile *f, void *pv,
> size_t size,
> static int put_unused(QEMUFile *f, void *pv, size_t size, VMStateField
> *field,
> QJSON *vmdesc)
> {
> - fprintf(stderr, "uint32_as_uint16 is only used for backward
> compatibility.\n");
> - fprintf(stderr, "This functions shouldn't be called.\n");
> + error_report("uint32_as_uint16 is only used for backward
> compatibility.");
> +
> + g_assert_not_reached();
>
> return 0;
> }
>
- Re: [Qemu-devel] [PATCH v4 18/45] hw/intc: Replace fprintf(stderr, "*\n" with error_report(), (continued)
- [Qemu-devel] [PATCH v4 02/45] Replace all occurances of __FUNCTION__ with __func__, Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 22/45] hw/microblaze: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 21/45] hw/lm32: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 23/45] hw/mips: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 25/45] hw/moxie: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 27/45] hw/nios2: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 26/45] hw/net: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 24/45] hw/misc: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 28/45] hw/nvram: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- Re: [Qemu-devel] [PATCH v4 28/45] hw/nvram: Replace fprintf(stderr, "*\n" with error_report(),
Philippe Mathieu-Daudé <=
- [Qemu-devel] [PATCH v4 29/45] hw/openrisc: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 30/45] hw/pci*: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 32/45] hw/s390x: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 33/45] hw/scsi: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 31/45] hw/ppc: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 34/45] hw/sd: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 35/45] hw/sh4: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08
- [Qemu-devel] [PATCH v4 36/45] hw/sparc*: Replace fprintf(stderr, "*\n" with error_report(), Alistair Francis, 2017/11/08