diff mbox

[1/3] qemu-nbd: Fix coding style

Message ID 1269796032-9166-1-git-send-email-ozaki.ryota@gmail.com
State New
Headers show

Commit Message

Ryota OZAKI March 28, 2010, 5:07 p.m. UTC
Follow "Every indented statement is braced; even if the block
contains just one statement." described in CODING_STYLE.

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
---
 qemu-nbd.c |   60 ++++++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 40 insertions(+), 20 deletions(-)

Comments

Kevin Wolf March 29, 2010, 10:44 a.m. UTC | #1
Am 28.03.2010 19:07, schrieb Ryota Ozaki:
> Follow "Every indented statement is braced; even if the block
> contains just one statement." described in CODING_STYLE.
> 
> Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>

Usually we fix the coding style in places that need to be changed
anyway, but avoid touching things only for style cleanup (it makes git
blame less meaningful, for example).

Kevin
Ryota OZAKI May 2, 2010, 9:50 p.m. UTC | #2
Hi Kevin

On Mon, Mar 29, 2010 at 7:44 PM, Kevin Wolf <kwolf@redhat.com> wrote:
> Am 28.03.2010 19:07, schrieb Ryota Ozaki:
>> Follow "Every indented statement is braced; even if the block
>> contains just one statement." described in CODING_STYLE.
>>
>> Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
>
> Usually we fix the coding style in places that need to be changed
> anyway, but avoid touching things only for style cleanup (it makes git
> blame less meaningful, for example).

Thank you for reviewing and I'm sorry I've stuck for long time...

I follow the policy and will drop the patch.

Thanks,
  ozaki-r


>
> Kevin
>
diff mbox

Patch

