[Ffmpeg-cvslog] CVS: ffmpeg/libavcodec bitstream.h,1.155,1.156

Erik Slagter erik
Thu Sep 22 11:50:31 CEST 2005

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.

But I guess we've had this discussion before...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2115 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-cvslog/attachments/20050922/26fe6d2d/attachment.bin>

More information about the ffmpeg-cvslog mailing list