Followup fixes on the mtdparts spread patchset

Consolidate some code in mtd_get_len_incl_bad(), and fix a condition
where a valid partition could be reported as truncated if it has a
good block at the end of the device (unlikely, since the BBT is usually
there).

Fix mid-block declarations in net_part_size().

Signed-off-by: Scott Wood <scottwood@freescale.com>
Reviewed-by: Ben Gardiner <bengardiner@nanometrics.ca>
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
index 17865b7..5481c88 100644
--- a/common/cmd_mtdparts.c
+++ b/common/cmd_mtdparts.c
@@ -1228,15 +1228,16 @@
  */
 static uint64_t net_part_size(struct mtd_info *mtd, struct part_info *part)
 {
+	uint64_t i, net_size = 0;
+
 	if (!mtd->block_isbad)
 		return part->size;
 
-	uint64_t i, net_size = 0;
-
 	for (i = 0; i < part->size; i += mtd->erasesize) {
 		if (!mtd->block_isbad(mtd, part->offset + i))
 			net_size += mtd->erasesize;
 	}
+
 	return net_size;
 }
 #endif