qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel]  [PATCH v4 RFC 0/3] util/uri.c: Coding style format
@ 2018-02-25  4:35 Su Hang
  2018-02-25  4:35 ` [Qemu-devel] [PATCH v4 RFC 1/3] util/uri.c: Coding style check, Only whitespace involved. Using `clang-format -i util/uri.c` first, then change back few code manually, to make sure only whitespace involved Su Hang
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Su Hang @ 2018-02-25  4:35 UTC (permalink / raw)
  To: boxafox; +Cc: qemu-devel

Su Hang (3):
  util/uri.c: Coding style check, Only whitespace involved.
  util/uri.c: remove brackets () that wrap `return` statement's content.
  util/uri.c: wrap single statement blocks with braces {}

 util/uri.c | 1753 ++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 940 insertions(+), 813 deletions(-)

    Using `git diff -w` to make sure that the first patch only contains
    whitespace changes, replace all TAB with whitespace.
    Here is what I actually use:
    '''
    [core]
        whitespace = -trailing-space,-indent-with-non-tab,-tab-in-indent

        git diff -w  --word-diff-regex=[^[:space:]]
    '''

    For second patch, using
    `perl -pi -e "s/return \((.*?)\);/return \1;/g" util/uri.c`
    to remove brackets () that wrap `return` statement's content.
    Changing patterns like this:
    `return (a);` to `return a;`.

    For third patch, using curly braces to wrap `if` `while` `else` statements,
    which only hold single statement. For example:
    '''
    if (cond)
        statement;
    '''
    to
    '''
    if (cond) {
        statement;
    }
    '''

    And using tricks that compare the disassemblies before and after
    code changes, to make sure code logic isn't changed:
    '''
    git checkout master
    make util/uri.o
    strip util/uri.o
    objdump -Drx util/uri.o > /tmp/uri-master.txt
    git checkout cleanupbranch
    make util/uri.o
    strip util/uri.o
    objdump -Drx util/uri.o > /tmp/uri-cleanup.txt
    diff -u /tmp/uri-*.txt
    '''

--
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread
* [Qemu-devel]  [PATCH v4 RFC 0/3] util/uri.c: Coding style format
@ 2018-02-25  4:29 Su Hang
  2018-02-25  4:36 ` no-reply
  0 siblings, 1 reply; 15+ messages in thread
From: Su Hang @ 2018-02-25  4:29 UTC (permalink / raw)
  To: boxafox; +Cc: qemu-devel

*** BLURB HERE ***

Su Hang (3):
  util/uri.c: Coding style check, Only whitespace involved.
  util/uri.c: remove brackets () that wrap `return` statement's content.
  util/uri.c: wrap single statement blocks with braces {}

 util/uri.c | 1753 ++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 940 insertions(+), 813 deletions(-)

    Using `git diff -w` to make sure that the first patch only contains
    whitespace changes, replace all TAB with whitespace.
    Here is what I actually use:
    '''
    [core]
        whitespace = -trailing-space,-indent-with-non-tab,-tab-in-indent

        git diff -w  --word-diff-regex=[^[:space:]]
    '''

    For second patch, using
    `perl -pi -e "s/return \((.*?)\);/return \1;/g" util/uri.c`
    to remove brackets () that wrap `return` statement's content.
    Changing patterns like this:
    `return (a);` to `return a;`.

    For third patch, using curly braces to wrap `if` `while` `else` statements,
    which only hold single statement. For example:
    '''
    if (cond)
        statement;
    '''
    to
    '''
    if (cond) {
        statement;
    }
    '''

    And using tricks that compare the disassemblies before and after
    code changes, to make sure code logic isn't changed:
    '''
    git checkout master
    make util/uri.o
    strip util/uri.o
    objdump -Drx util/uri.o > /tmp/uri-master.txt
    git checkout cleanupbranch
    make util/uri.o
    strip util/uri.o
    objdump -Drx util/uri.o > /tmp/uri-cleanup.txt
    diff -u /tmp/uri-*.txt
    '''

--
2.7.4

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2018-02-27 15:52 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-25  4:35 [Qemu-devel] [PATCH v4 RFC 0/3] util/uri.c: Coding style format Su Hang
2018-02-25  4:35 ` [Qemu-devel] [PATCH v4 RFC 1/3] util/uri.c: Coding style check, Only whitespace involved. Using `clang-format -i util/uri.c` first, then change back few code manually, to make sure only whitespace involved Su Hang
2018-02-26  6:32   ` Thomas Huth
2018-02-25  4:35 ` [Qemu-devel] [PATCH v4 RFC 2/3] util/uri.c: remove brackets that wrap `return` statement's content Su Hang
2018-02-26  6:39   ` Thomas Huth
2018-02-25  4:35 ` [Qemu-devel] [PATCH v4 RFC 3/3] util/uri.c: wrap single statement blocks with braces {} Su Hang
2018-02-26  6:49   ` Thomas Huth
2018-02-26  7:19     ` Su Hang
2018-02-25  4:51 ` [Qemu-devel] [PATCH v4 RFC 0/3] util/uri.c: Coding style format no-reply
2018-02-25  4:57 ` no-reply
2018-02-25 20:56   ` Thomas Huth
2018-02-26  2:09     ` Fam Zheng
2018-02-27 15:52 ` Stefan Hajnoczi
  -- strict thread matches above, loose matches on Subject: below --
2018-02-25  4:29 Su Hang
2018-02-25  4:36 ` no-reply

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).