Ah, once again you can't argue facts, so you resort to denigrating comments.
>
>>>> The extra cast doesn't hurt anything (other than
>>>> add a few extra characters to the statement),
>>>
>>> That statement is a simple denial of a fact quoted by you above.
>>>
>>
>> Not at all. There is a relationship between the type of p and malloc.
>> And during development (or even during maintenance), the type of p may
>> need to be changed for one reason or another.
>
> Again I'm sorry but this is not meaningful; it's utter nonsense.
>
Ah, once again you can't argue facts, so you resort to denigrating
comments. The fact is - types DO change during both development and
maintenance.
>
>>>> but can protect against inadvertent problems.
>>>
>>> Yes it can, but at needless cost (no matter how you deny it: denial
>>> doesn't really work) and loss of clarity.
>>>
>>
>> The cost is only a few cycles at compile time - less, in fact, than the
>> cost of your macro.
>
> And yet again I'm sorry but this is not meaningful; it's utter nonsense.
>
Ah, once again you can't argue facts, so you resort to denigrating
comments. The truth hurts, doesn't it?
>
>>>> For CERT's recommendation see
>>>>
https://www.securecoding.cert.org/confluence/display/c/MEM02-C.+Immediately+cast+the+result+of+a+memory+allocation+function+call+into+a+pointer+to+the+allocated+type
>>>>
>>>>
>>>
>>> Apparently originally that article contained
>>>
>>>> "Explicitly casting the return value of malloc() eliminates the
>>>> warning for the implicit declaration of malloc()."
>>>
>>> … mentioned in the comments, which is lunacy.
>>>
>>
>> Not at all lunacy.
>>
>>> Or, let me soften that: using casts to shut up the compiler is something
>>> a first year student might do in the first month or so, but not a
>>> competent programmer.
>>>
>>
>> Or, in the case of pointers, ensuring the types are the same. There are
>> no type conversions between pointers to different types, like there are
>> with other types. Even a first year student understands that.
>
> Oh. I'm sorry. This is not meaningful, it's nonsense.
>
It wouldn't be to you, but it is to a first year student.
Ah, once again you can't argue facts, so you resort to denigrating comments.
>
>> Personally, I take CERT's guidelines over any I see in a newsgroup.
>> Those people know how to develop safe code.
>
> You COULD look at the comments on that guideline.
>
> Given the above avalanche of nonsense I guess relying on authority is a
> reasonable strategy, but do be careful about that.
>
I did, and I stand by my comments.
Ah, once again you can't argue facts, so you resort to denigrating comments.
But then you expect people to rely on YOU - but not on CERT? It doesn't
work that way, Alf.
You have yet to show any reason why your way is better than CERTs. All
you have done is call CERTs recommendations "lunacy". The last resort
of those who can't argue facts.
>
> Cheers & hth.,
>
> - Alf