[Ffmpeg-cvslog] CVS: ffmpeg/libavcodec bitstream.h,1.155,1.156
Måns Rullgård
mru
Thu Sep 22 19:38:44 CEST 2005
Erik Slagter <erik at slagter.name> writes:
> On Thu, 2005-09-22 at 10:35 +0200, Michel Bardiaux wrote:
>> >> static inline void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
>> >> {
>> >>- if(buffer_size < 0)
>> >>- buffer= buffer_size= 0;
>
>> > Can you explain how either of these involves a pointer to integer
>> > cast? IMO the old versions were fine.
>
>> buffer= buffer_size= 0;
>>
>> means
>>
>> buffer=(buffer_size=0);
>>
>> (buffer_size=0) evaluates to an integer expression, which generally may
>> not be cast to a pointer without an explicit cast.
>>
>> Of course, the compiler *could* notice that that expression evaluates to
>> a constant which is necessarily zero, which it could cast to NULL then
>> to pointer, without warning. But all that means is that one could debate
>> whether *suppressing* the warning here is legitimate. Keeping it always
>> will be legit.
>
> Common pitfal... "0" is either an integer or a pointer in C, depending
> on what's needed. So it's never an error (or even a warning) to assign 0
> to a pointer. So imho the eaky NULL is almost never needed, in case you
> write (type *)0, you don't ever need it.
The compiler is still right about the warning. An expression like
buffer_size=0 is not a constant evaluating to 0, nor is it a pointer
value.
Rich's complaint was about an accidental reversing of words in the
checkin comment: "pointer to integer" instead of "integer to pointer".
--
M?ns Rullg?rd
mru at inprovide.com
More information about the ffmpeg-cvslog
mailing list