lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


    Thank you once again, Mike. Another very helpful response from
you. I'm starting to get used to it :)
    All the best,

    Bogdan M.

On Mon, 14 Mar 2005 18:03:49 +0100, Mike Pall <mikelu-0503@mike.de> wrote:
> Hi,
> 
> Bogdan Marinescu wrote:
> >     While trying to port lua to an embedded 16-bit platform, the
> > compiler warns me that the comparison in luaM_reallocv is always true:
> 
> The same occurs on 64 bit platforms. I've already reported this to
> Roberto for Lua 5.1-work4.
> 
> Below is a patch to silence the compiler (and to optimize the conditional
> away when it's not needed).
> 
> Bye,
>      Mike
> 
> --- lua-5.1-work5/src/lmem.h    2004-12-01 16:46:18.000000000 +0100
> +++ lua-5.1-work5-lmemfix/src/lmem.h    2005-03-06 22:57:13.019119208 +0100
> @@ -21,7 +21,8 @@
>  void *luaM_toobig (lua_State *L);
> 
>  #define luaM_reallocv(L,b,on,n,e) \
> -  ((cast(unsigned int, (n)+1) <= MAX_SIZET/(e)) ?  /* +1 to avoid warnings */ \
> +  (((sizeof(unsigned int) < sizeof(size_t) ? 0 : cast(unsigned int, (n)+1)) \
> +    <= MAX_SIZET/(e)) ?  /* to avoid warnings */ \
>      luaM_realloc_(L, (b), (on)*(e), (n)*(e)) : \
>      luaM_toobig(L))
> 
> 


-- 
Bogdan