svn commit: r243262 - head/usr.bin/top

Bruce Evans brde at optusnet.com.au
Mon Nov 19 19:36:19 UTC 2012


On Mon, 19 Nov 2012, Rui Paulo wrote:

> On 19 Nov 2012, at 00:26, Alexey Dokuchaev <danfe at 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


More information about the svn-src-head mailing list