All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 01/23] qemu-nbd: Replace BSDism <err.h> by error_report()
Date: Thu, 17 Dec 2015 10:17:49 -0700	[thread overview]
Message-ID: <5672EE3D.3080901@redhat.com> (raw)
In-Reply-To: <1450371004-26866-2-git-send-email-armbru@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 5669 bytes --]

On 12/17/2015 09:49 AM, Markus Armbruster wrote:
> Coccinelle semantic patch
> 
>     @@
>     expression E;
>     expression list ARGS;
>     @@
>     -       errx(E, ARGS);
>     +       error_report(ARGS);
>     +       exit(E);
>     @@
>     expression E, FMT;
>     expression list ARGS;
>     @@
>     -       err(E, FMT, ARGS);
>     +       error_report(FMT /*": %s"*/, ARGS, strerror(errno));
>     +       exit(E);
> 
> followed by a replace of '"/*": %s"*/' by ' : %s"'.

Interesting approach to working around a coccinelle shortcoming.

Hmm. Should we add error_report_errno(), to parallel error_setg_errno()?
 But that can be a separate patch.

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  qemu-nbd.c | 119 ++++++++++++++++++++++++++++++++++++++-----------------------
>  1 file changed, 75 insertions(+), 44 deletions(-)
> 

> @@ -491,13 +498,14 @@ int main(int argc, char **argv)
>                                  BLOCKDEV_DETECT_ZEROES_OPTIONS_OFF,
>                                  &local_err);
>              if (local_err) {
> -                errx(EXIT_FAILURE, "Failed to parse detect_zeroes mode: %s", 
> -                     error_get_pretty(local_err));
> +                error_report("Failed to parse detect_zeroes mode: %s",
> +                             error_get_pretty(local_err));
> +                exit(EXIT_FAILURE);
>              }
>              if (detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP &&
>                  !(flags & BDRV_O_UNMAP)) {
> -                errx(EXIT_FAILURE, "setting detect-zeroes to unmap is not allowed "
> -                                   "without setting discard operation to unmap"); 
> +                error_report("setting detect-zeroes to unmap is not allowed " "without setting discard operation to unmap");

You'll want to fix the line-wrap on this.

> @@ -509,10 +517,12 @@ int main(int argc, char **argv)
>          case 'o':
>                  dev_offset = strtoll (optarg, &end, 0);
>              if (*end) {
> -                errx(EXIT_FAILURE, "Invalid offset `%s'", optarg);
> +                error_report("Invalid offset `%s'", optarg);

Worth cleaning this up to use '' instead of `' at some point in the
series?  (Not here, though, since this patch is best when it sticks as
close to the coccinelle script as possible).

> +                exit(EXIT_FAILURE);
>              }
>              if (dev_offset < 0) {
> -                errx(EXIT_FAILURE, "Offset must be positive `%s'", optarg);
> +                error_report("Offset must be positive `%s'", optarg);

Obviously, any `' cleanup to '' will have quite a few callers to adjust.


> @@ -534,16 +545,19 @@ int main(int argc, char **argv)
>          case 'P':
>              partition = strtol(optarg, &end, 0);
>              if (*end) {
> -                errx(EXIT_FAILURE, "Invalid partition `%s'", optarg);
> +                error_report("Invalid partition `%s'", optarg);
> +                exit(EXIT_FAILURE);
>              }
>              if (partition < 1 || partition > 8) {
> -                errx(EXIT_FAILURE, "Invalid partition %d", partition);
> +                error_report("Invalid partition %d", partition);
> +                exit(EXIT_FAILURE);
>              }
>              break;
>          case 'k':
>              sockpath = optarg;
>              if (sockpath[0] != '/') {
> -                errx(EXIT_FAILURE, "socket path must be absolute\n");
> +                error_report("socket path must be absolute\n");

I'm guessing later in the series will kill the trailing newline? If so,
then this patch is fine (again, limiting to just coccinelle here).

> +                exit(EXIT_FAILURE);
>              }
>              break;
>          case 'd':
> @@ -555,10 +569,12 @@ int main(int argc, char **argv)
>          case 'e':
>              shared = strtol(optarg, &end, 0);
>              if (*end) {
> -                errx(EXIT_FAILURE, "Invalid shared device number '%s'", optarg);
> +                error_report("Invalid shared device number '%s'", optarg);
> +                exit(EXIT_FAILURE);
>              }
>              if (shared < 1) {
> -                errx(EXIT_FAILURE, "Shared device number must be greater than 0\n");
> +                error_report("Shared device number must be greater than 0\n");
> +                exit(EXIT_FAILURE);

And another one.  Maybe mention in the commit message any future
cleanups planned for style issues that are exposed by this conversion?

>              }
>              break;
>          case 'f':
> @@ -579,21 +595,23 @@ int main(int argc, char **argv)
>              exit(0);
>              break;
>          case '?':
> -            errx(EXIT_FAILURE, "Try `%s --help' for more information.",
> -                 argv[0]);
> +            error_report("Try `%s --help' for more information.", argv[0]);
> +            exit(EXIT_FAILURE);
>          }
>      }
>  
>      if ((argc - optind) != 1) {
> -        errx(EXIT_FAILURE, "Invalid number of argument.\n"
> -             "Try `%s --help' for more information.",
> -             argv[0]);
> +        error_report("Invalid number of argument.\n" "Try `%s --help' for more information.",
> +                     argv[0]);

Long source line worth wrapping?

Line wraps and commit message improvements seem obvious, so I'm okay
with adding:
Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-12-17 17:18 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-17 16:49 [Qemu-devel] [PATCH v2 00/23] Error reporting cleanups and fixes Markus Armbruster
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 01/23] qemu-nbd: Replace BSDism <err.h> by error_report() Markus Armbruster
2015-12-17 17:17   ` Eric Blake [this message]
2015-12-17 18:52     ` Markus Armbruster
2015-12-17 19:56       ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 02/23] error: Use error_report_err() where appropriate (again) Markus Armbruster
2015-12-17 17:33   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 03/23] error: Use error_report_err() instead of monitor_printf() Markus Armbruster
2015-12-17 18:06   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 04/23] error: Use error_report_err() instead of ad hoc prints Markus Armbruster
2015-12-17 20:10   ` Eric Blake
2015-12-18  8:49     ` Markus Armbruster
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 05/23] error: Improve documentation around error_append_hint() Markus Armbruster
2015-12-17 16:59   ` Eric Blake
2015-12-17 18:04     ` Markus Armbruster
2015-12-17 18:16       ` Eric Blake
2015-12-17 19:00         ` Markus Armbruster
2015-12-17 19:53           ` Eric Blake
2015-12-18  9:11             ` Markus Armbruster
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 06/23] block: Clean up "Could not create temporary overlay" error message Markus Armbruster
2015-12-17 20:16   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 07/23] qemu-nbd: Clean up "Failed to load snapshot" " Markus Armbruster
2015-12-17 20:17   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 08/23] test-throttle: Simplify qemu_init_main_loop() error handling Markus Armbruster
2015-12-17 20:19   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 09/23] error: New error_prepend(), error_reportf_err() Markus Armbruster
2015-12-17 20:23   ` Eric Blake
2015-12-18  9:13     ` Markus Armbruster
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 10/23] error: Don't decorate original error message when adding to it Markus Armbruster
2015-12-17 20:32   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 11/23] error: Use error_reportf_err() where it makes obvious sense Markus Armbruster
2015-12-17 20:39   ` Eric Blake
2015-12-18  9:18     ` Markus Armbruster
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 12/23] error: Use error_prepend() " Markus Armbruster
2015-12-17 20:43   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 13/23] spapr: Use error_reportf_err() Markus Armbruster
2015-12-17 20:44   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 14/23] migration: Use error_reportf_err() instead of monitor_printf() Markus Armbruster
2015-12-17 20:46   ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 15/23] qemu-io qemu-nbd: Use error_report() etc. instead of fprintf() Markus Armbruster
2015-12-17 20:51   ` Eric Blake
2015-12-17 20:57     ` Eric Blake
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 16/23] error: Strip trailing '\n' from error string arguments (again) Markus Armbruster
2015-12-17 20:57   ` Eric Blake
2015-12-18  9:47     ` Markus Armbruster
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 17/23] vmdk: Clean up control flow in vmdk_parse_extents() a bit Markus Armbruster
2015-12-17 21:00   ` Eric Blake
2015-12-18  9:54     ` Markus Armbruster
2015-12-18  0:48   ` Fam Zheng
2015-12-17 16:49 ` [Qemu-devel] [PATCH v2 18/23] vmdk: Clean up "Invalid extent lines" error message Markus Armbruster
2015-12-17 21:09   ` Eric Blake
2015-12-18  0:52   ` Fam Zheng
2015-12-18  9:56     ` Markus Armbruster
2015-12-17 16:50 ` [Qemu-devel] [PATCH v2 19/23] pci-assign: Clean up "Failed to assign" error messages Markus Armbruster
2015-12-17 21:45   ` Eric Blake
2015-12-17 16:50 ` [Qemu-devel] [PATCH v2 20/23] vhdx: Fix "log that needs to be replayed" error message Markus Armbruster
2015-12-17 21:52   ` Eric Blake
2015-12-17 16:50 ` [Qemu-devel] [PATCH v2 21/23] error: Clean up errors with embedded newlines (again) Markus Armbruster
2015-12-17 21:53   ` Eric Blake
2015-12-18 10:04     ` Markus Armbruster
2015-12-17 16:50 ` [Qemu-devel] [PATCH v2 22/23] hw/s390x: Rename local variables Error *l_err to just err Markus Armbruster
2015-12-17 21:54   ` Eric Blake
2015-12-17 16:50 ` [Qemu-devel] [PATCH v2 23/23] s390/sclp: Simplify control flow in sclp_realize() Markus Armbruster
2015-12-17 17:25   ` Cornelia Huck
2015-12-17 21:54   ` Eric Blake
2015-12-17 17:26 ` [Qemu-devel] [PATCH v2 00/23] Error reporting cleanups and fixes Cornelia Huck

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=5672EE3D.3080901@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.