qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Su Hang <suhang16@mails.ucas.ac.cn>
Cc: Thomas Huth <thuth@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v2] util/uri.c formating
Date: Tue, 20 Feb 2018 09:14:16 +0000	[thread overview]
Message-ID: <CAFEAcA8GXtEJof8eiakbu3fDh_SafAnS_ywpPi6oXeT3qtQqJg@mail.gmail.com> (raw)
In-Reply-To: <1519113760-4474-1-git-send-email-suhang16@mails.ucas.ac.cn>

On 20 February 2018 at 08:02, Su Hang <suhang16@mails.ucas.ac.cn> wrote:
>  Formating the code with `clang-format -i util/uri.c`.
>  My .clang-format file content is:
>  '''
>  IndentWidth: 4
>  BreakBeforeBraces: Linux
>  '''
>
> Then use `perl -pi -e "s/return \((.*?)\);/return \1;/g" util/uri.c`
> to remove pattern like this: "return (1);"
>
> checkpatch.pl still rise these two kinds of "ERROR", I'm not sure
> whether I should also suppress these, so I left it.
>
> '''
> ERROR: braces {} are necessary even for single statement blocks
> #1803: FILE: uri.c:1803:
> +            while ((bas->path[cur] != 0) && (bas->path[cur] != '/'))
> +                cur++;
>
> ERROR: braces {} are necessary for all arms of this statement
> #1805: FILE: uri.c:1805:
> +            if (bas->path[cur] == 0)
> [...]
> '''

In some places you have put in extra braces, like here:

> -    if (str == NULL)
> -        return(-1);
> +    if (str == NULL) {
> +        return -1;
> +    }

I think if we're going to reformat the file we might as well
get it checkpatch-clean. Alternatively if you don't want to
fix up the brace style then we needn't touch them at all.

One useful split for format-cleanup patches that you might
consider is to have a patch which contains only whitespace
cleanups, so that 'git show --ignore-all-space' shows no changes.
That makes that patch easy to review. Then changes that do
make non-whitespace changes can go in their own patch, which
is generally smaller and so easier to review by eye.

thanks
-- PMM

  parent reply	other threads:[~2018-02-20  9:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-20  8:02 [Qemu-devel] [PATCH v2] util/uri.c formating Su Hang
2018-02-20  8:39 ` Thomas Huth
2018-02-20  9:14 ` Peter Maydell [this message]
2018-02-20  9:28   ` Daniel P. Berrangé

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=CAFEAcA8GXtEJof8eiakbu3fDh_SafAnS_ywpPi6oXeT3qtQqJg@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    --cc=suhang16@mails.ucas.ac.cn \
    --cc=thuth@redhat.com \
    /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).