qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: qemu-devel@nongnu.org
Cc: Laszlo Ersek <lersek@redhat.com>, Jeff Cody <jcody@redhat.com>,
	Fam Zheng <famz@redhat.com>
Subject: [Qemu-devel] [PATCH 3/4] error: Clean up errors with embedded newlines (again), part 2
Date: Thu, 10 Dec 2015 18:23:51 +0100	[thread overview]
Message-ID: <1449768232-22924-4-git-send-email-armbru@redhat.com> (raw)
In-Reply-To: <1449768232-22924-1-git-send-email-armbru@redhat.com>

The arguments of error_setg() & friends should yield a short error
string without newlines.

A few places try to append additional help to the error message by
embedding newlines in the error string.  That's nice, but let's do it
the right way, with error_append_hint().  Offenders tracked down with
the Coccinelle semantic patch from commit 312fd5f.

Cc: Jeff Cody <jcody@redhat.com>
Cc: Fam Zheng <famz@redhat.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/vhdx-log.c         |  9 +++++----
 block/vmdk.c             |  9 ++++++---
 hw/i386/kvm/pci-assign.c | 12 ++++++------
 3 files changed, 17 insertions(+), 13 deletions(-)

diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 47ae4b1..2ac8693 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -786,10 +786,11 @@ int vhdx_parse_log(BlockDriverState *bs, BDRVVHDXState *s, bool *flushed,
             ret = -EPERM;
             error_setg_errno(errp, EPERM,
                              "VHDX image file '%s' opened read-only, but "
-                             "contains a log that needs to be replayed.  To "
-                             "replay the log, execute:\n qemu-img check -r "
-                             "all '%s'",
-                             bs->filename, bs->filename);
+                             "contains a log that needs to be replayed",
+                             bs->filename);
+            error_append_hint(errp,  "To replay the log, run:\n"
+                              "qemu-img check -r all '%s'\n",
+                              bs->filename);
             goto exit;
         }
         /* now flush the log */
diff --git a/block/vmdk.c b/block/vmdk.c
index b4a224e..3a4c4ed 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -794,18 +794,21 @@ static int vmdk_parse_extents(const char *desc, BlockDriverState *bs,
             goto next_line;
         } else if (!strcmp(type, "FLAT")) {
             if (matches != 5 || flat_offset < 0) {
-                error_setg(errp, "Invalid extent lines: \n%s", p);
+                error_setg(errp, "Invalid extent lines");
+                error_append_hint(errp, "%s", p);
                 return -EINVAL;
             }
         } else if (!strcmp(type, "VMFS")) {
             if (matches == 4) {
                 flat_offset = 0;
             } else {
-                error_setg(errp, "Invalid extent lines:\n%s", p);
+                error_setg(errp, "Invalid extent lines");
+                error_append_hint(errp, "%s", p);
                 return -EINVAL;
             }
         } else if (matches != 4) {
-            error_setg(errp, "Invalid extent lines:\n%s", p);
+            error_setg(errp, "Invalid extent lines");
+            error_append_hint(errp, "%s", p);
             return -EINVAL;
         }
 
diff --git a/hw/i386/kvm/pci-assign.c b/hw/i386/kvm/pci-assign.c
index 0fd6923..68622ff 100644
--- a/hw/i386/kvm/pci-assign.c
+++ b/hw/i386/kvm/pci-assign.c
@@ -812,8 +812,9 @@ static void assign_device(AssignedDevice *dev, Error **errp)
             char *cause;
 
             cause = assign_failed_examine(dev);
-            error_setg_errno(errp, -r, "Failed to assign device \"%s\"\n%s",
-                             dev->dev.qdev.id, cause);
+            error_setg_errno(errp, -r, "Failed to assign device \"%s\"",
+                             dev->dev.qdev.id);
+            error_append_hint(errp, "%s", cause);
             g_free(cause);
             break;
         }
@@ -912,11 +913,10 @@ retry:
             dev->features |= ASSIGNED_DEVICE_PREFER_MSI_MASK;
             goto retry;
         }
-        error_setg_errno(errp, -r,
-                         "Failed to assign irq for \"%s\"\n"
-                         "Perhaps you are assigning a device "
-                         "that shares an IRQ with another device?",
+        error_setg_errno(errp, -r, "Failed to assign irq for \"%s\"",
                          dev->dev.qdev.id);
+        error_append_hint(errp, "Perhaps you are assigning a device "
+                          "that shares an IRQ with another device?");
         return r;
     }
 
-- 
2.4.3

  parent reply	other threads:[~2015-12-10 17:24 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10 17:23 [Qemu-devel] [PATCH 0/4] Error reporting cleanups Markus Armbruster
2015-12-10 17:23 ` [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error string arguments (again) Markus Armbruster
2015-12-10 17:31   ` Dr. David Alan Gilbert
2015-12-10 18:16   ` Cornelia Huck
2015-12-11  9:01     ` Hailiang Zhang
2015-12-11  3:09   ` Bharata B Rao
2015-12-11  5:26   ` Fam Zheng
2015-12-10 17:23 ` [Qemu-devel] [PATCH 2/4] error: Clean up errors with embedded newlines (again), part 1 Markus Armbruster
2015-12-10 17:36   ` Laszlo Ersek
2015-12-14  9:27     ` Markus Armbruster
2015-12-10 17:23 ` Markus Armbruster [this message]
2015-12-10 17:48   ` [Qemu-devel] [PATCH 3/4] error: Clean up errors with embedded newlines (again), part 2 Laszlo Ersek
2015-12-14  9:42     ` Markus Armbruster
2015-12-15  2:03       ` Fam Zheng
2015-12-15  7:59         ` Markus Armbruster
2015-12-10 17:23 ` [Qemu-devel] [PATCH 4/4] hw/s390x: Rename local variables Error *l_err to just err Markus Armbruster
2015-12-10 18:18   ` Cornelia Huck
2015-12-11  8:07   ` David Hildenbrand
2015-12-14  9:59     ` Markus Armbruster
2015-12-14 10:15       ` Cornelia Huck
2015-12-14 10:28         ` David Hildenbrand

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=1449768232-22924-4-git-send-email-armbru@redhat.com \
    --to=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=lersek@redhat.com \
    --cc=qemu-devel@nongnu.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).