[Skiboot] [PATCH 12/17] external/pflash: Move write and read size calculation together

Cyril Bur cyril.bur at au1.ibm.com
Fri Jul 21 16:36:03 AEST 2017


Very simple rework, makes sense to calculate those at the same time.

Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 external/pflash/pflash.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index f280f4c0..2cec6d69 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -882,19 +882,6 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
-	/* If file specified but not size, get size from file
-	 */
-	if (write_file && !write_size) {
-		struct stat stbuf;
-
-		if (stat(write_file, &stbuf)) {
-			perror("Failed to get file size");
-			rc = 1;
-			goto out;
-		}
-		write_size = stbuf.st_size;
-	}
-
 	if (tune && !direct) {
 		fprintf(stderr, "It doesn't make sense to --tune with --direct\n");
 		rc = 1;
@@ -935,6 +922,17 @@ int main(int argc, char *argv[])
 		goto out;
 	}
 
+	/* If file specified but not size, get size from file */
+	if (write_file && !write_size) {
+		struct stat stbuf;
+
+		if (stat(write_file, &stbuf)) {
+			perror("Failed to get file size");
+			rc = 1;
+			goto out;
+		}
+		write_size = stbuf.st_size;
+	}
 
 	/* If read specified and no read_size, use flash size */
 	if (do_read && !read_size && !part_name)
-- 
2.13.3



More information about the Skiboot mailing list