[PATCH 03/13] libfdisk: collapse indentation [oclint]

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

 



Move conditionals to be together to avoid code blocks that are length of
full logical segment.  This allows fewer indentation steps, and improves
general readability.

Signed-off-by: Sami Kerola <kerolasa@xxxxxx>
---
 libfdisk/src/sun.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index 55ec877..902596e 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -399,7 +399,8 @@ static int verify_sun_cmp(int *a, int *b, void *data)
 static int sun_verify_disklabel(struct fdisk_context *cxt)
 {
     uint32_t starts[SUN_MAXPARTITIONS], lens[SUN_MAXPARTITIONS], start, stop;
-    uint32_t i,j,k,starto,endo;
+    uint32_t i, j, k, starto, endo;
+
 #ifdef HAVE_QSORT_R
     int array[SUN_MAXPARTITIONS];
     unsigned int *verify_sun_starts;
@@ -413,30 +414,29 @@ static int sun_verify_disklabel(struct fdisk_context *cxt)
     for (k = 0; k < 7; k++) {
 	for (i = 0; i < SUN_MAXPARTITIONS; i++) {
 	    if (k && (lens[i] % (cxt->geom.heads * cxt->geom.sectors)))
-	        fdisk_warnx(cxt, _("Partition %u doesn't end on cylinder boundary."), i+1);
+		fdisk_warnx(cxt, _("Partition %u doesn't end on cylinder boundary."), i + 1);
 	    if (lens[i]) {
-	        for (j = 0; j < i; j++)
-	            if (lens[j]) {
-	                if (starts[j] == starts[i]+lens[i]) {
-	                    starts[j] = starts[i]; lens[j] += lens[i];
-	                    lens[i] = 0;
-	                } else if (starts[i] == starts[j]+lens[j]){
-	                    lens[j] += lens[i];
-	                    lens[i] = 0;
-	                } else if (!k) {
-	                    if (starts[i] < starts[j]+lens[j] &&
-				starts[j] < starts[i]+lens[i]) {
-	                        starto = starts[i];
-	                        if (starts[j] > starto)
-					starto = starts[j];
-	                        endo = starts[i]+lens[i];
-	                        if (starts[j]+lens[j] < endo)
-					endo = starts[j]+lens[j];
-	                        fdisk_warnx(cxt, _("Partition %u overlaps with others in "
-				       "sectors %u-%u."), i+1, starto, endo);
-	                    }
-	                }
-	            }
+		for (j = 0; j < i && lens[j]; j++)
+		    if (starts[j] == starts[i] + lens[i]) {
+			starts[j] = starts[i];
+			lens[j] += lens[i];
+			lens[i] = 0;
+		    } else if (starts[i] == starts[j] + lens[j]) {
+			lens[j] += lens[i];
+			lens[i] = 0;
+		    } else if (!k &&
+			       starts[i] < starts[j] + lens[j] &&
+			       starts[j] < starts[i] + lens[i]) {
+			starto = starts[i];
+			if (starts[j] > starto)
+			    starto = starts[j];
+			endo = starts[i] + lens[i];
+			if (starts[j] + lens[j] < endo)
+			    endo = starts[j] + lens[j];
+			fdisk_warnx(cxt,
+				    _("Partition %u overlaps with others in "
+				      "sectors %u-%u."), i + 1, starto, endo);
+		    }
 	    }
 	}
     }
-- 
2.9.0

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux