[U-Boot-Users] [PATCH] cmd_nand: Fix warning: dereferencing type-punned pointer will break strict-aliasing rules

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Wed Apr 2 13:37:50 CEST 2008


cmd_nand.c:353: warning: dereferencing type-punned pointer will break strict-aliasing rules
cmd_nand.c:356: warning: dereferencing type-punned pointer will break strict-aliasing rules

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>

diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index 7b1f830..2906aed 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -84,7 +84,7 @@ static int nand_dump(nand_info_t *nand, ulong off)
 
 /* ------------------------------------------------------------------------- */
 
-static inline int str2long(char *p, ulong *num)
+static inline int str2long(char *p, loff_t *num)
 {
 	char *endptr;
 
@@ -93,7 +93,7 @@ static inline int str2long(char *p, ulong *num)
 }
 
 static int
-arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size)
+arg_off_size(int argc, char *argv[], nand_info_t *nand, loff_t *off, size_t *size)
 {
 	int idx = nand_curr_device;
 #if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
@@ -136,7 +136,7 @@ arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, ulong *size)
 	}
 
 	if (argc >= 2) {
-		if (!(str2long(argv[1], size))) {
+		if (!(str2long(argv[1], (loff_t*)size))) {
 			printf("'%s' is not a number\n", argv[1]);
 			return -1;
 		}
@@ -158,7 +158,9 @@ out:
 int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 {
 	int i, dev, ret;
-	ulong addr, off, size;
+	ulong addr;
+	loff_t off;
+	size_t size;
 	char *cmd, *s;
 	nand_info_t *nand;
 #ifdef CFG_NAND_QUIET
@@ -477,11 +479,11 @@ U_BOOT_CMD(nand, 5, 1, do_nand,
 	"nand unlock [offset] [size] - unlock section\n");
 
 static int nand_load_image(cmd_tbl_t *cmdtp, nand_info_t *nand,
-			   ulong offset, ulong addr, char *cmd)
+			   loff_t offset, ulong addr, char *cmd)
 {
 	int r;
 	char *ep, *s;
-	ulong cnt;
+	size_t cnt;
 	image_header_t *hdr;
 	int jffs2 = 0;
 #if defined(CONFIG_FIT)
diff --git a/include/nand.h b/include/nand.h
index 3c0752e..b4ee14f 100644
--- a/include/nand.h
+++ b/include/nand.h
@@ -34,22 +34,22 @@ extern int nand_curr_device;
 extern nand_info_t nand_info[];
 extern void nand_init(void);
 
-static inline int nand_read(nand_info_t *info, ulong ofs, ulong *len, u_char *buf)
+static inline int nand_read(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)
 {
-	return info->read(info, ofs, *len, (size_t *)len, buf);
+	return info->read(info, ofs, *len, len, buf);
 }
 
-static inline int nand_write(nand_info_t *info, ulong ofs, ulong *len, u_char *buf)
+static inline int nand_write(nand_info_t *info, loff_t ofs, size_t *len, u_char *buf)
 {
-	return info->write(info, ofs, *len, (size_t *)len, buf);
+	return info->write(info, ofs, *len, len, buf);
 }
 
-static inline int nand_block_isbad(nand_info_t *info, ulong ofs)
+static inline int nand_block_isbad(nand_info_t *info, loff_t ofs)
 {
 	return info->block_isbad(info, ofs);
 }
 
-static inline int nand_erase(nand_info_t *info, ulong off, ulong size)
+static inline int nand_erase(nand_info_t *info, loff_t off, ulong size)
 {
 	struct erase_info instr;
 
@@ -68,8 +68,8 @@ static inline int nand_erase(nand_info_t *info, ulong off, ulong size)
 
 struct nand_write_options {
 	u_char *buffer;		/* memory block containing image to write */
-	ulong length;		/* number of bytes to write */
-	ulong offset;		/* start address in NAND */
+	size_t length;		/* number of bytes to write */
+	loff_t offset;		/* start address in NAND */
 	int quiet;		/* don't display progress messages */
 	int autoplace;		/* if true use auto oob layout */
 	int forcejffs2;		/* force jffs2 oob layout */
@@ -85,8 +85,8 @@ typedef struct nand_write_options nand_write_options_t;
 
 struct nand_read_options {
 	u_char *buffer;		/* memory block in which read image is written*/
-	ulong length;		/* number of bytes to read */
-	ulong offset;		/* start address in NAND */
+	size_t length;		/* number of bytes to read */
+	loff_t offset;		/* start address in NAND */
 	int quiet;		/* don't display progress messages */
 	int readoob;		/* put oob data in image */
 };
@@ -94,8 +94,8 @@ struct nand_read_options {
 typedef struct nand_read_options nand_read_options_t;
 
 struct nand_erase_options {
-	ulong length;		/* number of bytes to erase */
-	ulong offset;		/* first address in NAND to erase */
+	size_t length;		/* number of bytes to erase */
+	loff_t offset;		/* first address in NAND to erase */
 	int quiet;		/* don't display progress messages */
 	int jffs2;		/* if true: format for jffs2 usage
 				 * (write appropriate cleanmarker blocks) */
-- 
1.5.4.5





More information about the U-Boot mailing list