diff mbox

[6/6] Use &error_fatal when initializing crypto on qemu-{img, io, nbd}

Message ID 1463062204-20330-7-git-send-email-ehabkost@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Eduardo Habkost May 12, 2016, 2:10 p.m. UTC
In addition to making the code simpler, this will replace the
long error messages:
  cannot initialize crypto: Unable to initialize GNUTLS library: [...]
  cannot initialize crypto: Unable to initialize gcrypt
with shorter messages:
  Unable to initialize GNUTLS library: [...]
  Unable to initialize gcrypt

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu-img.c | 6 +-----
 qemu-io.c  | 6 +-----
 qemu-nbd.c | 5 +----
 3 files changed, 3 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/qemu-img.c b/qemu-img.c
index d3cfec3..5e09a6a 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -3450,7 +3450,6 @@  int main(int argc, char **argv)
 {
     const img_cmd_t *cmd;
     const char *cmdname;
-    Error *local_error = NULL;
     int c;
     static const struct option long_options[] = {
         {"help", no_argument, 0, 'h'},
@@ -3467,10 +3466,7 @@  int main(int argc, char **argv)
 
     qemu_init_main_loop(&error_fatal);
 
-    if (qcrypto_init(&local_error) < 0) {
-        error_reportf_err(local_error, "cannot initialize crypto: ");
-        exit(1);
-    }
+    qcrypto_init(&error_fatal);
 
     module_call_init(MODULE_INIT_QOM);
     bdrv_init();
diff --git a/qemu-io.c b/qemu-io.c
index 1507559..1a6478c 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -433,7 +433,6 @@  int main(int argc, char **argv)
     int opt_index = 0;
     int flags = BDRV_O_UNMAP;
     bool writethrough = true;
-    Error *local_error = NULL;
     QDict *opts = NULL;
     const char *format = NULL;
 
@@ -444,10 +443,7 @@  int main(int argc, char **argv)
     progname = basename(argv[0]);
     qemu_init_exec_dir(argv[0]);
 
-    if (qcrypto_init(&local_error) < 0) {
-        error_reportf_err(local_error, "cannot initialize crypto: ");
-        exit(1);
-    }
+    qcrypto_init(&error_fatal);
 
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_object_opts);
diff --git a/qemu-nbd.c b/qemu-nbd.c
index f2685e67..2a30e46 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -521,10 +521,7 @@  int main(int argc, char **argv)
     sa_sigterm.sa_handler = termsig_handler;
     sigaction(SIGTERM, &sa_sigterm, NULL);
 
-    if (qcrypto_init(&local_err) < 0) {
-        error_reportf_err(local_err, "cannot initialize crypto: ");
-        exit(1);
-    }
+    qcrypto_init(&error_fatal);
 
     module_call_init(MODULE_INIT_QOM);
     qemu_add_opts(&qemu_object_opts);