develooper Front page | perl.perl5.porters | Postings from March 2007

Re: Change 30774: [PATCH] stop the cargo cult of (MEM_SIZE)~0

Thread Next
From:
Nicholas Clark
Date:
March 27, 2007 13:31
Subject:
Re: Change 30774: [PATCH] stop the cargo cult of (MEM_SIZE)~0
Message ID:
20070327203142.GU6221@plum.flirble.org
On Tue, Mar 27, 2007 at 05:45:04AM -0700, H. Merijn Brand wrote:
> Change 30774 by merijn@merijn-pc09 on 2007/03/27 12:30:11
> 
> 	Subject: [PATCH] stop the cargo cult of (MEM_SIZE)~0
> 	From: Jarkko Hietaniemi <jhi@cc.hut.fi>
> 	Date: Tue, 27 Mar 2007 15:07:52 +0300 (EEST)
> 	Message-Id: <200703271207.l2RC7qOC443040@kosh.hut.fi>

> +#define MEM_SIZE_MAX ((MEM_SIZE)~0)

> -		if (len > ((MEM_SIZE)~0)/count)
> +		if (len > MEM_SIZE_MAX / count)

> -    if (size && (count <= (MEM_SIZE)~0 / size))
> +    if (size && (count <= MEM_SIZE_MAX / size))

> -    if (sTHX <= (MEM_SIZE)~0 - (MEM_SIZE)total_size)
> +    if (sTHX <= MEM_SIZE_MAX - (MEM_SIZE)total_size)


I realise that you're just refactoring existing expressions to D.R.Y.
but does (MEM_SIZE)~0 actually work. Has our code been broken for years?

In C, say if 0 is of type int, and MEM_SIZE is of type long long, isn't
(~(MEM_SIZE)0) what we really want here?

Nicholas Clark

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About