public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* Silent GCC4.0 warning
@ 2005-09-13 16:45 Sébastien Couret
  2005-09-13 23:06 ` Jörn Engel
  0 siblings, 1 reply; 8+ messages in thread
From: Sébastien Couret @ 2005-09-13 16:45 UTC (permalink / raw)
  To: linux-mtd

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

Hi All,
I'm not used to post to this mailing list as i use jffs2 with ecos.

Here are JFFS2 patches to silent gcc 4.0 warnings.
Hope this helps

[-- Attachment #2: jffs2.patch --]
[-- Type: application/octet-stream, Size: 18781 bytes --]

diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/ChangeLog /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/ChangeLog
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/ChangeLog	2005-08-03 22:39:51.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/ChangeLog	2005-09-02 11:25:28.000000000 +0200
@@ -1,5 +1,18 @@
+2005-09-02  Sebastien Couret <sebastien.couret@elios-informatique.fr>
+
+	* src/compr_rubin.c: Silent gcc4 signedness warnings 
+	* src/erase.c      : Silent gcc4 warnings 
+	* src/flashio.c    : Silent gcc4 warnings
+	* src/gc.c         : Silent gcc4 signedness warnings
+	* src/nodelist.c   : Silent gcc4 warnings
+	* src/nodemgmt.c   : Silent gcc4 signedness warnings
+	* src/pushpull.h   : Silent gcc4 signedness warnings
+	* src/read.c       : Silent gcc4 signedness warnings
+	* src/readinode.c  : Silent gcc4 warnings
+	* src/write.c      : Silent gcc4 signedness warnings
+	
 2005-08-03  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* tests/jffs2_1.c: Include <stdio.h> to stop compiler warning.
 
 2005-07-30  Andrew Lunn  <andrew.lunn@ascom.ch>
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/compr_rubin.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/compr_rubin.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/compr_rubin.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/compr_rubin.c	2005-09-02 11:16:33.000000000 +0200
@@ -193,11 +193,11 @@
 	{
 	int outpos = 0;
 	int pos=0;
 	struct rubin_state rs;
 
-	init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32);
+	init_pushpull(&rs.pp,(char*) cpage_out, *dstlen * 8, 0, 32);
 
 	init_rubin(&rs, bit_divider, bits);
 	
 	while (pos < (*sourcelen) && !out_byte(&rs, data_in[pos]))
 		pos++;
@@ -297,11 +297,11 @@
 			 unsigned char *page_out, uint32_t srclen, uint32_t destlen)
 {
 	int outpos = 0;
 	struct rubin_state rs;
 	
-	init_pushpull(&rs.pp, cdata_in, srclen, 0, 0);
+	init_pushpull(&rs.pp, (char *)cdata_in, srclen, 0, 0);
 	init_decode(&rs, bit_divider, bits);
 	
 	while (outpos < destlen) {
 		page_out[outpos++] = in_byte(&rs);
 	}
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/erase.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/erase.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c	2005-09-02 11:14:07.000000000 +0200
@@ -331,11 +331,11 @@
 			printk(KERN_WARNING "Short read from newly-erased block at 0x%08x. Wanted %d, got %zd\n", ofs, readlen, retlen);
 			goto fail;
 		}
 		for (i=0; i<readlen; i += sizeof(unsigned long)) {
 			/* It's OK. We know it's properly aligned */
-			unsigned long *datum = ebuf + i;
+			unsigned long *datum = (unsigned long *)((char*) ebuf + i);
 			if (*datum + 1) {
 				*bad_offset += i;
 				printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset);
 				goto fail;
 			}
@@ -352,11 +352,11 @@
 static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
 {
 	struct jffs2_raw_node_ref *marker_ref = NULL;
 	size_t retlen;
 	int ret;
-	uint32_t bad_offset;
+	uint32_t bad_offset=0;
 
 	switch (jffs2_block_check_erase(c, jeb, &bad_offset)) {
 	case -EAGAIN:	goto refile;
 	case -EIO:	goto filebad;
 	}
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/flashio.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/flashio.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/flashio.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/flashio.c	2005-09-02 10:51:29.000000000 +0200
@@ -99,11 +99,11 @@
 					       vecs[j].iov_len);
 					cbufptr += vecs[j].iov_len;
 				}
 				ret =
 				    jffs2_flash_write(c, to, sizetomalloc,
-						      &thislen, cbuf);
+						      &thislen,(unsigned char *) cbuf);
 				if (thislen > totvecsize)	// in case it was aligned up
 					thislen = totvecsize;
 				totlen += thislen;
 				free(cbuf);
 				goto writev_out;
@@ -118,11 +118,11 @@
 				lentowrite &= ~(sizeof (int) - 1);
 				memcpy(buf, vecs[i].iov_base, lentowrite);
 
 				ret =
 				    jffs2_flash_write(c, to, lentowrite,
-						      &thislen, (char *) &buf);
+						      &thislen, (unsigned char *) &buf);
 				if (thislen > vecs[i].iov_len)
 					thislen = vecs[i].iov_len;
 			}	// else
 		} else
 			ret =
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/gc.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/gc.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c	2005-09-02 10:58:41.000000000 +0200
@@ -525,11 +525,11 @@
 
 	node = kmalloc(rawlen, GFP_KERNEL);
 	if (!node)
                return -ENOMEM;
 
-	ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)node);
+	ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (unsigned char *)node);
 	if (!ret && retlen != rawlen)
 		ret = -EIO;
 	if (ret)
 		goto out_node;
 
@@ -592,11 +592,11 @@
  retry:
 	nraw->flash_offset = phys_ofs;
 	nraw->__totlen = rawlen;
 	nraw->next_phys = NULL;
 
-	ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node);
+	ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (unsigned char *)node);
 
 	if (ret || (retlen != rawlen)) {
 		printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
                        rawlen, phys_ofs, ret, retlen);
 		if (retlen) {
@@ -689,11 +689,11 @@
 		mdata = kmalloc(fn->size, GFP_KERNEL);
 		if (!mdata) {
 			printk(KERN_WARNING "kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n");
 			return -ENOMEM;
 		}
-		ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen);
+		ret = jffs2_read_dnode(c, f, fn,(unsigned char *)mdata, 0, mdatalen);
 		if (ret) {
 			printk(KERN_WARNING "read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", ret);
 			kfree(mdata);
 			return ret;
 		}
@@ -736,11 +736,11 @@
 	ri.dsize = cpu_to_je32(mdatalen);
 	ri.compr = JFFS2_COMPR_NONE;
 	ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
 	ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
 
-	new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, ALLOC_GC);
+	new_fn = jffs2_write_dnode(c, f, &ri,( unsigned char *) mdata, mdatalen, phys_ofs, ALLOC_GC);
 
 	if (IS_ERR(new_fn)) {
 		printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));
 		ret = PTR_ERR(new_fn);
 		goto out;
@@ -762,11 +762,11 @@
 	uint32_t alloclen, phys_ofs;
 	int ret;
 
 	rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
 	rd.nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);
-	rd.nsize = strlen(fd->name);
+	rd.nsize = strlen((char*)fd->name);
 	rd.totlen = cpu_to_je32(sizeof(rd) + rd.nsize);
 	rd.hdr_crc = cpu_to_je32(crc32(0, &rd, sizeof(struct jffs2_unknown_node)-4));
 
 	rd.pino = cpu_to_je32(f->inocache->ino);
 	rd.version = cpu_to_je32(++f->highest_version);
@@ -806,11 +806,11 @@
 	if (!jffs2_can_mark_obsolete(c)) {
 		struct jffs2_raw_dirent *rd;
 		struct jffs2_raw_node_ref *raw;
 		int ret;
 		size_t retlen;
-		int name_len = strlen(fd->name);
+		int name_len = strlen((char*)fd->name);
 		uint32_t name_crc = crc32(0, fd->name, name_len);
 		uint32_t rawlen = ref_totlen(c, jeb, fd->raw);
 
 		rd = kmalloc(rawlen, GFP_KERNEL);
 		if (!rd)
@@ -838,11 +838,11 @@
 
 			D1(printk(KERN_DEBUG "Check potential deletion dirent at %08x\n", ref_offset(raw)));
 
 			/* This is an obsolete node belonging to the same directory, and it's of the right
 			   length. We need to take a closer look...*/
-			ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd);
+			ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (unsigned char *)rd);
 			if (ret) {
 				printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Read error (%d) reading obsolete node at %08x\n", ret, ref_offset(raw));
 				/* If we can't read it, we don't need to continue to obsolete it. Continue */
 				continue;
 			}
@@ -918,11 +918,11 @@
 	if(fn->frags > 1) {
 		size_t readlen;
 		uint32_t crc;
 		/* It's partially obsoleted by a later write. So we have to 
 		   write it out again with the _same_ version as before */
-		ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri);
+		ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (unsigned char *)&ri);
 		if (readlen != sizeof(ri) || ret) {
 			printk(KERN_WARNING "Node read failed in jffs2_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", ret, readlen);
 			goto fill;
 		}
 		if (je16_to_cpu(ri.nodetype) != JFFS2_NODETYPE_INODE) {
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodelist.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodelist.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodelist.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodelist.c	2005-09-02 10:41:40.000000000 +0200
@@ -26,11 +26,11 @@
 	struct jffs2_full_dirent **prev = list;
 	
 	JFFS2_DBG_DENTLIST("add dirent \"%s\", ino #%u\n", new->name, new->ino);
 
 	while ((*prev) && (*prev)->nhash <= new->nhash) {
-		if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
+		if ((*prev)->nhash == new->nhash && !strcmp((char*)(*prev)->name,(char*)new->name)) {
 			/* Duplicate. Free one */
 			if (new->version < (*prev)->version) {
 				JFFS2_DBG_DENTLIST("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
 					(*prev)->name, (*prev)->ino);
 				jffs2_mark_node_obsolete(c, new->raw);
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodemgmt.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodemgmt.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodemgmt.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodemgmt.c	2005-09-02 10:44:45.000000000 +0200
@@ -539,11 +539,11 @@
 	   and potentially put its eraseblock onto the erase_pending_list. Thus, we know that
 	   the block hasn't _already_ been erased, and that 'ref' itself hasn't been freed yet
 	   by jffs2_free_all_node_refs() in erase.c. Which is nice. */
 
 	D1(printk(KERN_DEBUG "obliterating obsoleted node at 0x%08x\n", ref_offset(ref)));
-	ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
+	ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (unsigned char *)&n);
 	if (ret) {
 		printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
 		goto out_erase_sem;
 	}
 	if (retlen != sizeof(n)) {
@@ -558,11 +558,11 @@
 		D1(printk(KERN_DEBUG "Node at 0x%08x was already marked obsolete (nodetype 0x%04x)\n", ref_offset(ref), je16_to_cpu(n.nodetype)));
 		goto out_erase_sem;
 	}
 	/* XXX FIXME: This is ugly now */
 	n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS2_NODE_ACCURATE);
-	ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
+	ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (unsigned char *)&n);
 	if (ret) {
 		printk(KERN_WARNING "Write error in obliterating obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
 		goto out_erase_sem;
 	}
 	if (retlen != sizeof(n)) {
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/pushpull.h /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/pushpull.h
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/pushpull.h	2005-01-22 18:14:49.000000000 +0100
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/pushpull.h	2005-09-02 11:15:02.000000000 +0200
@@ -24,11 +24,11 @@
 };
 
 
 static inline void init_pushpull(struct pushpull *pp, char *buf, unsigned buflen, unsigned ofs, unsigned reserve)
 {
-	pp->buf = buf;
+	pp->buf = (unsigned char*)buf;
 	pp->buflen = buflen;
 	pp->ofs = ofs;
 	pp->reserve = reserve;
 }
 
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/read.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/read.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/read.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/read.c	2005-09-02 10:50:04.000000000 +0200
@@ -33,11 +33,11 @@
 
 	ri = jffs2_alloc_raw_inode();
 	if (!ri)
 		return -ENOMEM;
 
-	ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri);
+	ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (unsigned char *)ri);
 	if (ret) {
 		jffs2_free_raw_inode(ri);
 		printk(KERN_WARNING "Error reading node from 0x%08x: %d\n", ref_offset(fd->raw), ret);
 		return ret;
 	}
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/readinode.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/readinode.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/readinode.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/readinode.c	2005-09-02 10:49:24.000000000 +0200
@@ -475,11 +475,11 @@
 				JFFS2_ERROR("short read dirent at %#08x\n", ref_offset(ref));
 				err = -EIO;
 				goto free_out;
 			}
 
-			err = read_direntry(c, ref, &node.d, retlen, &ret_fd, latest_mctime, mctime_ver);
+			err = read_direntry(c, ref, &node.d, retlen, &ret_fd, (int32_t*)latest_mctime, mctime_ver);
 			if (err == 1) {
 				jffs2_mark_node_obsolete(c, ref);
 				break;
 			} else if (unlikely(err))
 				goto free_out;
@@ -496,11 +496,11 @@
 				JFFS2_ERROR("short read dnode at %#08x\n", ref_offset(ref));
 				err = -EIO;
 				goto free_out;
 			}
 
-			err = read_dnode(c, ref, &node.i, retlen, &ret_tn, latest_mctime, mctime_ver);
+			err = read_dnode(c, ref, &node.i, retlen, &ret_tn,(int32_t*)latest_mctime, mctime_ver);
 			if (err == 1) {
 				jffs2_mark_node_obsolete(c, ref);
 				break;
 			} else if (unlikely(err))
 				goto free_out;
@@ -548,11 +548,11 @@
 					struct jffs2_raw_inode *latest_node)
 {
 	struct jffs2_tmp_dnode_info *tn = NULL;
 	struct rb_root tn_list;
 	struct rb_node *rb, *repl_rb;
-	struct jffs2_full_dirent *fd_list;
+	struct jffs2_full_dirent *fd_list=NULL;
 	struct jffs2_full_dnode *fn = NULL;
 	uint32_t crc;
 	uint32_t latest_mctime, mctime_ver;
 	uint32_t mdata_ver = 0;
 	size_t retlen;
@@ -708,11 +708,11 @@
 				jffs2_do_clear_inode(c, f);
 				return -ENOMEM;
 			}
 			
 			ret = jffs2_flash_read(c, ref_offset(fn->raw) + sizeof(*latest_node),
-						je32_to_cpu(latest_node->csize), &retlen, (char *)f->target);
+						je32_to_cpu(latest_node->csize), &retlen, (unsigned char *)f->target);
 			
 			if (ret  || retlen != je32_to_cpu(latest_node->csize)) {
 				if (retlen != je32_to_cpu(latest_node->csize))
 					ret = -EIO;
 				kfree(f->target);
diff -r -u5 -N -x CVS -x '*~' -x '.#*' /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/write.c /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/write.c
--- /cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/write.c	2005-07-30 17:30:42.000000000 +0200
+++ /cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/write.c	2005-09-02 11:05:43.000000000 +0200
@@ -247,11 +247,11 @@
 		return ERR_PTR(-ENOMEM);
 	}
 
 	fd->version = je32_to_cpu(rd->version);
 	fd->ino = je32_to_cpu(rd->ino);
-	fd->nhash = full_name_hash(name, strlen(name));
+	fd->nhash = full_name_hash(name, strlen((char*)name));
 	fd->type = rd->type;
 	memcpy(fd->name, name, namelen);
 	fd->name[namelen]=0;
 
  retry:
@@ -507,11 +507,11 @@
 	rd->nsize = namelen;
 	rd->type = DT_REG;
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL);
+	fd = jffs2_write_dirent(c, dir_f, rd,(unsigned char*) name, namelen, phys_ofs, ALLOC_NORMAL);
 
 	jffs2_free_raw_dirent(rd);
 	
 	if (IS_ERR(fd)) {
 		/* dirent failed to write. Delete the inode normally 
@@ -569,11 +569,11 @@
 		rd->nsize = namelen;
 		rd->type = DT_UNKNOWN;
 		rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 		rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
 
-		fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION);
+		fd = jffs2_write_dirent(c, dir_f, rd, (unsigned char*)name, namelen, phys_ofs, ALLOC_DELETION);
 		
 		jffs2_free_raw_dirent(rd);
 
 		if (IS_ERR(fd)) {
 			jffs2_complete_reservation(c);
@@ -584,11 +584,11 @@
 		/* File it. This will mark the old one obsolete. */
 		jffs2_add_fd_to_list(c, fd, &dir_f->dents);
 		up(&dir_f->sem);
 	} else {
 		struct jffs2_full_dirent **prev = &dir_f->dents;
-		uint32_t nhash = full_name_hash(name, namelen);
+		uint32_t nhash = full_name_hash((unsigned char *)name, namelen);
 
 		down(&dir_f->sem);
 
 		while ((*prev) && (*prev)->nhash <= nhash) {
 			if ((*prev)->nhash == nhash && 
@@ -680,11 +680,11 @@
 	rd->type = type;
 
 	rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
 	rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
 
-	fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL);
+	fd = jffs2_write_dirent(c, dir_f, rd,(unsigned char*) name, namelen, phys_ofs, ALLOC_NORMAL);
 	
 	jffs2_free_raw_dirent(rd);
 
 	if (IS_ERR(fd)) {
 		jffs2_complete_reservation(c);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-13 16:45 Silent GCC4.0 warning Sébastien Couret
@ 2005-09-13 23:06 ` Jörn Engel
  2005-09-14  7:05   ` Marius Groeger
  0 siblings, 1 reply; 8+ messages in thread
From: Jörn Engel @ 2005-09-13 23:06 UTC (permalink / raw)
  To: Sébastien Couret; +Cc: linux-mtd

On Tue, 13 September 2005 18:45:41 +0200, Sébastien Couret wrote:
> 
> I'm not used to post to this mailing list as i use jffs2 with ecos.
> 
> Here are JFFS2 patches to silent gcc 4.0 warnings.

Rejected.  Examplary reasons below...

In principle, I'd like a patch to silence gcc warnings.  But only when
the patch actually improves code quality.  If I get to choose between
bad code and compiler warnings, I'll pick the warning.

Jörn

-- 
Data expands to fill the space available for storage.
-- Parkinson's Law

> -	init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32);
> +	init_pushpull(&rs.pp,(char*) cpage_out, *dstlen * 8, 0, 32);

If it was a bug before, it will still be a bug.  Either way, new code
would be uglier than old.

Simply adding an explicit cast is *not* a solution.

Solution would be to use void* as parameter type for init_pushpull().
The meaning of the parameter is a chunk of memory, not an array of
signed or unsigned chars, shorts, ints longs or whatnot.

> -			unsigned long *datum = ebuf + i;
> +			unsigned long *datum = (unsigned long *)((char*) ebuf + i);

Arithmetic with void* pointers is one of the best gcc extensions.  Use
it!  The above is obviously correct, while below makes my brain rotate
around itself at dangerous speed.

> @@ -352,11 +352,11 @@
>  static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseblock *jeb)
>  {
>  	struct jffs2_raw_node_ref *marker_ref = NULL;
>  	size_t retlen;
>  	int ret;
> -	uint32_t bad_offset;
> +	uint32_t bad_offset=0;
>  
>  	switch (jffs2_block_check_erase(c, jeb, &bad_offset)) {
>  	case -EAGAIN:	goto refile;
>  	case -EIO:	goto filebad;
>  	}

Obviously a false positive.  Gcc should be smart enough to notice that
jffs2_block_check_erase() - a static function - never reads bad_offset
before writing to it.

>  				    jffs2_flash_write(c, to, sizetomalloc,
> -						      &thislen, cbuf);
> +						      &thislen,(unsigned char *) cbuf);

Correct solution would be void* as parameter type for
jffs2_flash_write().

> -	ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)node);
> +	ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (unsigned char *)node);

Dito here.

> -	rd.nsize = strlen(fd->name);
> +	rd.nsize = strlen((char*)fd->name);
> -		int name_len = strlen(fd->name);
> +		int name_len = strlen((char*)fd->name);

We might use char* for fd->name.  Cast is no solution.

> -	ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
> +	ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (unsigned char *)&n);

void* for jffs2_flash_read() and remove cast from original code.

>  static inline void init_pushpull(struct pushpull *pp, char *buf, unsigned buflen, unsigned ofs, unsigned reserve)
                                                         ^^^^
Make that "void" instead of below.
>  {
> -	pp->buf = buf;
> +	pp->buf = (unsigned char*)buf;
>  	pp->buflen = buflen;
>  	pp->ofs = ofs;
>  	pp->reserve = reserve;
>  }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-13 23:06 ` Jörn Engel
@ 2005-09-14  7:05   ` Marius Groeger
  2005-09-14  9:26     ` Jörn Engel
  0 siblings, 1 reply; 8+ messages in thread
