This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Avoid bogus pointer->int cast


On Jul 20 02:27, Ralf Corsepius wrote:
> On 07/18/2012 09:54 PM, Eric Blake wrote:
> >On 07/17/2012 05:11 PM, Eric Blake wrote:
> >>On 07/17/2012 04:31 PM, Ralf Corsepius wrote:
> >>>>Rather than "fixing" the bogus pointer check, why not just nuke that
> >>>>code altogether?
> >>>
> >>>My goal was to make the existing code compilable by removing invalid
> >>>code, not rewrite it.
> >>
> >>Ergo, remove ALL of that bogus code, not just the one line bogus cast.
> >
> >More concretely, any objections to this patch instead?
> >
> >2012-07-18  Eric Blake  <eblake@redhat.com>
> >
> >	* libc/posix/readdir.c (readdir): Drop bogus attempt to catch
> >	bogus pointers.
> >
> >diff --git i/newlib/libc/posix/readdir.c w/newlib/libc/posix/readdir.c
> >index da07d5c..d3187e6 100644
> >--- i/newlib/libc/posix/readdir.c
> >+++ w/newlib/libc/posix/readdir.c
> >@@ -75,12 +75,6 @@ _DEFUN(readdir, (dirp),
> >        continue;
> >      }
> >      dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
> >-    if ((int)dp & 03) {	/* bogus pointer check */

...not to mention the fact that casts from pointer to int should have
been eradicated from earth at least 20 years ago.

> >-#ifdef HAVE_DD_LOCK
> >-      __lock_release_recursive(dirp->dd_lock);
> >-#endif
> >-      return NULL;
> >-    }
> >      if (dp->d_reclen <= 0 ||
> >  	dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) {
> >  #ifdef HAVE_DD_LOCK
> >
> 
> OK with me.

Yeah, go ahead, please.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]