Silent GCC4.0 warning
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
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/ChangeLog renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/ChangeLog +13 -0
@@ -1,5 +1,18 @@ +2005-09-02 Sebastien Couret <[email protected]> + + * 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 <[email protected]> * tests/jffs2_1.c: Include <stdio.h> to stop compiler warning. 2005-07-30 Andrew Lunn <[email protected]>
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/compr_rubin.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/compr_rubin.c +2 -2
@@ -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); }
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/erase.c +2 -2
@@ -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; }
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/flashio.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/flashio.c +2 -2
@@ -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 =
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/gc.c +8 -8
@@ -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 ) {
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodelist.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodelist.c +1 -1
@@ -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);
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodemgmt.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodemgmt.c +2 -2
@@ -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)) {
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/pushpull.h renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/pushpull.h +1 -1
@@ -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; }
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/read.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/read.c +1 -1
@@ -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; }
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/readinode.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/readinode.c +4 -4
@@ -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);
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/write.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/write.c +5 -5
@@ -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);
Quoted 4 lines · Sébastien Couret
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
Signature · 2 lines
Data expands to fill the space available for storage. -- Parkinson's Law
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/compr_rubin.c line 198
Quoted 2 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/compr_rubin.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/compr_rubin.c +1
-1-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.
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c line 336
Quoted 2 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/erase.c +1
-1-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.
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c line 362
Quoted 13 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/erase.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/erase.c +1
-1@@ -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.
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/flashio.c line 104
Quoted 3 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/flashio.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/flashio.c +1
-1jffs2_flash_write (c, to, sizetomalloc, - &thislen, cbuf); + &thislen,(unsigned char *) cbuf);
Correct solution would be void* as parameter type for jffs2_flash_write().
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c line 530
Quoted 2 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/gc.c +1
-1- 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.
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c
Quoted 4 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/gc.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/gc.c +2
-2- 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.
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodemgmt.c line 544
Quoted 2 lines
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/nodemgmt.c renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/nodemgmt.c +1
-1- 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.
Quoted 1 line
static inline void
init_pushpull(struct pushpull *pp, char *buf, unsigned buflen, unsigned ofs, unsigned reserve)
^^^^
Make that "void" instead of below.
Quoted 7 lines
{
cvs-tempo/checkout-ecoscentric-devoted/ecos/packages/fs/jffs2/current/src/pushpull.h renamed from cvs-tempo/checkout-ecoscentric/ecos/packages/fs/jffs2/current/src/pushpull.h +1
-1- pp->buf = buf; + pp->buf = (unsigned char *)buf; pp->buflen = buflen; pp->ofs = ofs; pp->reserve = reserve; }
Quoted 1 line · Jörn Engel
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.
Quoted 3 lines
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.
[...]
Quoted 7 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- 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
Signature · 4 lines
Marius Groeger <[email protected]> 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
Quoted 7 lines · Marius Groeger
Quoted 1 line · Jörn Engel
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.
Quoted 6 lines
Quoted 3 lines
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.
[...]
Quoted 2 lines
Quoted 2 lines
(quoted diff) +1
-1- unsigned long *datum = ebuf + i; + unsigned long *datum = (unsigned long *)((char*)
Quoted 8 lines
Quoted 5 lines
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
Signature · 2 lines
I don't understand it. Nobody does. -- Richard P. Feynman
Quoted 4 lines · Jörn Engel
Quoted 4 lines
Quoted 3 lines
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.
Quoted 8 lines
Quoted 2 lines
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
Signature · 4 lines
Marius Groeger <[email protected]> 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
Quoted 6 lines · Marius Groeger
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
Signature · 4 lines
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
Quoted 2 lines · Jörn Engel
"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
Signature · 4 lines
Marius Groeger <[email protected]> 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
Quoted 11 lines · Marius Groeger
Quoted 2 lines · Jörn Engel
"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
Signature · 2 lines
You can take my soul, but not my lack of enthusiasm. -- Wally