[MPlayer-cvslog] r24194 - trunk/osdep/mmap_anon.c

Reimar D?ffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Aug 25 19:52:39 CEST 2007


Hello,
On Sat, Aug 25, 2007 at 07:40:34PM +0200, Diego Biurrun wrote:
> On Sat, Aug 25, 2007 at 07:25:14PM +0200, Reimar Döffinger wrote:
> > On Sat, Aug 25, 2007 at 07:09:09PM +0200, diego wrote:
> > > 
> > > Log:
> > > warning fix:
> > > mmap_anon.c: In function 'mmap_anon':
> > > mmap_anon.c:37: warning: unused variable 'fd'
> > > 
> > > --- trunk/osdep/mmap_anon.c	(original)
> > > +++ trunk/osdep/mmap_anon.c	Sat Aug 25 19:09:09 2007
> > > @@ -34,7 +34,6 @@
> > >   */
> > >  void *mmap_anon(void *addr, size_t len, int prot, int flags, off_t offset)
> > >  {
> > > -    int fd;
> > >      void *result;
> > >  
> > >       /* From loader/ext.c:
> > > @@ -50,6 +49,7 @@ void *mmap_anon(void *addr, size_t len, 
> > >      result = mmap(addr, len, prot, flags | MAP_ANONYMOUS, -1, offset);
> > >  #else
> > >      /* SysV-style anonymous mapping */
> > > +    int fd;
> > >      fd = open("/dev/zero", O_RDWR);
> > >      if(fd < 0){
> > >          perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
> > 
> > Well, it was there to avoid problems with gcc 2.95.
> > No idea what kind of systems still do not have MAP_ANONYMOUS though.
> 
> I explicitly tested this with gcc 2.95, the preprocessor removes all
> statements before this variable declaration.

The only problematic case is a system with MAP_SHARED, MAP_PRIVATE but
not MAP_ANONYMOUS.
Maybe such a system does not even exist, no idea.
Furthermore, I am not even sure if the "flags = (flags & ~MAP_SHARED) |
MAP_PRIVATE;" make sense outside the MAP_ANONYMOUS.
Just explaining why the variable was where it was.

Greetings,
Reimar Döffinger



More information about the MPlayer-cvslog mailing list