qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v8 00/14] Remove some of the fprintf(stderr, "*
@ 2018-02-03  8:43 Markus Armbruster
  2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 01/14] audio: Replace AUDIO_FUNC with __func__ Markus Armbruster
                   ` (13 more replies)
  0 siblings, 14 replies; 23+ messages in thread
From: Markus Armbruster @ 2018-02-03  8:43 UTC (permalink / raw)
  To: qemu-devel; +Cc: alistair.francis, eblake, f4bug

This is my attempt to salvage a good part of Alistair's error
reporting cleanup series

    [PATCH v6 00/29]  Remove some of the fprintf(stderr, "*

    Continue on improving QEMUs logging/error messages by removing more
    fprintf()'s.

    Unfortunatley my Coccinelle skills aren't that great so it's all done in
    some nasty regex and a little bit of manual work.

It foundered on the problem that some of its fprintf() to
error_report() conversions are inappropriate, see

    Message-ID: <87lghulqno.fsf@dusky.pond.sub.org>
    https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg04961.html

Alistair didn't feel like checking about one hundred conversions by
hand, which is understandable.  But letting the work go to waste would
be a shame, so I wrote an AWK script (see below) to extract a common
kind of obviously good conversions: the ones where the fprintf() is
followed by exit().  Judging from the diffstat, this salvages more
than half of his conversion work.  The script is not foolproof: it
keeps patch hunks containing "good" or no conversions.  Unwanted stuff
could conceivably hide there.  Please review for that.

v8:
* Cover letter: add warning about weakness of my filter script, ask
  reviewers to look out for unwanted stuff
* PATCH v7 12 dropped [Philippe]
* PATCH 02,09: Trailing punctuation in error messages trimmed [Eric]
* PATCH 10: Commit message replaced
* PATCH 14: Bogus submodule change dropped [Eric]

v7:
* Old PATCH 02,03,21 are already in master, drop
* Conversions not obviously followed by exit() dropped
  Nothing left in old PATCH 06-12,16,17,22, drop
  R-bys dropped
* Rebased, trivial conflict in the last patch resolved


#!/usr/bin/awk -f

hunk && /^\+[ \t]*error_report/ {
    n++
    er_indent = match(substr($0, 2), /[^ \t]/)
    er_nr = NR
    plus = 0
    fatal = 0
}

hunk && er_indent && /^\+/ {
    plus++
}

hunk && er_indent && /^[ \t]*exit/ {
    d = NR - er_nr - plus
    if (maxd < d)
	maxd = d
    fatal = 1
}

hunk && er_indent && match(substr($0, 2), /[^ \t]/) < er_indent {
    if (fatal)
	nf++
    er_indent = 0
}

hunk && /^[-+ ]/ {
    hunk = hunk "\n" $0
    next
}

hunk {
    if (n && nf && n != nf)
	print loc, "mixed hunk", n, nf >"/dev/stderr"
    else if (n && !nf)
	print loc, "non-fatal hunk", n, nf >"/dev/stderr"
    else if (!n || nf)
	print hunk
    hunk = ""
}

/^@@ / {
    hunk = $0
    loc = FILENAME ":" FNR ":"
    n = nf = 0
    next
}

{
    print
}

END {
    print "max distance", maxd+0 >"/dev/stderr"
}

Alistair Francis (14):
  audio: Replace AUDIO_FUNC with __func__
  hw/arm: Replace fprintf(stderr, "*\n" with error_report()
  hw/dma: Replace fprintf(stderr, "*\n" with error_report()
  hw/lm32: Replace fprintf(stderr, "*\n" with error_report()
  hw/mips: Replace fprintf(stderr, "*\n" with error_report()
  hw/moxie: Replace fprintf(stderr, "*\n" with error_report()
  hw/openrisc: Replace fprintf(stderr, "*\n" with error_report()
  hw/pci*: Replace fprintf(stderr, "*\n" with error_report()
  hw/ppc: Replace fprintf(stderr, "*\n" with error_report()
  hw/sd: Replace fprintf(stderr, "*\n" with DPRINTF()
  hw/sparc*: Replace fprintf(stderr, "*\n" with error_report()
  hw/xen*: Replace fprintf(stderr, "*\n" with error_report()
  tcg: Replace fprintf(stderr, "*\n" with error_report()
  target: Use qemu_log() instead of fprintf(stderr, ...)

 audio/alsaaudio.c            |  4 ++--
 audio/audio.c                | 40 +++++++++++++++----------------
 audio/audio_int.h            |  6 -----
 audio/audio_pt_int.c         | 28 +++++++++++-----------
 audio/audio_template.h       | 26 ++++++++++----------
 audio/dsoundaudio.c          |  2 +-
 audio/mixeng.c               |  2 +-
 audio/ossaudio.c             | 10 ++++----
 audio/paaudio.c              | 56 ++++++++++++++++++++++----------------------
 audio/sdlaudio.c             |  2 +-
 audio/wavaudio.c             |  2 +-
 cpus.c                       | 10 ++++----
 exec.c                       |  6 ++---
 hw/arm/armv7m.c              |  2 +-
 hw/arm/boot.c                | 16 ++++++-------
 hw/arm/gumstix.c             | 13 +++++-----
 hw/arm/mainstone.c           |  7 +++---
 hw/arm/musicpal.c            |  2 +-
 hw/arm/omap1.c               |  5 ++--
 hw/arm/omap2.c               |  3 ++-
 hw/arm/omap_sx1.c            |  2 +-
 hw/arm/pxa2xx.c              |  7 +++---
 hw/arm/vexpress.c            |  8 +++----
 hw/arm/z2.c                  |  6 ++---
 hw/dma/soc_dma.c             | 36 ++++++++++++++--------------
 hw/lm32/lm32_boards.c        |  7 +++---
 hw/lm32/milkymist.c          |  7 +++---
 hw/mips/mips_fulong2e.c      | 13 +++++-----
 hw/mips/mips_jazz.c          |  4 ++--
 hw/mips/mips_malta.c         | 16 ++++++-------
 hw/mips/mips_mipssim.c       | 11 ++++-----
 hw/mips/mips_r4k.c           | 16 ++++++-------
 hw/moxie/moxiesim.c          | 13 +++++-----
 hw/openrisc/openrisc_sim.c   |  4 ++--
 hw/pci-host/bonito.c         |  6 ++---
 hw/pci/pci.c                 |  4 ++--
 hw/ppc/e500.c                | 16 ++++++-------
 hw/ppc/mac_newworld.c        |  2 +-
 hw/ppc/mac_oldworld.c        |  2 +-
 hw/ppc/ppc405_boards.c       | 15 +++++-------
 hw/ppc/ppc440_bamboo.c       | 16 ++++++-------
 hw/ppc/prep.c                |  4 ++--
 hw/ppc/virtex_ml507.c        |  4 ++--
 hw/sd/sd.c                   |  7 +++---
 hw/sparc/leon3.c             | 16 ++++++-------
 hw/sparc/sun4m.c             | 16 ++++++-------
 hw/sparc64/niagara.c         |  4 ++--
 hw/sparc64/sun4u.c           | 10 ++++----
 hw/xen/xen-common.c          |  5 ++--
 hw/xenpv/xen_machine_pv.c    |  9 +++----
 target/cris/translate.c      |  2 +-
 target/ppc/translate.c       | 36 ++++++++--------------------
 target/sh4/translate.c       |  7 ++----
 target/unicore32/translate.c |  2 +-
 vl.c                         |  2 +-
 55 files changed, 271 insertions(+), 306 deletions(-)

-- 
2.13.6

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2018-02-06 17:06 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-03  8:43 [Qemu-devel] [PATCH v8 00/14] Remove some of the fprintf(stderr, "* Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 01/14] audio: Replace AUDIO_FUNC with __func__ Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 02/14] hw/arm: Replace fprintf(stderr, "*\n" with error_report() Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 03/14] hw/dma: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 04/14] hw/lm32: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 05/14] hw/mips: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 06/14] hw/moxie: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 07/14] hw/openrisc: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 08/14] hw/pci*: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 09/14] hw/ppc: " Markus Armbruster
2018-02-06 17:06   ` [Qemu-devel] [Qemu-ppc] " Thomas Huth
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 10/14] hw/sd: Replace fprintf(stderr, "*\n" with DPRINTF() Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 11/14] hw/sparc*: Replace fprintf(stderr, "*\n" with error_report() Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 12/14] hw/xen*: " Markus Armbruster
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 13/14] tcg: " Markus Armbruster
2018-02-03 20:28   ` Thomas Huth
2018-02-03  8:43 ` [Qemu-devel] [PATCH v8 14/14] target: Use qemu_log() instead of fprintf(stderr, ...) Markus Armbruster
2018-02-03 20:23   ` Thomas Huth
2018-02-05  6:33     ` Markus Armbruster
2018-02-05  6:52       ` Thomas Huth
2018-02-05 14:31         ` Markus Armbruster
2018-02-05 18:07           ` Alistair Francis
2018-02-06  8:43             ` Thomas Huth

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).