提交 78288671 编写于 作者: M Markus Armbruster

error: Use error_report_err() instead of ad hoc prints

Unlike ad hoc prints, error_report_err() uses the error whole instead
of just its message obtained with error_get_pretty().  This avoids
suppressing its hint (see commit 50b7b000).  Example:

    $ bld/ivshmem-server -l 42@
    Parameter 'shm_size' expects a size
    You may use k, M, G or T suffixes for kilobytes, megabytes, gigabytes and terabytes.

The last line is new with this patch.

While there, drop a "cannot parse shm size: " message prefix; it's
redundant, because the error message proper is always of the form
"Parameter 'shm_size' expects ...".
Signed-off-by: NMarkus Armbruster <armbru@redhat.com>
Reviewed-by: NEric Blake <eblake@redhat.com>
Message-Id: <1450452927-8346-5-git-send-email-armbru@redhat.com>
上级 193227f9
......@@ -106,9 +106,7 @@ ivshmem_server_parse_args(IvshmemServerArgs *args, int argc, char *argv[])
case 'l': /* shm_size */
parse_option_size("shm_size", optarg, &args->shm_size, &errp);
if (errp) {
fprintf(stderr, "cannot parse shm size: %s\n",
error_get_pretty(errp));
error_free(errp);
error_report_err(errp);
ivshmem_server_usage(argv[0], 1);
}
break;
......
......@@ -266,8 +266,7 @@ int qdev_device_help(QemuOpts *opts)
return 1;
error:
error_printf("%s\n", error_get_pretty(local_err));
error_free(local_err);
error_report_err(local_err);
return 1;
}
......
......@@ -251,8 +251,7 @@ static void *nbd_client_thread(void *arg)
&size, &local_error);
if (ret < 0) {
if (local_error) {
fprintf(stderr, "%s\n", error_get_pretty(local_error));
error_free(local_error);
error_report_err(local_error);
}
goto out_socket;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册