qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] CODING_STYLE: {} as in linux kernel


From: Gerd Hoffmann
Subject: Re: [Qemu-devel] [PATCH] CODING_STYLE: {} as in linux kernel
Date: Wed, 07 Oct 2009 16:54:24 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-2.7.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4

-    if (a == 5) {
+    if (a == 5)
          printf("a was 5.\n");
-    } else if (a == 6) {
+    else if (a == 6) {
          printf("a was 6.\n");
-    } else {
+        printf("multiply by 7 to get the answer.\n");
+    } else
          printf("a was something else entirely.\n");
-    }

This is the best example of how having braces only sometimes makes
patches unreadable. All of the if/else lines are touched even though the
condition (and thus semantics) remains unchanged.

I somehow dislike the unneeded branches because it looks a bit irritating to my eyes.

They have advantages though. Making patches more readable is one, as kevin and the nice example above clearly points out ;)

Another one is that you don't have to hop around in your editor adding and removing branches when throwing in a temporary debug printf.

So I'd tend to keep them.

cheers,
  Gerd





reply via email to

[Prev in Thread] Current Thread [Next in Thread]