Alexandre Julliard : ntdll: Fixed a compiler warning for size_t/ unsigned int mismatch.

Francois Gouget fgouget at free.fr
Sat Mar 10 14:42:19 CST 2007


On Sat, 10 Mar 2007, Alexandre Julliard wrote:

> Francois Gouget <fgouget at free.fr> writes:
> 
> > On Fri, 9 Mar 2007, Alexandre Julliard wrote:
> > [...]
> >>  void * __cdecl _lfind( const void *key, const void *base, unsigned int *nmemb,
> >> -                       unsigned int size, int(*compar)(const void *, const void *) )
> >> +                       size_t size, int(*compar)(const void *, const void *) )
> >>  {
> >> -    return lfind( key, base, nmemb, size, compar );
> >> +    size_t n = *nmemb;
> >> +    return lfind( key, base, &n, size, compar );
> >>  }
> >
> > The problem is that Microsoft's _lfind() takes an 'unsigned int' and not 
> > a size_t. Or, more precisely, the msvcrt one declared in search.h does. 
> > There's no official prototype for the ntdll implementation that I 
> > know of, but I'd expect it to have the same prototype.
> >
> > So my understanding is that replacing this parameter type with a size_t 
> > could be a problem on 64bit systems.
> 
> Yes, that's why I left *nmemb as an unsigned int. For parameters
> passed by value it doesn't matter, the compiler will expand things as
> needed.

Even so I think we can get a problem for the Win64 case: on Windows the 
size parameter will still be 32bits since it's an 'unsigned int'. So 
64bit Windows applications will generate code that passes a 32bit size 
to _lfind(). But Wine's implementation will expect the size parameter to 
be 64bit since it's a size_t (which is 64bits in both Windows and 
Unix) and thus it will try to pop too much stuff off the stack.


-- 
Francois Gouget <fgouget at free.fr>              http://fgouget.free.fr/
        It really galls me that most of the computer power in the world
                          is wasted on screen savers.
                     Chris Caldwell from the GIMPS project
                       http://www.mersenne.org/prime.htm



More information about the wine-devel mailing list