From: Marius Groeger @ 2005-09-14  7:05 UTC (permalink / raw)
  To: Jörn Engel; +Cc: Sébastien Couret, linux-mtd

On Wed, 14 Sep 2005, Jörn Engel wrote:

> Rejected.  Examplary reasons below...

Unless you feel your comments are insignificant, please don't put them 
below the sigdashes "-- <NL>". Otherwise good Mailers will strip them 
in the reply.

> In principle, I'd like a patch to silence gcc warnings.  But only when
> the patch actually improves code quality.  If I get to choose between
> bad code and compiler warnings, I'll pick the warning.
[...]
> > -                     unsigned long *datum = ebuf + i;
> > +                     unsigned long *datum = (unsigned long *)((char*)
> ebuf + i);
> 
> Arithmetic with void* pointers is one of the best gcc extensions.  Use
> it!  The above is obviously correct, while below makes my brain rotate
> around itself at dangerous speed.

If I get to choose between portable code and some remote developers 
brain rotation, I'll pick the portable code. :-)

Regards,
Marius

-- 
Marius Groeger <mgroeger@sysgo.com>
SYSGO AG                      Embedded and Real-Time Software
Voice: +49 6136 9948 0                  FAX: +49 6136 9948 10
www.sysgo.com | www.elinos.com | www.osek.de | www.pikeos.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-14  7:05   ` Marius Groeger
@ 2005-09-14  9:26     ` Jörn Engel
  2005-09-14 10:04       ` Marius Groeger
  0 siblings, 1 reply; 8+ messages in thread
From: Jörn Engel @ 2005-09-14  9:26 UTC (permalink / raw)
  To: Marius Groeger; +Cc: Sébastien Couret, linux-mtd

On Wed, 14 September 2005 09:05:31 +0200, Marius Groeger wrote:
> On Wed, 14 Sep 2005, Jörn Engel wrote:
> 
> >Rejected.  Examplary reasons below...
> 
> Unless you feel your comments are insignificant, please don't put them 
> below the sigdashes "-- <NL>". Otherwise good Mailers will strip them 
> in the reply.

Good point.  Sorry about that.

> >In principle, I'd like a patch to silence gcc warnings.  But only when
> >the patch actually improves code quality.  If I get to choose between
> >bad code and compiler warnings, I'll pick the warning.
> [...]
> >> -                     unsigned long *datum = ebuf + i;
> >> +                     unsigned long *datum = (unsigned long *)((char*)
> >ebuf + i);
> >
> >Arithmetic with void* pointers is one of the best gcc extensions.  Use
> >it!  The above is obviously correct, while below makes my brain rotate
> >around itself at dangerous speed.
> 
> If I get to choose between portable code and some remote developers 
> brain rotation, I'll pick the portable code. :-)

It's a good thing that we both agree on this.  :)

Is anyone actually using JFFS2 with a non-gcc compiler?  Intel's
compiler counts as gcc-compatible here, they included all gcc
extensions used in the kernel, for obvious reasons.

Jörn

-- 
I don't understand it. Nobody does.
-- Richard P. Feynman

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-14  9:26     ` Jörn Engel
@ 2005-09-14 10:04       ` Marius Groeger
  2005-09-14 12:03         ` Jörn Engel
  0 siblings, 1 reply; 8+ messages in thread
