[lkml]   [2004]   [Apr]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Linux 2.4.26-rc2
    Marcelo Tosatti wrote:
    > The void pointer case in here its being done math on without any problem. What is the
    > problem with void pointer math

    There is a problem regarding the C standard. The semantics of 'void *' are well defined
    and only allow for limited use. Basically, you can cast any pointer to and from 'void *',
    but nothing else.

    Pointer math says that 'p+n' means "add to 'p' the value 'n*s' where 's' is the size
    on the element that 'p' points to". A 'void *' does not have a defined element size
    until it is cast. So, ANSI specifically does not allow any arithmetics on 'void *'.

    Some compilers are forgiving and will invent an element size of '1' and allow the
    math. We should not rely on such improper usage.

    >> Maybe a cast is
    >>called for in bh_kmap(), like:
    >> return (char *)kmap(bh->b_page) + bh_offset(bh);
    > Hum, that would fix the warning but I dont see much reasoning behind it.

    It will not simply 'fix' the problem, this is one case where a cast is not
    a bad thing (i.e. a cheat) but the correct thing to do.

    Eyal Lebedinsky ( <>
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 14:02    [W:0.021 / U:19.716 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site