[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Compilation warnings
- From: Mike Pall <mikelu-0710@...>
- Date: Tue, 23 Oct 2007 00:51:51 +0200
Hi,
Enrico Colombini wrote:
> I may be a bit nitpicking, but I like to see no warnings at all in my
> programs :-)
Well, it's still a good idea to check all of them. IMHO most are
uncritical and can be silenced with casts or consistent
definitions (e.g. fb2int/int2fb is a misnomer as it only ever
deals with unsigned ints).
However ...
> Warning : implicit arithmetic conversion from 'int' to 'unsigned int'
> lstring.c line 65 h = lmod(h, tb->size);
Here, 'h' really shouldn't be reused. Indexing with ints vs.
unsigned ints makes a difference on some platforms.
> Warning : implicit arithmetic conversion from 'unsigned long' to 'long'
> lstrlib.c line 31 lua_pushinteger(L, l);
>
> Warning : implicit arithmetic conversion from 'long' to 'unsigned long'
> lstrlib.c line 50 lua_pushlstring(L, s+start-1, end-start+1);
>
> Warning : implicit arithmetic conversion from 'unsigned long' to 'long'
> lstrlib.c line 112 if ((size_t)pose > l) pose = l;
These look like potential security holes on first inspection. But
I don't think it's possible to create a string bigger than half
the virtual address space (e.g. >2GB on a 32 bit OS) in the first
place. So a few casts should silence them.
> Warning : implicit arithmetic conversion from 'unsigned long' to 'long'
> lstrlib.c line 651 int max_s = aL_optinteger(L, ( 4), ( srcl+1)));
This is a real bug, because sizeof(size_t) may be larger than
sizeof(int), e.g. on a 64 bit OS.
Bye,
Mike