Source-Changes archive

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

Re: CVS commit: src/usr.sbin/videomode



> On Thu, Jan 15, 2009 at 07:31:54PM +0200, Alan Barrett wrote:
>  > > Add a cast to make this build again (no sense in doing PRIu64 when we
>  > > & with 7 right after).
>  >
>  > I think that you are invoking undefined behaviour, casting a value to
>  > (int) when the value might conceivably be larger than INT_MAX.  If you
>  > cast to (unsigned int) instead, then all should be well.
>
> It's missing parens; it should be (int)(minor(stb.st_rdev) & 0x7)
> instead of (int)minor(stb.st_rdev) & 0x7.

Alan privately suggested instead:

        (unsigned int)minor(stb.st_rdev) & 0x7;

and printing with %u, in order to avoid invoking formally
undefined behaviour (unsigned -> int cast and bitwise ops on
signed values).

I've just not gotten around to committing it yet (I think I'll be
using u_int instead).

Regards,

- Håvard


Home | Main Index | Thread Index | Old Index