error: Clean up errors with embedded newlines (again)
authorMarkus Armbruster <armbru@redhat.com>
Fri, 18 Dec 2015 15:35:24 +0000 (16:35 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 13 Jan 2016 14:16:18 +0000 (15:16 +0100)
The arguments of error_report() should yield a short error string
without newlines.

A few places try to print additional help after the error message by
embedding newlines in the error string.  That's nice, but let's do it
the right way.  Commit 474c213 cleaned up some, but they keep coming
back.  Offenders tracked down with the Coccinelle semantic patch from
commit 312fd5f.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
hw/i386/pc.c
kvm-all.c
qemu-nbd.c

index 0e5c86ae1bcb2c389b51dfdad8ade52bb193b087..9e371867765c40214147de3ec0fe15bee4cf34f1 100644 (file)
@@ -377,8 +377,8 @@ ISADevice *pc_find_fdc0(void)
 
     if (state.multiple) {
         error_report("warning: multiple floppy disk controllers with "
-                     "iobase=0x3f0 have been found;\n"
-                     "the one being picked for CMOS setup might not reflect "
+                     "iobase=0x3f0 have been found");
+        error_printf("the one being picked for CMOS setup might not reflect "
                      "your intent");
     }
 
index bd9e7641b2df87d08824b45c2b283a141cee93d9..914888992119783d47fa69db80a5251cf623028e 100644 (file)
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -2063,9 +2063,9 @@ void kvm_device_access(int fd, int group, uint64_t attr,
                            write ? KVM_SET_DEVICE_ATTR : KVM_GET_DEVICE_ATTR,
                            &kvmattr);
     if (err < 0) {
-        error_report("KVM_%s_DEVICE_ATTR failed: %s\n"
-                     "Group %d attr 0x%016" PRIx64, write ? "SET" : "GET",
-                     strerror(-err), group, attr);
+        error_report("KVM_%s_DEVICE_ATTR failed: %s",
+                     write ? "SET" : "GET", strerror(-err));
+        error_printf("Group %d attr 0x%016" PRIx64, group, attr);
         abort();
     }
 }
index 023eacd1c8eaa182f5e7abf1a67b5b4bddfb7fc6..a4cf847976a50ee93c95966741727f13851d67b9 100644 (file)
@@ -599,9 +599,8 @@ int main(int argc, char **argv)
     }
 
     if ((argc - optind) != 1) {
-        error_report("Invalid number of argument.\n"
-                     "Try `%s --help' for more information.",
-                     argv[0]);
+        error_report("Invalid number of arguments");
+        error_printf("Try `%s --help' for more information.\n", argv[0]);
         exit(EXIT_FAILURE);
     }