[libvirt] [PATCH] Omitting braces with a single-line body

From: Harry Wei <harryxiyou@gmail.com> After i read libvirt/HACKING file, i find we should Omit braces with a single-line body. So this patch fix this coding style problem for Sheepdog storage backend driver. Signed-off-by: Harry Wei <harryxiyou@gmail.com> --- src/storage/storage_backend_sheepdog.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index 35a3a04..15fa29c 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -97,12 +97,10 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, const char *address = "localhost"; int port = 7000; if (pool->def->source.nhost > 0) { - if (pool->def->source.hosts[0].name != NULL) { + if (pool->def->source.hosts[0].name != NULL) address = pool->def->source.hosts[0].name; - } - if (pool->def->source.hosts[0].port) { + if (pool->def->source.hosts[0].port) port = pool->def->source.hosts[0].port; - } } virCommandAddArg(cmd, "-a"); virCommandAddArgFormat(cmd, "%s", address); @@ -210,11 +208,10 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol, continue; /* skip space */ - if (p + 2 < next) { + if (p + 2 < next) p += 2; - } else { + else return -1; - } /* skip name */ while (*p != '\0' && *p != ' ') { -- 1.7.9.5

On 22/04/13 20:33, harryxiyou@gmail.com wrote:
From: Harry Wei <harryxiyou@gmail.com>
After i read libvirt/HACKING file, i find we should
s/i/I/,
Omit braces with a single-line body. So this patch fix this coding style problem for Sheepdog storage
s/fix this/fixes the/,
backend driver.
The commit log can be more compact: Prefer no braces for single line bodies.
Signed-off-by: Harry Wei <harryxiyou@gmail.com> --- src/storage/storage_backend_sheepdog.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/src/storage/storage_backend_sheepdog.c b/src/storage/storage_backend_sheepdog.c index 35a3a04..15fa29c 100644 --- a/src/storage/storage_backend_sheepdog.c +++ b/src/storage/storage_backend_sheepdog.c @@ -97,12 +97,10 @@ virStorageBackendSheepdogAddHostArg(virCommandPtr cmd, const char *address = "localhost"; int port = 7000; if (pool->def->source.nhost > 0) { - if (pool->def->source.hosts[0].name != NULL) { + if (pool->def->source.hosts[0].name != NULL) address = pool->def->source.hosts[0].name; - } - if (pool->def->source.hosts[0].port) { + if (pool->def->source.hosts[0].port) port = pool->def->source.hosts[0].port; - } } virCommandAddArg(cmd, "-a"); virCommandAddArgFormat(cmd, "%s", address); @@ -210,11 +208,10 @@ virStorageBackendSheepdogParseVdiList(virStorageVolDefPtr vol, continue;
/* skip space */ - if (p + 2 < next) { + if (p + 2 < next) p += 2; - } else { + else return -1; - }
/* skip name */ while (*p != '\0' && *p != ' ') {
ACK

On Mon, Apr 22, 2013 at 9:13 PM, Osier Yang <jyang@redhat.com> wrote:
On 22/04/13 20:33, harryxiyou@gmail.com wrote:
From: Harry Wei <harryxiyou@gmail.com>
After i read libvirt/HACKING file, i find we should
s/i/I/,
Actually, i wonder what 's/i/l/' means?
Omit braces with a single-line body. So this patch fix this coding style problem for Sheepdog storage
s/fix this/fixes the/,
The same problem as above.
backend driver.
The commit log can be more compact:
Prefer no braces for single line bodies.
Yup, i think so ;-)
[...]
ACK
Thanks ;-) -- Thanks Harry Wei

On 04/22/2013 07:40 AM, harryxiyou wrote:
On Mon, Apr 22, 2013 at 9:13 PM, Osier Yang <jyang@redhat.com> wrote:
On 22/04/13 20:33, harryxiyou@gmail.com wrote:
From: Harry Wei <harryxiyou@gmail.com>
After i read libvirt/HACKING file, i find we should
s/i/I/,
Actually, i wonder what 's/i/l/' means?
It's capital 'I', not lower case 'l'. That's shorthand using sed syntax for an in-place replacement you should perform on your text. It means you should have written: After I read libvirt/HACKING file, I find we should for that line, because in English, the pronoun 'I' is always capitalized.
ACK
Thanks ;-)
I'll go ahead and touch up the commit message as suggested, and push. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Mon, Apr 22, 2013 at 10:33 PM, Eric Blake <eblake@redhat.com> wrote: [...]
It's capital 'I', not lower case 'l'. That's shorthand using sed syntax for an in-place replacement you should perform on your text. It means you should have written: After I read libvirt/HACKING file, I find we should for that line, because in English, the pronoun 'I' is always capitalized.
Yeah, it's just a shorthand for my words.
ACK
Thanks ;-)
I'll go ahead and touch up the commit message as suggested, and push.
Ok, thanks. -- Thanks Harry Wei
participants (4)
-
Eric Blake
-
harryxiyou
-
harryxiyou@gmail.com
-
Osier Yang