diff --git a/qemu-nbd.c b/qemu-nbd.c
index 6d854d3..00b8896 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -113,8 +113,9 @@  static int find_partition(BlockDriverState *bs, int partition,
     int i;
     int ext_partnum = 4;
 
-    if (bdrv_read(bs, 0, data, 1))
+    if (bdrv_read(bs, 0, data, 1)) {
         errx(EXIT_FAILURE, "error while reading");
+    }
 
     if (data[510] != 0x55 || data[511] != 0xaa) {
         errno = -EINVAL;
@@ -124,21 +125,24 @@  static int find_partition(BlockDriverState *bs, int partition,
     for (i = 0; i < 4; i++) {
         read_partition(&data[446 + 16 * i], &mbr[i]);
 
-        if (!mbr[i].nb_sectors_abs)
+        if (!mbr[i].nb_sectors_abs) {
             continue;
+        }
 
         if (mbr[i].system == 0xF || mbr[i].system == 0x5) {
             struct partition_record ext[4];
             uint8_t data1[512];
             int j;
 
-            if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1))
+            if (bdrv_read(bs, mbr[i].start_sector_abs, data1, 1)) {
                 errx(EXIT_FAILURE, "error while reading");
+            }
 
             for (j = 0; j < 4; j++) {
                 read_partition(&data1[446 + 16 * j], &ext[j]);
-                if (!ext[j].nb_sectors_abs)
+                if (!ext[j].nb_sectors_abs) {
                     continue;
+                }
 
                 if ((ext_partnum + j + 1) == partition) {
                     *offset = (uint64_t)ext[j].start_sector_abs << 9;
@@ -169,8 +173,9 @@  static void show_parts(const char *device)
          *     modprobe nbd max_part=63
          */
         nbd = open(device, O_RDWR);
-        if (nbd != -1)
+        if (nbd != -1) {
               close(nbd);
+        }
         exit(0);
     }
 }
@@ -262,15 +267,18 @@  int main(int argc, char **argv)
             break;
         case 'P':
             partition = strtol(optarg, &end, 0);
-            if (*end)
+            if (*end) {
                 errx(EXIT_FAILURE, "Invalid partition `%s'", optarg);
-            if (partition < 1 || partition > 8)
+            }
+            if (partition < 1 || partition > 8) {
                 errx(EXIT_FAILURE, "Invalid partition %d", partition);
+            }
             break;
         case 'k':
             socket = optarg;
-            if (socket[0] != '/')
+            if (socket[0] != '/') {
                 errx(EXIT_FAILURE, "socket path must be absolute\n");
+            }
             break;
         case 'd':
             disconnect = true;
@@ -315,8 +323,9 @@  int main(int argc, char **argv)
 
     if (disconnect) {
         fd = open(argv[optind], O_RDWR);
-        if (fd == -1)
+        if (fd == -1) {
             errx(EXIT_FAILURE, "Cannot open %s", argv[optind]);
+        }
 
         nbd_disconnect(fd);
 
@@ -330,17 +339,20 @@  int main(int argc, char **argv)
     bdrv_init();
 
     bs = bdrv_new("hda");
-    if (bs == NULL)
+    if (bs == NULL) {
         return 1;
+    }
 
-    if (bdrv_open(bs, argv[optind], flags) < 0)
+    if (bdrv_open(bs, argv[optind], flags) < 0) {
         return 1;
+    }
 
     fd_size = bs->total_sectors * 512;
 
     if (partition != -1 &&
-        find_partition(bs, partition, &dev_offset, &fd_size))
+        find_partition(bs, partition, &dev_offset, &fd_size)) {
         errx(EXIT_FAILURE, "Could not find partition %d", partition);
+    }
 
     if (device) {
         pid_t pid;
@@ -360,8 +372,9 @@  int main(int argc, char **argv)
         }
 
         pid = fork();
-        if (pid < 0)
+        if (pid < 0) {
             return 1;
+        }
         if (pid != 0) {
             off_t size;
             size_t blocksize;
@@ -372,8 +385,9 @@  int main(int argc, char **argv)
             do {
                 sock = unix_socket_outgoing(socket);
                 if (sock == -1) {
-                    if (errno != ENOENT && errno != ECONNREFUSED)
+                    if (errno != ENOENT && errno != ECONNREFUSED) {
                         goto out;
+                    }
                     sleep(1);	/* wait children */
                 }
             } while (sock == -1);
@@ -422,14 +436,16 @@  int main(int argc, char **argv)
         sharing_fds[0] = tcp_socket_incoming(bindto, port);
     }
 
-    if (sharing_fds[0] == -1)
+    if (sharing_fds[0] == -1) {
         return 1;
+    }
     max_fd = sharing_fds[0];
     nb_fds++;
 
     data = qemu_memalign(512, NBD_BUFFER_SIZE);
-    if (data == NULL)
+    if (data == NULL) {
         errx(EXIT_FAILURE, "Cannot allocate data buffer");
+    }
 
     do {
 
@@ -438,11 +454,13 @@  int main(int argc, char **argv)
             FD_SET(sharing_fds[i], &fds);
 
         ret = select(max_fd + 1, &fds, NULL, NULL, NULL);
-        if (ret == -1)
+        if (ret == -1) {
             break;
+        }
 
-        if (FD_ISSET(sharing_fds[0], &fds))
+        if (FD_ISSET(sharing_fds[0], &fds)) {
             ret--;
+        }
         for (i = 1; i < nb_fds && ret; i++) {
             if (FD_ISSET(sharing_fds[i], &fds)) {
                 if (nbd_trip(bs, sharing_fds[i], fd_size, dev_offset,
@@ -463,8 +481,9 @@  int main(int argc, char **argv)
                                              &addr_len);
                 if (sharing_fds[nb_fds] != -1 &&
                     nbd_negotiate(sharing_fds[nb_fds], fd_size) != -1) {
-                        if (sharing_fds[nb_fds] > max_fd)
+                        if (sharing_fds[nb_fds] > max_fd) {
                             max_fd = sharing_fds[nb_fds];
+                        }
                         nb_fds++;
                 }
             }
@@ -475,8 +494,9 @@  int main(int argc, char **argv)
     close(sharing_fds[0]);
     bdrv_close(bs);
     qemu_free(sharing_fds);
-    if (socket)
+    if (socket) {
         unlink(socket);
+    }
 
     return 0;
 }