From: Marius Groeger @ 2005-09-14 10:04 UTC (permalink / raw)
  To: Jörn Engel; +Cc: Sébastien Couret, linux-mtd

On Wed, 14 Sep 2005, Jörn Engel wrote:

>>> Arithmetic with void* pointers is one of the best gcc extensions.  Use
>>> it!  The above is obviously correct, while below makes my brain rotate
>>> around itself at dangerous speed.
>>
>> If I get to choose between portable code and some remote developers
>> brain rotation, I'll pick the portable code. :-)
>
> It's a good thing that we both agree on this.  :)
>
> Is anyone actually using JFFS2 with a non-gcc compiler?  Intel's
> compiler counts as gcc-compatible here, they included all gcc
> extensions used in the kernel, for obvious reasons.

I know I'm quite religous here, and my point isn't really who's using
something else than GCC today -- I grant you that this is quite unlikely.
Experience shows however that you never know in what context you will have
to reuse a specific piece of software, so if your write it portable in the
first place, you're always safe.

Regards,
Marius

-- 
Marius Groeger <mgroeger@sysgo.com>
SYSGO AG                      Embedded and Real-Time Software
Voice: +49 6136 9948 0                  FAX: +49 6136 9948 10
www.sysgo.com | www.elinos.com | www.osek.de | www.pikeos.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-14 10:04       ` Marius Groeger
@ 2005-09-14 12:03         ` Jörn Engel
  2005-09-14 12:34           ` Marius Groeger
  0 siblings, 1 reply; 8+ messages in thread
From: Jörn Engel @ 2005-09-14 12:03 UTC (permalink / raw)
  To: Marius Groeger; +Cc: Sébastien Couret, linux-mtd

On Wed, 14 September 2005 12:04:48 +0200, Marius Groeger wrote:
> 
> I know I'm quite religous here, and my point isn't really who's using
> something else than GCC today -- I grant you that this is quite unlikely.
> Experience shows however that you never know in what context you will have
> to reuse a specific piece of software, so if your write it portable in the
> first place, you're always safe.

My experience is that you cannot anticipate the problem coming up in
the future.  Next hardware revision will have unbelievable bugs, next
OS/compiler/etc. you port to just the same.

"if your write it portable in the first place" sounds nice, but noone
really knows what that means, before the acid test happens.


Back to the original topic, we really need to do something about the
warnings.  Most of them can be solved by using void* for the "just a
hunk of memory" type fields.

Jörn

-- 
To announce that there must be no criticism of the President, or that we
are to stand by the President, right or wrong, is not only unpatriotic
and servile, but is morally treasonable to the American public.
-- Theodore Roosevelt, Kansas City Star, 1918

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-14 12:03         ` Jörn Engel
@ 2005-09-14 12:34           ` Marius Groeger
  2005-09-14 13:06             ` Jörn Engel
  0 siblings, 1 reply; 8+ messages in thread
