Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 20 Nov 2012 06:36:09 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Rui Paulo <rpaulo@freebsd.org>
Cc:        svn-src-head@freebsd.org, Alexey Dokuchaev <danfe@freebsd.org>, src-committers@freebsd.org, svn-src-all@freebsd.org
Subject:   Re: svn commit: r243262 - head/usr.bin/top
Message-ID:  <20121120063319.H3656@besplex.bde.org>
In-Reply-To: <3241E07C-D177-4297-825A-A52FEA8F1241@FreeBSD.org>
References:  <201211190803.qAJ83eRo014127@svn.freebsd.org> <20121119082618.GB67020@FreeBSD.org> <3241E07C-D177-4297-825A-A52FEA8F1241@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, 19 Nov 2012, Rui Paulo wrote:

> On 19 Nov 2012, at 00:26, Alexey Dokuchaev <danfe@FreeBSD.org> wrote:
>
>> On Mon, Nov 19, 2012 at 08:03:40AM +0000, Rui Paulo wrote:
>>> New Revision: 243262
>>> URL: http://svnweb.freebsd.org/changeset/base/243262
>>>
>>> -	cmdbuf = (char *)malloc(cmdlengthdelta + 1);
>>> +	cmdbuf = (char *)malloc(cmdlen + 1);
>>
>> Why explicitly casting malloc return() value (void *)?
>
> Why are you asking me about code I didn't write? :-)
> I don't want to mix style changes with functional changes so I let it be. If you're asking why our source tree has malloc casts, it's because compilers in the 1980s used to be unnecessarily more pedantic.

It is more because code written in the 1980's didn't even declare
malloc().  It tried to hide its bug by casting malloc().  The behaviour
was still undefined.  Now, C++ compilers are more strict.

Bruce



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121120063319.H3656>