[PATCH 09/17] cmdlinepart: make argument types safer

Sascha Hauer s.hauer at pengutronix.de
Thu Feb 12 00:54:26 PST 2015


The return size should be loff_t to support partitions bigger
than 4G. Also use const for the devname and endp.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/partition.c  | 4 ++--
 include/cmdlinepart.h | 6 +++---
 lib/cmdlinepart.c     | 6 +++---
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/commands/partition.c b/commands/partition.c
index c95433f..17ca136 100644
--- a/commands/partition.c
+++ b/commands/partition.c
@@ -41,7 +41,7 @@
 static int do_addpart(int argc, char *argv[])
 {
 	char *devname;
-	char *endp;
+	const char *endp;
 	loff_t offset = 0;
 	loff_t devsize;
 	struct stat s;
@@ -70,7 +70,7 @@ static int do_addpart(int argc, char *argv[])
 	endp = argv[optind + 1];
 
 	while (1) {
-		size_t size = 0;
+		loff_t size = 0;
 
 		if (cmdlinepart_do_parse_one(devname, endp, &endp, &offset,
 					devsize, &size, flags))
diff --git a/include/cmdlinepart.h b/include/cmdlinepart.h
index 5ffa3c4..3f8e136 100644
--- a/include/cmdlinepart.h
+++ b/include/cmdlinepart.h
@@ -3,9 +3,9 @@
 
 #define CMDLINEPART_ADD_DEVNAME (1 << 0)
 
-int cmdlinepart_do_parse_one(char *devname, const char *partstr,
-				 char **endp, loff_t *offset,
-				 loff_t devsize, size_t *retsize,
+int cmdlinepart_do_parse_one(const char *devname, const char *partstr,
+				 const char **endp, loff_t *offset,
+				 loff_t devsize, loff_t *retsize,
 				 unsigned int partition_flags);
 
 #endif /* __CMD_LINE_PART_H */
diff --git a/lib/cmdlinepart.c b/lib/cmdlinepart.c
index 4781d82..9351587 100644
--- a/lib/cmdlinepart.c
+++ b/lib/cmdlinepart.c
@@ -24,9 +24,9 @@
 
 #define SIZE_REMAINING ((loff_t)-1)
 
-int cmdlinepart_do_parse_one(char *devname, const char *partstr,
-				 char **endp, loff_t *offset,
-				 loff_t devsize, size_t *retsize,
+int cmdlinepart_do_parse_one(const char *devname, const char *partstr,
+				 const char **endp, loff_t *offset,
+				 loff_t devsize, loff_t *retsize,
 				 unsigned int partition_flags)
 {
 	loff_t size;
-- 
2.1.4




More information about the barebox mailing list