From: Marius Groeger @ 2005-09-14 12:34 UTC (permalink / raw)
  To: Jörn Engel; +Cc: Sébastien Couret, linux-mtd

On Wed, 14 Sep 2005, Jörn Engel wrote:

> "if your write it portable in the first place" sounds nice, but noone
> really knows what that means, before the acid test happens.

I think this is a weak argument in this context. Sticking to the 
standards should always be a prime directive for any programmer. 
Moreover, /if/ I follow your argument: it's very unlikely something 
happens to the semantics of (char*)buf + i, compared to the likelihood 
of a future GCC discovering honour and making the extensions harder to 
access.

Regards,
Marius

-- 
Marius Groeger <mgroeger@sysgo.com>
SYSGO AG                      Embedded and Real-Time Software
Voice: +49 6136 9948 0                  FAX: +49 6136 9948 10
www.sysgo.com | www.elinos.com | www.osek.de | www.pikeos.com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Silent GCC4.0 warning
  2005-09-14 12:34           ` Marius Groeger
@ 2005-09-14 13:06             ` Jörn Engel
  0 siblings, 0 replies; 8+ messages in thread
From: Jörn Engel @ 2005-09-14 13:06 UTC (permalink / raw)
  To: Marius Groeger; +Cc: Sébastien Couret, linux-mtd

