Mir

Code review comment for lp:~alan-griffiths/mir/fix-1717061

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

> +unsigned clamp_dim(unsigned dim)
> +{
> + return std::min<unsigned long>(std::numeric_limits<long>::max(), dim);
> +}
>
> Why max "long" - the signedness of it confuses me. What is this clamping "dim"
> to?
>
> If sizeof(unsigned) < sizeof(long), this always returns "dim", so the only
> interesting case is if sizeof(unsigned) == sizeof(long), where this clamps dim
> in the bottom 1/2 of the unsigned ints. Intended?

That was the intent, yes. To clamp dim to the shared range of long and unsigned int.

« Back to merge proposal