[PATCH] cmd: fix clone coverity scan

John Chau johnchau.2nd at gmail.com
Mon Aug 17 09:53:01 CEST 2020


From: John Chau <john at harmon.hk>

This patch fixes coverity scan MISSING_BREAK issues, and also an error
on block size check.

Signed-off-by: John Chau <john at harmon.hk>
---

 cmd/clone.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/cmd/clone.c b/cmd/clone.c
index 9ece465537..89fa63eb72 100644
--- a/cmd/clone.c
+++ b/cmd/clone.c
@@ -37,7 +37,7 @@ static int do_clone(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	srcbz = srcdesc->blksz;
 	destbz = destdesc->blksz;
 
-	if ((srcbz * (buffersize / srcbz) != buffersize) &&
+	if ((srcbz * (buffersize / srcbz) != buffersize) ||
 	    (destbz * (buffersize / destbz) != buffersize)) {
 		printf("failed: cannot match device block sizes\n");
 		return 1;
@@ -54,10 +54,12 @@ static int do_clone(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 		switch (unit[0]) {
 		case 'g':
 		case 'G':
-			requested *= 1024;
+			requested *= 1024 * 1024 * 1024;
+			break;
 		case 'm':
 		case 'M':
-			requested *= 1024;
+			requested *= 1024 * 1024;
+			break;
 		case 'k':
 		case 'K':
 			requested *= 1024;
-- 
2.25.1



More information about the U-Boot mailing list