More warning reporting fixed
Subsystems (4)
cover More warning reporting fixed
This series expands on my previous series by converting more existing prints to use warn_report() instead of error_report() or fprintf().
Alistair Francis (5):
hw/i386: Improve some of the warning messages Convert remaining error_report() to warn_report() Convert single line fprintf() to warn_report() Convert multi-line fprintf() to warn_report() Convert single line fprintf() to warn_report()
accel/kvm/kvm-all.c | 7 +++---- block/qcow2.c | 10 +++++----- block/vvfat.c | 8 +++++--- hw/acpi/core.c | 10 +++++----- hw/arm/vexpress.c | 4 ++-- hw/i386/acpi-build.c | 15 ++++++++++----- hw/i386/pc.c | 9 ++++----- hw/i386/pc_q35.c | 8 +++++--- hw/i386/xen/xen-mapcache.c | 4 ++-- hw/mips/mips_malta.c | 4 ++-- hw/mips/mips_r4k.c | 7 ++++--- hw/misc/applesmc.c | 2 +- hw/s390x/s390-virtio.c | 16 ++++++++-------- hw/usb/hcd-ehci.c | 5 +++-- hw/virtio/virtio-balloon.c | 3 ++- net/hub.c | 12 ++++++------ net/net.c | 14 +++++++------- net/socket.c | 7 +++++-- qga/vss-win32.c | 2 +- target/i386/cpu.c | 12 ++++++------ target/i386/hax-mem.c | 6 +++--- target/mips/kvm.c | 4 ++-- target/ppc/translate_init.c | 18 +++++++++--------- target/s390x/kvm.c | 4 ++-- tests/Makefile.include | 4 ++-- trace/control.c | 4 ++-- trace/simple.c | 2 +- ui/keymaps.c | 11 ++++++----- ui/spice-display.c | 2 +- util/cutils.c | 3 ++- util/main-loop.c | 6 +++--- 31 files changed, 119 insertions(+), 104 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/5 hw/i386: Improve some of the warning messages
---
V3:
- Improve the messages
hw/i386/acpi-build.c | 15 ++++++++++----- hw/i386/pc.c | 7 +++---- hw/i386/pc_q35.c | 8 +++++--- 3 files changed, 18 insertions(+), 12 deletions(-)
hw/i386/acpi-build.c +10 -5
@@ -2766,17 +2766,22 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) ACPI_BUILD_ALIGN_SIZE);if (tables_blob->len > legacy_table_size) {/* Should happen only with PCI bridges and -M pc-i440fx-2.0. */ -warn_report ("migration may not work." ); +warn_report ("ACPI table size %u exceeds %d bytes," +" migration may not work" , + tables_blob->len, legacy_table_size); +error_printf ("Try removing CPUs, NUMA nodes, memory slots" +" or PCI bridges." ); }g_array_set_size (tables_blob, legacy_table_size); }else {/* Make sure we have a buffer in case we need to resize the tables. */ if (tables_blob->len >ACPI_BUILD_TABLE_SIZE /2 ) {/* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots. */ -warn_report ("ACPI tables are larger than 64k." ); -warn_report ("migration may not work." ); -warn_report ("please remove CPUs, NUMA nodes, " -"memory slots or PCI bridges." ); +warn_report ("ACPI table size %u exceeds %d bytes," +" migration may not work" , + tables_blob->len,ACPI_BUILD_TABLE_SIZE /2 ); +error_printf ("Try removing CPUs, NUMA nodes, memory slots" +" or PCI bridges." ); }acpi_align_size (tables_blob,ACPI_BUILD_TABLE_SIZE ); }
hw/i386/pc.c +3 -4
@@ -384,7 +384,7 @@ ISADevice *pc_find_fdc0(void)warn_report ("multiple floppy disk controllers with " "iobase=0x3f0 have been found" );error_printf ("the one being picked for CMOS setup might not reflect " -"your intent\n" ); +"your intent" ); }return state.floppy;
@@ -2085,9 +2085,8 @@ static void pc_machine_set_max_ram_below_4g(Object *obj, Visitor *v, }if (value < (1ULL <<20 )) { -warn_report ("small max_ram_below_4g(%" PRIu64 -") less than 1M. BIOS may not work.." , - value); +warn_report ("Only %" PRIu64" bytes of RAM below the 4GiB boundary," +"BIOS may not work with less than 1MiB" , value); } pcms->max_ram_below_4g = value;
hw/i386/pc_q35.c +5 -3
@@ -101,9 +101,11 @@ static void pc_q35_init(MachineState *machine) lowmem = pcms->max_ram_below_4g;if (machine->ram_size - lowmem > lowmem && lowmem & ((1ULL <<30 ) -1 )) { -warn_report ("Large machine and max_ram_below_4g(%" PRIu64 -") not a multiple of 1G; possible bad performance." , - pcms->max_ram_below_4g); +warn_report ("Large machine as the ram size (0x%" PRIx64") is more" +" then twice the size of the internal limit" +" (0x%" PRIx64") and max-ram-below-4g (%" PRIu64")" +" note a multiple of 1G; possible bad performance." , + machine->ram_size, lowmem, pcms->max_ram_below_4g); } }
Signature · 1 line
2.11.0
PATCH 2/5 Convert remaining error_report() to warn_report()
In reply to Alistair FrancisIn a previous patch (3dc6f8693694a649a9c83f1e2746565b47683923) we converted uses of error_report("warning:"... to use warn_report() instead. This was to help standardise on a single method of printing warnings to the user.
There appears to have been some cases that slipped through in patch sets applied around the same time, this patch catches the few remaining cases.
All of the warnings were changed using this command:
find ./* -type f -exec sed -i \
's|error_report(".*warning[,:] |warn_report("|Ig' {} +Indentation fixed up manually afterwards.
---
block/qcow2.c | 10 +++++----- target/s390x/kvm.c | 4 ++-- trace/control.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)
block/qcow2.c +5 -5
@@ -302,11 +302,11 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, }if (!(s->autoclear_features &QCOW2_AUTOCLEAR_BITMAPS )) { -error_report ("WARNING: a program lacking bitmap support " -"modified this file, so all bitmaps are now " -"considered inconsistent. Some clusters may be " -"leaked, run 'qemu-img check -r' on the image " -"file to fix." ); +warn_report ("a program lacking bitmap support " +"modified this file, so all bitmaps are now " +"considered inconsistent. Some clusters may be " +"leaked, run 'qemu-img check -r' on the image " +"file to fix." );if (need_update_header !=NULL ) {/* Updating is needed to drop invalid bitmap extension. */ *need_update_header = true;
target/s390x/kvm.c +2 -2
@@ -222,8 +222,8 @@ static void kvm_s390_enable_cmma(void) };if (mem_path) { -error_report ("Warning: CMM will not be enabled because it is not " -"compatible to hugetlbfs." ); +warn_report ("CMM will not be enabled because it is not " +"compatible to hugetlbfs." );return ; } rc =kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr);
trace/control.c +2 -2
@@ -72,8 +72,8 @@ void trace_event_register_group(TraceEvent **events)if (likely (next_vcpu_id <CPU_TRACE_DSTATE_MAX_EVENTS )) { events[i]->vcpu_id = next_vcpu_id++; }else { -error_report ("WARNING: too many vcpu trace events; dropping '%s'" , - events[i]->name); +warn_report ("too many vcpu trace events; dropping '%s'" , + events[i]->name); } } event_groups =g_renew (TraceEventGroup, event_groups, nevent_groups +1 );
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v1 2/5] Convert remaining error_report() to warn_report()
Quoted 15 lines · On Wed, 26 Jul 2017 09:07:52 -0700 Alistair Francis…
In a previous patch (
3dc6f8693694a649a9c83f1e2746565b47683923) we converted uses of error_report("warning:"... to usewarn_report()instead. This was to help standardise on a single method of printing warnings to the user.There appears to have been some cases that slipped through in patch sets applied around the same time, this patch catches the few remaining cases.
All of the warnings were changed using this command:
find ./* -type f -exec sed -i \ 's|error_report(".*warning[,:] |warn_report("|Ig' {} +Indentation fixed up manually afterwards.
Quoted 8 lines
Signed-off-by Alistair Francis <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Cornelia Huck <[email protected]>Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Cc Stefan Hajnoczi <[email protected]>
Hm, the automatic cc:ing does not seem to have worked.
Quoted 13 lines
---
block/qcow2.c | 10 +++++----- target/s390x/kvm.c | 4 ++-- trace/control.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)target/s390x/kvm.c +0
-0
target/s390x/kvm.c static void kvm_s390_enable_cmma(void) · line 229
Quoted 10 lines
target/s390x/kvm.c +2
-2@@ -222,8 +222,8 @@ static void kvm_s390_enable_cmma(void) };if (mem_path) { -error_report ("Warning: CMM will not be enabled because it is not " -"compatible to hugetlbfs." ); +warn_report ("CMM will not be enabled because it is not " +"compatible to hugetlbfs." );return ; } rc =kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr);
s390x part:
Re: [Qemu-devel] [PATCH v1 2/5] Convert remaining error_report() to warn_report()
In reply to Alistair FrancisQuoted 38 lines · Alistair Francis
In a previous patch (
3dc6f8693694a649a9c83f1e2746565b47683923) we converted uses of error_report("warning:"... to usewarn_report()instead. This was to help standardise on a single method of printing warnings to the user.There appears to have been some cases that slipped through in patch sets applied around the same time, this patch catches the few remaining cases.
All of the warnings were changed using this command:
find ./* -type f -exec sed -i \ 's|error_report(".*warning[,:] |warn_report("|Ig' {} +Indentation fixed up manually afterwards.
Signed-off-by Alistair Francis <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Cornelia Huck <[email protected]>Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Cc Stefan Hajnoczi <[email protected]>---
block/qcow2.c | 10 +++++----- target/s390x/kvm.c | 4 ++-- trace/control.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)block/qcow2.c +0
-0@@ -302,11 +302,11 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, }if (!(s->autoclear_features &QCOW2_AUTOCLEAR_BITMAPS )) {
block/qcow2.c static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, · line 309
Quoted 10 lines
block/qcow2.c +5
-5-error_report ("WARNING: a program lacking bitmap support " -"modified this file, so all bitmaps are now " -"considered inconsistent. Some clusters may be " -"leaked, run 'qemu-img check -r' on the image " -"file to fix." ); +warn_report ("a program lacking bitmap support " +"modified this file, so all bitmaps are now " +"considered inconsistent. Some clusters may be " +"leaked, run 'qemu-img check -r' on the image " +"file to fix." );
This message is awfully long. What about splitting it while we're there:
warn_report("a program lacking bitmap support "
"modified this file, so all bitmaps are now " "considered inconsistent");
error_printf("Some clusters may be "leaked, "
"run 'qemu-img check -r' on the image " "file to fix.");
Quoted 8 lines
block/qcow2.c +0
-0if (need_update_header !=NULL ) {/* Updating is needed to drop invalid bitmap extension. */ *need_update_header = true;target/s390x/kvm.c +0
-0
target/s390x/kvm.c static void kvm_s390_enable_cmma(void) · line 226
Quoted 7 lines
target/s390x/kvm.c +2
-2@@ -222,8 +222,8 @@ static void kvm_s390_enable_cmma(void) };if (mem_path) { -error_report ("Warning: CMM will not be enabled because it is not " -"compatible to hugetlbfs." ); +warn_report ("CMM will not be enabled because it is not " +"compatible to hugetlbfs." );
Not a native speaker, but here goes anyway: "compatible with".
Quoted 8 lines
target/s390x/kvm.c +0
-0return ; } rc =kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr);trace/control.c +0
-0
trace/control.c void trace_event_register_group(TraceEvent **events) · line 79
Quoted 10 lines
trace/control.c +2
-2@@ -72,8 +72,8 @@ void trace_event_register_group(TraceEvent **events)if (likely (next_vcpu_id <CPU_TRACE_DSTATE_MAX_EVENTS )) { events[i]->vcpu_id = next_vcpu_id++; }else { -error_report ("WARNING: too many vcpu trace events; dropping '%s'" , - events[i]->name); +warn_report ("too many vcpu trace events; dropping '%s'" , + events[i]->name); } } event_groups =g_renew (TraceEventGroup, event_groups, nevent_groups +1 );
The nits I picked predate your patch, so:
Re: [Qemu-devel] [PATCH v1 2/5] Convert remaining error_report() to warn_report()
Quoted 98 lines · Markus Armbruster
Quoted 38 lines · Alistair Francis
In a previous patch (
3dc6f8693694a649a9c83f1e2746565b47683923) we converted uses of error_report("warning:"... to usewarn_report()instead. This was to help standardise on a single method of printing warnings to the user.There appears to have been some cases that slipped through in patch sets applied around the same time, this patch catches the few remaining cases.
All of the warnings were changed using this command:
find ./* -type f -exec sed -i \ 's|error_report(".*warning[,:] |warn_report("|Ig' {} +Indentation fixed up manually afterwards.
Signed-off-by Alistair Francis <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Cornelia Huck <[email protected]>Cc Alexander Graf <[email protected]>Cc Richard Henderson <[email protected]>Cc Stefan Hajnoczi <[email protected]>---
block/qcow2.c | 10 +++++----- target/s390x/kvm.c | 4 ++-- trace/control.c | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-)block/qcow2.c +0
-0@@ -302,11 +302,11 @@ static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, }if (!(s->autoclear_features &QCOW2_AUTOCLEAR_BITMAPS )) {block/qcow2.c static int qcow2_read_extensions(BlockDriverState *bs, uint64_t start_offset, · line 309
Quoted 10 lines
block/qcow2.c +5
-5-error_report ("WARNING: a program lacking bitmap support " -"modified this file, so all bitmaps are now " -"considered inconsistent. Some clusters may be " -"leaked, run 'qemu-img check -r' on the image " -"file to fix." ); +warn_report ("a program lacking bitmap support " +"modified this file, so all bitmaps are now " +"considered inconsistent. Some clusters may be " +"leaked, run 'qemu-img check -r' on the image " +"file to fix." );This message is awfully long. What about splitting it while we're there:
warn_report("a program lacking bitmap support "
"modified this file, so all bitmaps are now " "considered inconsistent");
error_printf("Some clusters may be "leaked, "
"run 'qemu-img check -r' on the image " "file to fix.");Quoted 8 lines
block/qcow2.c +0
-0if (need_update_header !=NULL ) {/* Updating is needed to drop invalid bitmap extension. */ *need_update_header = true;target/s390x/kvm.c +0
-0target/s390x/kvm.c static void kvm_s390_enable_cmma(void) · line 226
Quoted 7 lines
target/s390x/kvm.c +2
-2@@ -222,8 +222,8 @@ static void kvm_s390_enable_cmma(void) };if (mem_path) { -error_report ("Warning: CMM will not be enabled because it is not " -"compatible to hugetlbfs." ); +warn_report ("CMM will not be enabled because it is not " +"compatible to hugetlbfs." );Not a native speaker, but here goes anyway: "compatible with".
Quoted 8 lines
target/s390x/kvm.c +0
-0return ; } rc =kvm_vm_ioctl (kvm_state,KVM_SET_DEVICE_ATTR , &attr);trace/control.c +0
-0trace/control.c void trace_event_register_group(TraceEvent **events) · line 79
Quoted 10 lines
trace/control.c +2
-2@@ -72,8 +72,8 @@ void trace_event_register_group(TraceEvent **events)if (likely (next_vcpu_id <CPU_TRACE_DSTATE_MAX_EVENTS )) { events[i]->vcpu_id = next_vcpu_id++; }else { -error_report ("WARNING: too many vcpu trace events; dropping '%s'" , - events[i]->name); +warn_report ("too many vcpu trace events; dropping '%s'" , + events[i]->name); } } event_groups =g_renew (TraceEventGroup, event_groups, nevent_groups +1 );The nits I picked predate your patch, so:
Quoted 1 line
Reviewed-by Markus Armbruster <[email protected]>
Thanks, I fixed up the changes you mentioned as well.
Thanks,
Alistair
PATCH 3/5 Convert single line fprintf() to warn_report()
In reply to Alistair FrancisConvert all the single line uses of fprintf(stderr, "warning:"..."\n"... to use warn_report() instead. This helps standardise on a single method of printing warnings to the user.
All of the warnings were changed using this command:
find ./* -type f -exec sed -i \
's|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig' \
{} +Some of the lines were manually edited to reduce the line length to below 80 charecters.
The #include lines were manually updated to allow the code to compile.
---
block/vvfat.c | 4 +++- hw/acpi/core.c | 3 ++- hw/i386/pc.c | 2 +- hw/misc/applesmc.c | 2 +- hw/usb/hcd-ehci.c | 5 +++-- hw/virtio/virtio-balloon.c | 3 ++- net/hub.c | 3 ++- net/socket.c | 7 +++++-- qga/vss-win32.c | 2 +- target/mips/kvm.c | 4 ++-- trace/simple.c | 2 +- ui/keymaps.c | 2 +- ui/spice-display.c | 2 +- 13 files changed, 25 insertions(+), 16 deletions(-)
block/vvfat.c +3 -1
@@ -32,6 +32,7 @@#include "qapi/qmp/qbool.h" #include "qapi/qmp/qstring.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" #ifndef S_IWGRP #define S_IWGRP 0
@@ -3028,7 +3029,8 @@ DLOG(checkpoint());if (memcmp (direntries + k,array_get (&(s->directory), dir_index + k),sizeof (direntry_t))) { -fprintf (stderr,"Warning: tried to write to write-protected file\n" ); +warn_report ("tried to write to write-protected " +"file" );return -1 ; } }
hw/acpi/core.c +2 -1
@@ -28,6 +28,7 @@#include "qapi/opts-visitor.h" #include "qapi-visit.h" #include "qapi-event.h" +#include "qemu/error-report.h" struct acpi_table_header {uint16_t _length;/* our length, not actual part of the hdr */
@@ -221,7 +222,7 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen, }if (!has_header && changed_fields ==0 ) { -fprintf (stderr,"warning: ACPI table: no headers are specified\n" ); +warn_report ("ACPI table: no headers are specified" ); }/* recalculate checksum */
hw/i386/pc.c +1 -1
@@ -1310,7 +1310,7 @@ void pc_acpi_init(const char *default_dsdt) filename =qemu_find_file (QEMU_FILE_TYPE_BIOS , default_dsdt);if (filename ==NULL ) { -fprintf (stderr,"WARNING: failed to find %s\n" , default_dsdt); +warn_report ("failed to find %s" , default_dsdt); }else {QemuOpts *opts =qemu_opts_create (qemu_find_opts ("acpi" ),NULL ,0 , &error_abort);
hw/misc/applesmc.c +1 -1
@@ -331,7 +331,7 @@ static void applesmc_isa_realize(DeviceState *dev, Error **errp) s->iobase + APPLESMC_ERR_PORT);if (!s->osk || (strlen (s->osk) !=64 )) { -fprintf (stderr,"WARNING: Using AppleSMC with invalid key\n" ); +warn_report ("Using AppleSMC with invalid key" ); s->osk = default_osk; }
hw/usb/hcd-ehci.c +3 -2
@@ -32,6 +32,7 @@#include "hw/usb/ehci-regs.h" #include "hw/usb/hcd-ehci.h" #include "trace.h" +#include "qemu/error-report.h" #define FRAME_TIMER_FREQ 1000#define FRAME_TIMER_NS (NANOSECONDS_PER_SECOND / FRAME_TIMER_FREQ)
@@ -348,7 +349,7 @@ static void ehci_trace_sitd(EHCIState *s, hwaddr addr,static void ehci_trace_guest_bug (EHCIState *s,const char *message) {trace_usb_ehci_guest_bug (message); -fprintf (stderr,"ehci warning: %s\n" , message); +warn_report ("%s" , message); }static inline bool ehci_enabled (EHCIState *s)
@@ -1728,7 +1729,7 @@ static int ehci_state_fetchsitd(EHCIState *ehci, int async)/* siTD is not active, nothing to do */ ; }else {/* TODO: split transfers are not implemented */ -fprintf (stderr,"WARNING: Skipping active siTD\n" ); +warn_report ("Skipping active siTD" ); }ehci_set_fetch_addr (ehci, async, sitd.next);
hw/virtio/virtio-balloon.c +2 -1
@@ -26,6 +26,7 @@#include "qapi/visitor.h" #include "qapi-event.h" #include "trace.h" +#include "qemu/error-report.h" #include "hw/virtio/virtio-bus.h" #include "hw/virtio/virtio-access.h"
@@ -292,7 +293,7 @@ static void virtio_balloon_receive_stats(VirtIODevice *vdev, VirtQueue *vq) s->stats_vq_offset = offset;if (qemu_gettimeofday (&tv) <0 ) { -fprintf (stderr,"warning: %s: failed to get time of day\n" , __func__); +warn_report ("%s: failed to get time of day" , __func__); goto out; }
net/hub.c +2 -1
@@ -18,6 +18,7 @@#include "clients.h" #include "hub.h" #include "qemu/iov.h" +#include "qemu/error-report.h" /* * A hub broadcasts incoming packets to all its ports except the source port.
@@ -330,7 +331,7 @@ void net_hub_check_clients(void) } }if (has_host_dev && !has_nic) { -fprintf (stderr,"Warning: vlan %d with no nics\n" , hub->id); +warn_report ("vlan %d with no nics" , hub->id); }if (has_nic && !has_host_dev) { fprintf(stderr,
net/socket.c +5 -2
@@ -449,8 +449,11 @@ static NetSocketState *net_socket_fd_init(NetClientState *peer,case SOCK_STREAM :return net_socket_fd_init_stream (peer, model, name, fd, is_connected);default : -/* who knows ... this could be a eg. a pty, do warn and continue as stream */ -fprintf (stderr,"qemu: warning: socket type=%d for fd=%d is not SOCK_DGRAM or SOCK_STREAM\n" , so_type, fd); +/* who knows ... this could be a eg. a pty, do warn and continue as +* stream +*/ +warn_report ("socket type=%d for fd=%d is not SOCK_DGRAM or " +"SOCK_STREAM" , so_type, fd);return net_socket_fd_init_stream (peer, model, name, fd, is_connected); }return NULL ;
qga/vss-win32.c +1 -1
@@ -61,7 +61,7 @@ static bool vss_check_os_version(void) return false; }if (wow64) { -fprintf (stderr,"Warning: Running under WOW64\n" ); +warn_report ("Running under WOW64" ); }#endif return !wow64;
target/mips/kvm.c +2 -2
@@ -95,11 +95,11 @@ void kvm_mips_reset_vcpu(MIPSCPU *cpu)CPUMIPSState *env = &cpu->env;if (!kvm_mips_fpu_cap && env->CP0_Config1 & (1 <<CP0C1_FP )) { -fprintf (stderr,"Warning: KVM does not support FPU, disabling\n" ); +warn_report ("KVM does not support FPU, disabling" ); env->CP0_Config1 &= ~(1 <<CP0C1_FP ); }if (!kvm_mips_msa_cap && env->CP0_Config3 & (1 <<CP0C3_MSAP )) { -fprintf (stderr,"Warning: KVM does not support MSA, disabling\n" ); +warn_report ("KVM does not support MSA, disabling" ); env->CP0_Config3 &= ~(1 <<CP0C3_MSAP ); }
trace/simple.c +1 -1
@@ -405,7 +405,7 @@ bool st_init(void) thread =trace_thread_create (writeout_thread);if (!thread) { -fprintf (stderr,"warning: unable to initialize simple trace backend\n" ); +warn_report ("unable to initialize simple trace backend" );return false; }
ui/keymaps.c +1 -1
@@ -141,7 +141,7 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,int keysym; keysym =get_keysym (table, keyname);if (keysym ==0 ) { -/* fprintf(stderr, "Warning: unknown keysym %s\n", line);*/ +/* warn_report("unknown keysym %s", line);*/ }else {const char *rest = line + offset +1 ;int keycode =strtol (rest,NULL ,0 );
ui/spice-display.c +1 -1
@@ -850,7 +850,7 @@ static void qemu_spice_gl_unblock_bh(void *opaque)static void qemu_spice_gl_block_timer (void *opaque) { -fprintf (stderr,"WARNING: spice: no gl-draw-done within one second\n" ); +warn_report ("spice: no gl-draw-done within one second" ); }static void spice_gl_refresh (DisplayChangeListener *dcl)
Signature · 1 line
2.11.0
PATCH 4/5 Convert multi-line fprintf() to warn_report()
In reply to Alistair FrancisConvert all the multi-line uses of fprintf(stderr, "warning:"..."\n"... to use warn_report() instead. This helps standardise on a single method of printing warnings to the user.
All of the warnings were changed using these commands:
find ./* -type f -exec sed -i \
'N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +
find ./* -type f -exec sed -i \
'N;N;N;N;N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \
{} +Indentation fixed up manually afterwards.
Some of the lines were manually edited to reduce the line length to below 80 charecters. Some of the lines with newlines in the middle of the string were also manually edit to avoid checkpatch errrors.
The #include lines were manually updated to allow the code to compile.
---
I couldn't figure out any nice way (it is possible with some more logic inside the sed apparently) to do this is one command, so I had to use all of the commands above.
accel/kvm/kvm-all.c | 7 +++---- block/vvfat.c | 4 ++-- hw/acpi/core.c | 7 +++---- hw/arm/vexpress.c | 4 ++-- hw/i386/xen/xen-mapcache.c | 4 ++-- hw/mips/mips_malta.c | 4 ++-- hw/mips/mips_r4k.c | 7 ++++--- hw/s390x/s390-virtio.c | 16 ++++++++-------- net/hub.c | 9 ++++----- net/net.c | 14 +++++++------- target/i386/cpu.c | 12 ++++++------ target/i386/hax-mem.c | 6 +++--- target/ppc/translate_init.c | 18 +++++++++--------- ui/keymaps.c | 9 +++++---- util/main-loop.c | 6 +++--- 15 files changed, 63 insertions(+), 64 deletions(-)
accel/kvm/kvm-all.c +3 -4
@@ -1629,10 +1629,9 @@ static int kvm_init(MachineState *ms)while (nc->name) {if (nc->num > soft_vcpus_limit) { -fprintf (stderr, -"Warning: Number of %s cpus requested (%d) exceeds " -"the recommended cpus supported by KVM (%d)\n" , - nc->name, nc->num, soft_vcpus_limit); +warn_report ("Number of %s cpus requested (%d) exceeds " +"the recommended cpus supported by KVM (%d)" , + nc->name, nc->num, soft_vcpus_limit);if (nc->num > hard_vcpus_limit) { fprintf(stderr, "Number of %s cpus requested (%d) exceeds "
block/vvfat.c +2 -2
@@ -1227,8 +1227,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,switch (s->fat_type) {case 32 : -fprintf (stderr,"Big fat greek warning: FAT32 has not been tested. " -"You are welcome to do so!\n" ); +warn_report ("FAT32 has not been tested. " +"You are welcome to do so!" );break ;case 16 :case 12 :
hw/acpi/core.c +3 -4
@@ -184,10 +184,9 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen, }if (has_header &&le32_to_cpu (ext_hdr->length) != acpi_payload_size) { -fprintf (stderr, -"warning: ACPI table has wrong length, header says " -"%" PRIu32", actual size %zu bytes\n" , -le32_to_cpu (ext_hdr->length), acpi_payload_size); +warn_report ("ACPI table has wrong length, header says " +"%" PRIu32", actual size %zu bytes" , +le32_to_cpu (ext_hdr->length), acpi_payload_size); } ext_hdr->length =cpu_to_le32 (acpi_payload_size);
hw/arm/vexpress.c +2 -2
@@ -491,8 +491,8 @@ static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt)/* Not fatal, we just won't provide virtio. This will * happen with older device tree blobs. */ -fprintf (stderr,"QEMU: warning: couldn't find interrupt controller in " -"dtb; will not include virtio-mmio devices in the dtb.\n" ); +warn_report ("couldn't find interrupt controller in " +"dtb; will not include virtio-mmio devices in the dtb." ); }else {int i;const hwaddr *map = daughterboard->motherboard_map;
hw/i386/xen/xen-mapcache.c +2 -2
@@ -125,8 +125,8 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) rlimit_as.rlim_cur = rlimit_as.rlim_max;if (rlimit_as.rlim_max !=RLIM_INFINITY ) { -fprintf (stderr,"Warning: QEMU's maximum size of virtual" -" memory is not infinity.\n" ); +warn_report ("QEMU's maximum size of virtual" +" memory is not infinity." ); }if (rlimit_as.rlim_max <MCACHE_MAX_SIZE +NON_MCACHE_MEMORY_SIZE ) { mapcache->max_mcache_size = rlimit_as.rlim_max -
hw/mips/mips_malta.c +2 -2
@@ -216,8 +216,8 @@ static void generate_eeprom_spd(uint8_t *eeprom, ram_addr_t ram_size) }if (ram_size) { -fprintf (stderr,"Warning: SPD cannot represent final %dMB" -" of SDRAM\n" , (int )ram_size); +warn_report ("SPD cannot represent final %dMB" +" of SDRAM" , (int )ram_size); }/* fill in SPD memory information */
hw/mips/mips_r4k.c +4 -3
@@ -31,6 +31,7 @@#include "sysemu/block-backend.h" #include "exec/address-spaces.h" #include "sysemu/qtest.h" +#include "qemu/error-report.h" #define MAX_IDE_BUS 2
@@ -251,9 +252,9 @@ void mips_r4k_init(MachineState *machine)fprintf (stderr,"qemu: Error registering flash memory.\n" ); } }else if (!qtest_enabled ()) { -/* not fatal */ -fprintf (stderr,"qemu: Warning, could not load MIPS bios '%s'\n" , - bios_name); +/* not fatal */ +warn_report ("could not load MIPS bios '%s'" , + bios_name); }g_free (filename);
hw/s390x/s390-virtio.c +8 -8
@@ -146,9 +146,9 @@ void gtod_save(QEMUFile *f, void *opaque) r =s390_get_clock (&tod_high, &tod_low);if (r) { -fprintf (stderr,"WARNING: Unable to get guest clock for migration. " -"Error code %d. Guest clock will not be migrated " -"which could cause the guest to hang.\n" , r); +warn_report ("Unable to get guest clock for migration. " +"Error code %d. Guest clock will not be migrated " +"which could cause the guest to hang." , r);qemu_put_byte (f,S390_TOD_CLOCK_VALUE_MISSING );return ; }
@@ -165,8 +165,8 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id)int r;if (qemu_get_byte (f) ==S390_TOD_CLOCK_VALUE_MISSING ) { -fprintf (stderr,"WARNING: Guest clock was not migrated. This could " -"cause the guest to hang.\n" ); +warn_report ("Guest clock was not migrated. This could " +"cause the guest to hang." );return 0 ; }
@@ -175,9 +175,9 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id) r =s390_set_clock (&tod_high, &tod_low);if (r) { -fprintf (stderr,"WARNING: Unable to set guest clock value. " -"s390_get_clock returned error %d. This could cause " -"the guest to hang.\n" , r); +warn_report ("Unable to set guest clock value. " +"s390_get_clock returned error %d. This could cause " +"the guest to hang." , r); }return 0 ;
net/hub.c +4 -5
@@ -310,8 +310,8 @@ void net_hub_check_clients(void) QLIST_FOREACH(port, &hub->ports, next) { peer = port->nc.peer;if (!peer) { -fprintf (stderr,"Warning: hub port %s has no peer\n" , - port->nc.name); +warn_report ("hub port %s has no peer" , + port->nc.name);continue ; }
@@ -334,9 +334,8 @@ void net_hub_check_clients(void)warn_report ("vlan %d with no nics" , hub->id); }if (has_nic && !has_host_dev) { -fprintf (stderr, -"Warning: vlan %d is not connected to host network\n" , - hub->id); +warn_report ("vlan %d is not connected to host network" , + hub->id); } } }
net/net.c +7 -7
@@ -1481,9 +1481,9 @@ void net_check_clients(void) QTAILQ_FOREACH(nc, &net_clients, next) {if (!nc->peer) { -fprintf (stderr,"Warning: %s %s has no peer\n" , - nc->info->type ==NET_CLIENT_DRIVER_NIC ? -"nic" :"netdev" , nc->name); +warn_report ("%s %s has no peer" , + nc->info->type ==NET_CLIENT_DRIVER_NIC ? +"nic" :"netdev" , nc->name); } }
@@ -1494,10 +1494,10 @@ void net_check_clients(void)for (i =0 ; i <MAX_NICS ; i++) {NICInfo *nd = &nd_table[i];if (nd->used && !nd->instantiated) { -fprintf (stderr,"Warning: requested NIC (%s, model %s) " -"was not created (not supported by this machine?)\n" , - nd->name ? nd->name :"anonymous" , - nd->model ? nd->model :"unspecified" ); +warn_report ("requested NIC (%s, model %s) " +"was not created (not supported by this machine?)" , + nd->name ? nd->name :"anonymous" , + nd->model ? nd->model :"unspecified" ); } } }
target/i386/cpu.c +6 -6
@@ -1710,12 +1710,12 @@ static void report_unavailable_features(FeatureWord w, uint32_t mask)if ((1UL << i) & mask) {const char *reg =get_register_name_32 (f->cpuid_reg);assert (reg); -fprintf (stderr,"warning: %s doesn't support requested feature: " -"CPUID.%02XH:%s%s%s [bit %d]\n" , -kvm_enabled () ?"host" :"TCG" , - f->cpuid_eax, reg, - f->feat_names[i] ?"." :"" , - f->feat_names[i] ? f->feat_names[i] :"" , i); +warn_report ("%s doesn't support requested feature: " +"CPUID.%02XH:%s%s%s [bit %d]" , +kvm_enabled () ?"host" :"TCG" , + f->cpuid_eax, reg, + f->feat_names[i] ?"." :"" , + f->feat_names[i] ? f->feat_names[i] :"" , i); } } }
target/i386/hax-mem.c +3 -3
@@ -178,9 +178,9 @@ static void hax_process_section(MemoryRegionSection *section, uint8_t flags)if (!memory_region_is_ram (mr)) {if (memory_region_is_romd (mr)) {/* HAXM kernel module does not support ROMD yet */ -fprintf (stderr,"%s: Warning: Ignoring ROMD region 0x%016" PRIx64 -"->0x%016" PRIx64"\n" , __func__, start_pa, - start_pa + size); +warn_report ("Ignoring ROMD region 0x%016" PRIx64 +"->0x%016" PRIx64"" , __func__, start_pa, + start_pa + size); }return ; }
target/ppc/translate_init.c +9 -9
@@ -9215,14 +9215,14 @@ static void init_ppc_proc(PowerPCCPU *cpu) env->tlb_per_way = env->nb_tlb / env->nb_ways; }if (env->irq_inputs ==NULL ) { -fprintf (stderr,"WARNING: no internal IRQ controller registered.\n" -" Attempt QEMU to crash very soon !\n" ); +warn_report ("no internal IRQ controller registered." +" Attempt QEMU to crash very soon !" ); }#endif if (env->check_pow ==NULL ) { -fprintf (stderr,"WARNING: no power management check handler " -"registered.\n" -" Attempt QEMU to crash very soon !\n" ); +warn_report ("no power management check handler " +"registered." +" Attempt QEMU to crash very soon !" ); } }
@@ -9776,10 +9776,10 @@ static int ppc_fixup_cpu(PowerPCCPU *cpu)* tree. */ if ((env->insns_flags & ~PPC_TCG_INSNS ) || (env->insns_flags2 & ~PPC_TCG_INSNS2 )) { -fprintf (stderr,"Warning: Disabling some instructions which are not " -"emulated by TCG (0x%" PRIx64", 0x%" PRIx64")\n" , - env->insns_flags & ~PPC_TCG_INSNS , - env->insns_flags2 & ~PPC_TCG_INSNS2 ); +warn_report ("Disabling some instructions which are not " +"emulated by TCG (0x%" PRIx64", 0x%" PRIx64")" , + env->insns_flags & ~PPC_TCG_INSNS , + env->insns_flags2 & ~PPC_TCG_INSNS2 ); } env->insns_flags &=PPC_TCG_INSNS ; env->insns_flags2 &=PPC_TCG_INSNS2 ;
ui/keymaps.c +5 -4
@@ -26,6 +26,7 @@#include "keymaps.h" #include "sysemu/sysemu.h" #include "trace.h" +#include "qemu/error-report.h" static int get_keysym (const name2keysym_t *table,const char *name)
@@ -76,8 +77,8 @@ static void add_keysym(char *line, int keysym, int keycode, kbd_layout_t *k) { k->keysym2keycode[keysym] = keycode; }else {if (k->extra_count >=MAX_EXTRA_COUNT ) { -fprintf (stderr,"Warning: Could not assign keysym %s (0x%x)" -" because of memory constraints.\n" , line, keysym); +warn_report ("Could not assign keysym %s (0x%x)" +" because of memory constraints." , line, keysym); }else {trace_keymap_add ("extra" , keysym, keycode, line); k->keysym2keycode_extra[k->extra_count].
@@ -197,8 +198,8 @@ int keysym2scancode(void *kbd_layout, int keysym)if (keysym <MAX_NORMAL_KEYCODE ) {if (k->keysym2keycode[keysym] ==0 ) {trace_keymap_unmapped (keysym); -fprintf (stderr,"Warning: no scancode found for keysym %d\n" , - keysym); +warn_report ("no scancode found for keysym %d" , + keysym); }return k->keysym2keycode[keysym]; }else {
util/main-loop.c +3 -3
@@ -32,6 +32,7 @@#include "slirp/libslirp.h" #include "qemu/main-loop.h" #include "block/aio.h" +#include "qemu/error-report.h" #ifndef _WIN32
@@ -236,9 +237,8 @@ static int os_host_main_loop_wait(int64_t timeout)static bool notified;if (!notified && !qtest_enabled () && !qtest_driver ()) { -fprintf (stderr, -"main-loop: WARNING: I/O thread spun for %d iterations\n" , -MAX_MAIN_LOOP_SPIN ); +warn_report ("I/O thread spun for %d iterations" , +MAX_MAIN_LOOP_SPIN ); notified = true; }
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v1 4/5] Convert multi-line fprintf() to warn_report()
Quoted 82 lines · On Wed, 26 Jul 2017 09:07:57 -0700 Alistair Francis…
Convert all the multi-line uses of fprintf(stderr, "warning:"..."\n"... to use
warn_report()instead. This helps standardise on a single method of printing warnings to the user.All of the warnings were changed using these commands:
find ./* -type f -exec sed -i \ 'N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} +Indentation fixed up manually afterwards.
Some of the lines were manually edited to reduce the line length to below 80 charecters. Some of the lines with newlines in the middle of the string were also manually edit to avoid checkpatch errrors.
The #include lines were manually updated to allow the code to compile.
Signed-off-by Alistair Francis <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Igor Mammedov <[email protected]>Cc Peter Maydell <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Cc Richard Henderson <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Aurelien Jarno <[email protected]>Cc Yongbok Kim <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Alexander Graf <[email protected]>Cc Jason Wang <[email protected]>Cc David Gibson <[email protected]>Cc Gerd Hoffmann <[email protected]>---
I couldn't figure out any nice way (it is possible with some more logic inside the sed apparently) to do this is one command, so I had to use all of the commands above.accel/kvm/kvm-all.c | 7 +++---- block/vvfat.c | 4 ++-- hw/acpi/core.c | 7 +++---- hw/arm/vexpress.c | 4 ++-- hw/i386/xen/xen-mapcache.c | 4 ++-- hw/mips/mips_malta.c | 4 ++-- hw/mips/mips_r4k.c | 7 ++++--- hw/s390x/s390-virtio.c | 16 ++++++++-------- net/hub.c | 9 ++++----- net/net.c | 14 +++++++------- target/i386/cpu.c | 12 ++++++------ target/i386/hax-mem.c | 6 +++--- target/ppc/translate_init.c | 18 +++++++++--------- ui/keymaps.c | 9 +++++---- util/main-loop.c | 6 +++--- 15 files changed, 63 insertions(+), 64 deletions(-)block/vvfat.c +0
-0
block/vvfat.c static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, · line 1231
Quoted 5 lines
block/vvfat.c +0
-2@@ -1227,8 +1227,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags,switch (s->fat_type) {case 32 : -fprintf (stderr,"Big fat greek warning: FAT32 has not been tested. " -"You are welcome to do so!\n" );
Kind of sad to see this one go...
Quoted 37 lines
block/vvfat.c +2
-0+warn_report ("FAT32 has not been tested. " +"You are welcome to do so!" );break ;case 16 :case 12 :hw/s390x/s390-virtio.c +5
-5@@ -146,9 +146,9 @@ void gtod_save(QEMUFile *f, void *opaque) r =s390_get_clock (&tod_high, &tod_low);if (r) { -fprintf (stderr,"WARNING: Unable to get guest clock for migration. " -"Error code %d. Guest clock will not be migrated " -"which could cause the guest to hang.\n" , r); +warn_report ("Unable to get guest clock for migration. " +"Error code %d. Guest clock will not be migrated " +"which could cause the guest to hang." , r);qemu_put_byte (f,S390_TOD_CLOCK_VALUE_MISSING );return ; }@@ -165,8 +165,8 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id)int r;if (qemu_get_byte (f) ==S390_TOD_CLOCK_VALUE_MISSING ) { -fprintf (stderr,"WARNING: Guest clock was not migrated. This could " -"cause the guest to hang.\n" ); +warn_report ("Guest clock was not migrated. This could " +"cause the guest to hang." );return 0 ; }@@ -175,9 +175,9 @@ int gtod_load(QEMUFile *f, void *opaque, int version_id) r =s390_set_clock (&tod_high, &tod_low);
hw/s390x/s390-virtio.c int gtod_load(QEMUFile *f, void *opaque, int version_id) · line 183
Quoted 10 lines
hw/s390x/s390-virtio.c +3
-3if (r) { -fprintf (stderr,"WARNING: Unable to set guest clock value. " -"s390_get_clock returned error %d. This could cause " -"the guest to hang.\n" , r); +warn_report ("Unable to set guest clock value. " +"s390_get_clock returned error %d. This could cause " +"the guest to hang." , r); }return 0 ;
s390x part:
Re: [Qemu-devel] [PATCH v1 4/5] Convert multi-line fprintf() to warn_report()
In reply to Alistair FrancisQuoted 58 lines · Alistair Francis
Convert all the multi-line uses of fprintf(stderr, "warning:"..."\n"... to use
warn_report()instead. This helps standardise on a single method of printing warnings to the user.All of the warnings were changed using these commands:
find ./* -type f -exec sed -i \ 'N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} + find ./* -type f -exec sed -i \ 'N;N;N;N;N;N;N; {s|fprintf(.*".*warning[,:] \(.*\)\\n"\(.*\));|warn_report("\1"\2);|Ig}' \ {} +Indentation fixed up manually afterwards.
Some of the lines were manually edited to reduce the line length to below 80 charecters. Some of the lines with newlines in the middle of the string were also manually edit to avoid checkpatch errrors.
The #include lines were manually updated to allow the code to compile.
Signed-off-by Alistair Francis <[email protected]>Cc Paolo Bonzini <[email protected]>Cc Kevin Wolf <[email protected]>Cc Max Reitz <[email protected]>Cc "Michael S. Tsirkin" <[email protected]>Cc Igor Mammedov <[email protected]>Cc Peter Maydell <[email protected]>Cc Stefano Stabellini <[email protected]>Cc Anthony Perard <[email protected]>Cc Richard Henderson <[email protected]>Cc Eduardo Habkost <[email protected]>Cc Aurelien Jarno <[email protected]>Cc Yongbok Kim <[email protected]>Cc Cornelia Huck <[email protected]>Cc Christian Borntraeger <[email protected]>Cc Alexander Graf <[email protected]>Cc Jason Wang <[email protected]>Cc David Gibson <[email protected]>Cc Gerd Hoffmann <[email protected]>---
I couldn't figure out any nice way (it is possible with some more logic inside the sed apparently) to do this is one command, so I had to use all of the commands above.
[...]
Quoted 5 lines
hw/i386/xen/xen-mapcache.c +0
-0
hw/i386/xen/xen-mapcache.c void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) · line 132
Quoted 10 lines
hw/i386/xen/xen-mapcache.c +2
-2@@ -125,8 +125,8 @@ void xen_map_cache_init(phys_offset_to_gaddr_t f, void *opaque) rlimit_as.rlim_cur = rlimit_as.rlim_max;if (rlimit_as.rlim_max !=RLIM_INFINITY ) { -fprintf (stderr,"Warning: QEMU's maximum size of virtual" -" memory is not infinity.\n" ); +warn_report ("QEMU's maximum size of virtual" +" memory is not infinity." ); }if (rlimit_as.rlim_max <MCACHE_MAX_SIZE +NON_MCACHE_MEMORY_SIZE ) { mapcache->max_mcache_size = rlimit_as.rlim_max -
warning: implicit declaration of function ‘warn_report’ [-Wimplicit-function-declaration]
Please double-check for warnings.
[...]
PATCH 5/5 Convert single line fprintf() to warn_report()
In reply to Alistair FrancisConvert any remaining uses of fprintf(stderr, "warning:"... to use warn_report() instead. This helps standardise on a single method of printing warnings to the user.
All of the warnings were changed using this command:
find ./* -type f -exec sed -i 's|fprintf(.*".*warning[,:] |warn_report("|Ig' {} +
The #include lines and chagnes to the test Makefile were manually updated to allow the code to compile.
---
tests/Makefile.include | 4 ++-- util/cutils.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
tests/Makefile.include +2 -2
@@ -560,8 +560,8 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y) tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o -tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y) -tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o +tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-qom-obj-y) +tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-qom-obj-y) tests/test-int128$(EXESUF): tests/test-int128.o tests/rcutorture$(EXESUF): tests/rcutorture.o $(test-util-obj-y) tests/test-rcu-list$(EXESUF): tests/test-rcu-list.o $(test-util-obj-y)
util/cutils.c +2 -1
@@ -30,6 +30,7 @@#include "qemu/iov.h" #include "net/net.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" void strpadcpy (char *buf,int buf_size,const char *str,char pad) {
@@ -601,7 +602,7 @@ int parse_debug_env(const char *name, int max, int initial)return initial; }if (debug <0 || debug > max || errno !=0 ) { -fprintf (stderr,"warning: %s not in [0, %d]" , name, max); +warn_report ("%s not in [0, %d]" , name, max);return initial; }return debug;
Signature · 1 line
2.11.0
Re: [Qemu-devel] [PATCH v1 5/5] Convert single line fprintf() to warn_report()
Quoted 22 lines · Alistair Francis
Convert any remaining uses of fprintf(stderr, "warning:"... to use
warn_report()instead. This helps standardise on a single method of printing warnings to the user.All of the warnings were changed using this command:
find ./* -type f -exec sed -i 's|fprintf(.*".*warning[,:] |warn_report("|Ig' {} +The #include lines and chagnes to the test
Makefilewere manually updated to allow the code to compile.Signed-off-by Alistair Francis <[email protected]>---
tests/Makefile.include | 4 ++-- util/cutils.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)tests/Makefile.include +0
-0
tests/Makefile.include tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) · line 564
Quoted 7 lines
tests/Makefile.include +2
-2@@ -560,8 +560,8 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y) tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o -tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y) -tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o +tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-qom-obj-y) +tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-qom-obj-y)
This doesn't look right to me - $(test-qom-obj-y) is the same as $(test-util-obj-y), but with $(qom-obj-y) added. AFAIK, your warn_report function doesn't use any code from $(qom-obj-y), so we should not need to link to that. So I think there's something else going on here.
Quoted 25 lines
util/cutils.c +2
-1@@ -30,6 +30,7 @@#include "qemu/iov.h" #include "net/net.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" void strpadcpy (char *buf,int buf_size,const char *str,char pad) {@@ -601,7 +602,7 @@ int parse_debug_env(const char *name, int max, int initial)return initial; }if (debug <0 || debug > max || errno !=0 ) { -fprintf (stderr,"warning: %s not in [0, %d]" , name, max); +warn_report ("%s not in [0, %d]" , name, max);return initial; }return debug;Signature · 1 line
2.11.0
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH v1 5/5] Convert single line fprintf() to warn_report()
Quoted 28 lines · Daniel P. Berrange
Quoted 27 lines · Alistair Francis
Convert any remaining uses of fprintf(stderr, "warning:"... to use
warn_report()instead. This helps standardise on a single method of printing warnings to the user.All of the warnings were changed using this command:
find ./* -type f -exec sed -i 's|fprintf(.*".*warning[,:] |warn_report("|Ig' {} +The #include lines and chagnes to the test
Makefilewere manually updated to allow the code to compile.Signed-off-by Alistair Francis <[email protected]>---
tests/Makefile.include | 4 ++-- util/cutils.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)tests/Makefile.include +0
-2@@ -560,8 +560,8 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y) tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o -tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y) -tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o
Quoted 8 lines
tests/Makefile.include tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) · line 564
Quoted 2 lines
tests/Makefile.include +2
-0+tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-qom-obj-y) +tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-qom-obj-y)This doesn't look right to me - $(test-qom-obj-y) is the same as $(test-util-obj-y), but with $(qom-obj-y) added. AFAIK, your
warn_reportfunction doesn't use any code from $(qom-obj-y), so we should not need to link to that. So I think there's something else going on here.
The problem I was seeing is that monitor_get_fd() is getting called in stubs/monitor.c which then requires error_setg_internal() to be linked in. Apparently this doesn't happen without this change as I kept seeing linker errors.
Thanks,
Alistair
Quoted 33 lines
Quoted 23 lines
util/cutils.c +2
-2@@ -30,6 +30,7 @@#include "qemu/iov.h" #include "net/net.h" #include "qemu/cutils.h" +#include "qemu/error-report.h" void strpadcpy (char *buf,int buf_size,const char *str,char pad) {@@ -601,7 +602,7 @@ int parse_debug_env(const char *name, int max, int initial)return initial; }if (debug <0 || debug > max || errno !=0 ) { -fprintf (stderr,"warning: %s not in [0, %d]" , name, max); +warn_report ("%s not in [0, %d]" , name, max);return initial; }return debug; --Quoted 3 lines
2.11.0
Regards,
Daniel
--|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH v1 5/5] Convert single line fprintf() to warn_report()
Quoted 38 lines · Alistair Francis
Quoted 28 lines · Daniel P. Berrange
Quoted 27 lines · Alistair Francis
Convert any remaining uses of fprintf(stderr, "warning:"... to use
warn_report()instead. This helps standardise on a single method of printing warnings to the user.All of the warnings were changed using this command:
find ./* -type f -exec sed -i 's|fprintf(.*".*warning[,:] |warn_report("|Ig' {} +The #include lines and chagnes to the test
Makefilewere manually updated to allow the code to compile.Signed-off-by Alistair Francis <[email protected]>---
tests/Makefile.include | 4 ++-- util/cutils.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)tests/Makefile.include +0
-2@@ -560,8 +560,8 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y) tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o -tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y) -tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.oQuoted 8 lines
tests/Makefile.include tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) · line 564
Quoted 2 lines
tests/Makefile.include +2
-0+tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-qom-obj-y) +tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-qom-obj-y)This doesn't look right to me - $(test-qom-obj-y) is the same as $(test-util-obj-y), but with $(qom-obj-y) added. AFAIK, your
warn_reportfunction doesn't use any code from $(qom-obj-y), so we should not need to link to that. So I think there's something else going on here.
Quoted 4 lines
The problem I was seeing is that
monitor_get_fd()is getting called instubs/monitor.cwhich then requireserror_setg_internal()to be linked in. Apparently this doesn't happen without this change as I kept seeing linker errors.
That's bizarre because error_setg_internal is included in libqemuutil.la that we're already linking to.
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Re: [Qemu-devel] [PATCH v1 5/5] Convert single line fprintf() to warn_report()
Quoted 39 lines · Daniel P. Berrange
Quoted 38 lines · Alistair Francis
Quoted 36 lines · Daniel P. Berrange
Quoted 22 lines · Alistair Francis
Convert any remaining uses of fprintf(stderr, "warning:"... to use
warn_report()instead. This helps standardise on a single method of printing warnings to the user.All of the warnings were changed using this command:
find ./* -type f -exec sed -i 's|fprintf(.*".*warning[,:] |warn_report("|Ig' {} +The #include lines and chagnes to the test
Makefilewere manually updated to allow the code to compile.Signed-off-by Alistair Francis <[email protected]>---
tests/Makefile.include | 4 ++-- util/cutils.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)tests/Makefile.include +0
-0tests/Makefile.include tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) · line 564
Quoted 7 lines
tests/Makefile.include +2
-2@@ -560,8 +560,8 @@ tests/test-thread-pool$(EXESUF): tests/test-thread-pool.o $(test-block-obj-y) tests/test-iov$(EXESUF): tests/test-iov.o $(test-util-obj-y) tests/test-hbitmap$(EXESUF): tests/test-hbitmap.o $(test-util-obj-y) $(test-crypto-obj-y) tests/test-x86-cpuid$(EXESUF): tests/test-x86-cpuid.o -tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-util-obj-y) -tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o +tests/test-xbzrle$(EXESUF): tests/test-xbzrle.o migration/xbzrle.o migration/page_cache.o $(test-qom-obj-y) +tests/test-cutils$(EXESUF): tests/test-cutils.o util/cutils.o $(test-qom-obj-y)This doesn't look right to me - $(test-qom-obj-y) is the same as $(test-util-obj-y), but with $(qom-obj-y) added. AFAIK, your
warn_reportfunction doesn't use any code from $(qom-obj-y), so we should not need to link to that. So I think there's something else going on here.
Quoted 7 lines
Quoted 4 lines
The problem I was seeing is that
monitor_get_fd()is getting called instubs/monitor.cwhich then requireserror_setg_internal()to be linked in. Apparently this doesn't happen without this change as I kept seeing linker errors.That's bizarre because
error_setg_internalis included in libqemuutil.la that we're already linking to.
That's what I thought too, but this is the only solution I could find. I'm open to suggestions, I'm not too familiar with all these linker scripts.
Thanks,
Alistair
Quoted 9 lines
Regards,
Daniel
--|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|