From: Ian Jackson <ian.jackson@eu.citrix.com>
To: qemu-devel@nongnu.org
Cc: "Ian Jackson" <ian.jackson@eu.citrix.com>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Eric Blake" <eblake@redhat.com>,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Alistair Francis" <alistair.francis@xilinx.com>,
"Ian Jackson" <Ian.Jackson@eu.citrix.com>
Subject: [Qemu-devel] [RFC PATCH 3/7] error reporting: Use error_report_errno in obvious places
Date: Thu, 26 Apr 2018 17:53:28 +0100 [thread overview]
Message-ID: <1524761612-5307-4-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1524761612-5307-1-git-send-email-ian.jackson@eu.citrix.com>
This patch is the result of
git-grep -l 'error_report.*strerror' | xargs perl -p -i~ ../t
with ../t containing
s{error_report\("(.*): \%s"(, .*)?, strerror\(errno\)\)\;}{error_report_errno\("$1"$2)\;}
Since this is an automatically generated patch, it does not contain
any cleanups of the occasional idiosyncratic messages. That is left
to the future.
No functional change, since error_report_errno does exactly what this
previous open-coded pattern does.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
audio/wavcapture.c | 2 +-
hw/i386/xen/xen-hvm.c | 2 +-
hw/tpm/tpm_emulator.c | 2 +-
hw/xen/xen_pt_load_rom.c | 4 ++--
migration/postcopy-ram.c | 12 ++++++------
net/tap-linux.c | 2 +-
os-posix.c | 8 ++++----
qemu-nbd.c | 4 ++--
scsi/qemu-pr-helper.c | 4 ++--
slirp/misc.c | 4 ++--
util/osdep.c | 2 +-
vl.c | 6 +++---
12 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index cf31ed6..7046365 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -66,7 +66,7 @@ static void wav_destroy (void *opaque)
}
doclose:
if (fclose (wav->f)) {
- error_report("wav_destroy: fclose failed: %s", strerror(errno));
+ error_report_errno("wav_destroy: fclose failed");
}
}
diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index caa563b..2778c92 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -414,7 +414,7 @@ go_physmap:
(start_addr + size - 1) >> TARGET_PAGE_BITS,
XEN_DOMCTL_MEM_CACHEATTR_WB);
if (rc) {
- error_report("pin_memory_cacheattr failed: %s", strerror(errno));
+ error_report_errno("pin_memory_cacheattr failed");
}
return xen_save_physmap(state, physmap);
}
diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
index 6418ef0..4345c1d 100644
--- a/hw/tpm/tpm_emulator.c
+++ b/hw/tpm/tpm_emulator.c
@@ -190,7 +190,7 @@ static int tpm_emulator_probe_caps(TPMEmulator *tpm_emu)
{
if (tpm_emulator_ctrlcmd(tpm_emu, CMD_GET_CAPABILITY,
&tpm_emu->caps, 0, sizeof(tpm_emu->caps)) < 0) {
- error_report("tpm-emulator: probing failed : %s", strerror(errno));
+ error_report_errno("tpm-emulator: probing failed ");
return -1;
}
diff --git a/hw/xen/xen_pt_load_rom.c b/hw/xen/xen_pt_load_rom.c
index 71063c4..bbfe423 100644
--- a/hw/xen/xen_pt_load_rom.c
+++ b/hw/xen/xen_pt_load_rom.c
@@ -43,12 +43,12 @@ void *pci_assign_dev_load_option_rom(PCIDevice *dev, struct Object *owner,
fp = fopen(rom_file, "r+");
if (fp == NULL) {
if (errno != ENOENT) {
- error_report("pci-assign: Cannot open %s: %s", rom_file, strerror(errno));
+ error_report_errno("pci-assign: Cannot open %s", rom_file);
}
return NULL;
}
if (fstat(fileno(fp), &st) == -1) {
- error_report("pci-assign: Cannot stat %s: %s", rom_file, strerror(errno));
+ error_report_errno("pci-assign: Cannot stat %s", rom_file);
goto close_rom;
}
diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c
index 8ceeaa2..6bfe002 100644
--- a/migration/postcopy-ram.c
+++ b/migration/postcopy-ram.c
@@ -406,14 +406,14 @@ bool postcopy_ram_supported_by_host(MigrationIncomingState *mis)
reg_struct.mode = UFFDIO_REGISTER_MODE_MISSING;
if (ioctl(ufd, UFFDIO_REGISTER, ®_struct)) {
- error_report("%s userfault register: %s", __func__, strerror(errno));
+ error_report_errno("%s userfault register", __func__);
goto out;
}
range_struct.start = (uintptr_t)testarea;
range_struct.len = pagesize;
if (ioctl(ufd, UFFDIO_UNREGISTER, &range_struct)) {
- error_report("%s userfault unregister: %s", __func__, strerror(errno));
+ error_report_errno("%s userfault unregister", __func__);
goto out;
}
@@ -543,7 +543,7 @@ int postcopy_ram_incoming_cleanup(MigrationIncomingState *mis)
if (enable_mlock) {
if (os_mlock() < 0) {
- error_report("mlock: %s", strerror(errno));
+ error_report_errno("mlock");
/*
* It doesn't feel right to fail at this point, we have a valid
* VM state.
@@ -624,7 +624,7 @@ static int ram_block_enable_notify(const char *block_name, void *host_addr,
/* Now tell our userfault_fd that it's responsible for this area */
if (ioctl(mis->userfault_fd, UFFDIO_REGISTER, ®_struct)) {
- error_report("%s userfault register: %s", __func__, strerror(errno));
+ error_report_errno("%s userfault register", __func__);
return -1;
}
if (!(reg_struct.ioctls & ((__u64)1 << _UFFDIO_COPY))) {
@@ -876,7 +876,7 @@ static void *postcopy_ram_fault_thread(void *opaque)
poll_result = poll(pfd, pfd_len, -1 /* Wait forever */);
if (poll_result == -1) {
- error_report("%s: userfault poll: %s", __func__, strerror(errno));
+ error_report_errno("%s: userfault poll", __func__);
break;
}
@@ -1199,7 +1199,7 @@ void *postcopy_get_tmp_page(MigrationIncomingState *mis)
MAP_ANONYMOUS, -1, 0);
if (mis->postcopy_tmp_page == MAP_FAILED) {
mis->postcopy_tmp_page = NULL;
- error_report("%s: %s", __func__, strerror(errno));
+ error_report_errno("%s", __func__);
return NULL;
}
}
diff --git a/net/tap-linux.c b/net/tap-linux.c
index 535b1dd..897e788 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -152,7 +152,7 @@ int tap_probe_vnet_hdr(int fd)
struct ifreq ifr;
if (ioctl(fd, TUNGETIFF, &ifr) != 0) {
- error_report("TUNGETIFF ioctl() failed: %s", strerror(errno));
+ error_report_errno("TUNGETIFF ioctl() failed");
return 0;
}
diff --git a/os-posix.c b/os-posix.c
index 24eb700..e6edb7d 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -125,7 +125,7 @@ void os_set_proc_name(const char *s)
/* Could rewrite argv[0] too, but that's a bit more complicated.
This simple way is enough for `top'. */
if (prctl(PR_SET_NAME, name)) {
- error_report("unable to change process name: %s", strerror(errno));
+ error_report_errno("unable to change process name");
exit(1);
}
#else
@@ -247,7 +247,7 @@ static void change_root(void)
exit(1);
}
if (chdir("/")) {
- error_report("not able to chdir to /: %s", strerror(errno));
+ error_report_errno("not able to chdir to /");
exit(1);
}
}
@@ -309,7 +309,7 @@ void os_setup_post(void)
if (daemonize) {
if (chdir("/")) {
- error_report("not able to chdir to /: %s", strerror(errno));
+ error_report_errno("not able to chdir to /");
exit(1);
}
TFR(fd = qemu_open("/dev/null", O_RDWR));
@@ -383,7 +383,7 @@ int os_mlock(void)
ret = mlockall(MCL_CURRENT | MCL_FUTURE);
if (ret < 0) {
- error_report("mlockall: %s", strerror(errno));
+ error_report_errno("mlockall");
}
return ret;
diff --git a/qemu-nbd.c b/qemu-nbd.c
index 0af0560..47b6957 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -847,7 +847,7 @@ int main(int argc, char **argv)
*/
pid = fork();
if (pid < 0) {
- error_report("Failed to fork: %s", strerror(errno));
+ error_report_errno("Failed to fork");
exit(EXIT_FAILURE);
} else if (pid == 0) {
close(stderr_fd[0]);
@@ -857,7 +857,7 @@ int main(int argc, char **argv)
old_stderr = dup(STDERR_FILENO);
dup2(stderr_fd[1], STDERR_FILENO);
if (ret < 0) {
- error_report("Failed to daemonize: %s", strerror(errno));
+ error_report_errno("Failed to daemonize");
exit(EXIT_FAILURE);
}
diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
index d0f8317..663a8a8 100644
--- a/scsi/qemu-pr-helper.c
+++ b/scsi/qemu-pr-helper.c
@@ -1085,7 +1085,7 @@ int main(int argc, char **argv)
if (daemonize) {
if (daemon(0, 0) < 0) {
- error_report("Failed to daemonize: %s", strerror(errno));
+ error_report_errno("Failed to daemonize");
exit(EXIT_FAILURE);
}
}
@@ -1095,7 +1095,7 @@ int main(int argc, char **argv)
#ifdef CONFIG_LIBCAP
if (drop_privileges() < 0) {
- error_report("Failed to drop privileges: %s", strerror(errno));
+ error_report_errno("Failed to drop privileges");
exit(EXIT_FAILURE);
}
#endif
diff --git a/slirp/misc.c b/slirp/misc.c
index 260187b..11a8bd1 100644
--- a/slirp/misc.c
+++ b/slirp/misc.c
@@ -111,7 +111,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
if ((s = qemu_socket(AF_INET, SOCK_STREAM, 0)) < 0 ||
bind(s, (struct sockaddr *)&addr, addrlen) < 0 ||
listen(s, 1) < 0) {
- error_report("Error: inet socket: %s", strerror(errno));
+ error_report_errno("Error: inet socket");
if (s >= 0) {
closesocket(s);
}
@@ -123,7 +123,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
pid = fork();
switch(pid) {
case -1:
- error_report("Error: fork failed: %s", strerror(errno));
+ error_report_errno("Error: fork failed");
close(s);
return 0;
diff --git a/util/osdep.c b/util/osdep.c
index a73de0e..b78b98b 100644
--- a/util/osdep.c
+++ b/util/osdep.c
@@ -89,7 +89,7 @@ static int qemu_mprotect__osdep(void *addr, size_t size, int prot)
return 0;
#else
if (mprotect(addr, size, prot)) {
- error_report("%s: mprotect failed: %s", __func__, strerror(errno));
+ error_report_errno("%s: mprotect failed", __func__);
return -1;
}
return 0;
diff --git a/vl.c b/vl.c
index d37e857..2f09210 100644
--- a/vl.c
+++ b/vl.c
@@ -1194,7 +1194,7 @@ static int parse_add_fd(void *opaque, QemuOpts *opts, Error **errp)
}
#endif
if (dupfd == -1) {
- error_report("error duplicating fd: %s", strerror(errno));
+ error_report_errno("error duplicating fd");
return -1;
}
@@ -4069,7 +4069,7 @@ int main(int argc, char **argv, char **envp)
}
vmstate_dump_file = fopen(optarg, "w");
if (vmstate_dump_file == NULL) {
- error_report("open %s: %s", optarg, strerror(errno));
+ error_report_errno("open %s", optarg);
exit(1);
}
break;
@@ -4094,7 +4094,7 @@ int main(int argc, char **argv, char **envp)
rcu_disable_atfork();
if (pid_file && qemu_create_pidfile(pid_file) != 0) {
- error_report("could not acquire pid file: %s", strerror(errno));
+ error_report_errno("could not acquire pid file");
exit(1);
}
--
2.1.4
next prev parent reply other threads:[~2018-04-26 16:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-26 16:53 [Qemu-devel] [RFC PATCH 0/7] Introduce error_[v]report_errno[val] Ian Jackson
2018-04-26 16:53 ` [Qemu-devel] [RFC PATCH 1/7] error reporting: Introduce errnoval parameter to vreport Ian Jackson
2018-04-26 17:24 ` Eric Blake
2018-04-26 17:32 ` Ian Jackson
2018-04-26 17:45 ` Eric Blake
2018-04-26 18:23 ` Ian Jackson
2018-04-26 18:12 ` Eric Blake
2018-04-26 16:53 ` [Qemu-devel] [RFC PATCH 2/7] error reporting: Provide error_report_errno (and error_vreport_errno) Ian Jackson
2018-04-26 17:27 ` Eric Blake
2018-04-26 16:53 ` Ian Jackson [this message]
2018-04-26 17:37 ` [Qemu-devel] [RFC PATCH 3/7] error reporting: Use error_report_errno in obvious places Eric Blake
2018-04-26 17:43 ` Ian Jackson
2018-04-26 18:07 ` Eric Blake
2018-04-26 16:53 ` [Qemu-devel] [RFC PATCH 4/7] error reporting: Fix some error messages to use ":" rather than ", " Ian Jackson
2018-04-26 16:53 ` [Qemu-devel] [RFC PATCH 5/7] error reporting: Provide error_report_errnoval (and error_vreport_errnoval) Ian Jackson
2018-04-26 17:31 ` Eric Blake
2018-04-26 17:42 ` Ian Jackson
2018-04-26 16:53 ` [Qemu-devel] [RFC PATCH 6/7] error reporting: Use error_report_errnoval in obvious places Ian Jackson
2018-04-26 16:53 ` [Qemu-devel] [RFC PATCH 7/7] error reporting: HACKING: Say to use error_report_errno Ian Jackson
2018-04-26 17:51 ` Eric Blake
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=1524761612-5307-4-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=alistair.francis@xilinx.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=f4bug@amsat.org \
--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).