On Wed, 14 September 2005 14:34:47 +0200, Marius Groeger wrote:
> On Wed, 14 Sep 2005, Jörn Engel wrote:
> 
> >"if your write it portable in the first place" sounds nice, but noone
> >really knows what that means, before the acid test happens.
> 
> I think this is a weak argument in this context. Sticking to the 
> standards should always be a prime directive for any programmer. 
> Moreover, /if/ I follow your argument: it's very unlikely something 
> happens to the semantics of (char*)buf + i, compared to the likelihood 
> of a future GCC discovering honour and making the extensions harder to 
> access.

Yeah, ok.  But then again, void* arithmetic is likely the single best
gcc extension.  We should spread this feature into more compilers and
into the next C standard instead of crippling ourselves.

Commercial companies with paying customers may have a different view
on this subject.  But since I don't receive a monthly cheque to worry
about such problems, please understand my ignorance. ;)

Jörn

-- 
You can take my soul, but not my lack of enthusiasm.
-- Wally

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-09-14 13:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-09-13 16:45 Silent GCC4.0 warning Sébastien Couret
2005-09-13 23:06 ` Jörn Engel
2005-09-14  7:05   ` Marius Groeger
2005-09-14  9:26     ` Jörn Engel
2005-09-14 10:04       ` Marius Groeger
2005-09-14 12:03         ` Jörn Engel
2005-09-14 12:34           ` Marius Groeger
2005-09-14 13:06             ` Jörn Engel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox