svn commit: r226359 - head/usr.bin/look

Colin Percival cperciva at freebsd.org
Sun Oct 16 18:39:12 UTC 2011


On 10/16/11 11:20, Ed Schouten wrote:
> Hmmm... Casting to size_t is not the way to go, but off_t also should be
> avoided. We can assume st_size is non-negative, so we should do
> something like this, right?
> 
> -		if (sb.st_size > (off_t)SIZE_T_MAX)
> +		if ((uintmax_t)sb.st_size > (uintmax_t)SIZE_T_MAX)

That should work.  I've also solved this problem in the past with
	if ((sizeof(off_t) > sizeof(size_t)) &&
	    (sb.st_size > (off_t)

-- 
Colin Percival
Security Officer, FreeBSD | freebsd.org | The power to serve
Founder / author, Tarsnap | tarsnap.com | Online backups for the truly paranoid


More information about the svn-src-all mailing list