[MPlayer-dev-eng] [PATCH] fix a few warnings

Dominik 'Rathann' Mierzejewski dominik at rangers.eu.org
Tue Feb 6 00:50:16 CET 2007


On Thursday, 25 January 2007 at 11:48, Reimar Döffinger wrote:
> Hello,
> On Thu, Jan 25, 2007 at 04:57:49AM +0100, Dominik 'Rathann' Mierzejewski wrote:
> > Found this rotting in my patch queue.
> > 
> > One weird thing, though:
> > 
> > libmpdemux/demux_mov.c:
> > @@ -1369,7 +1369,7 @@                                                                                                   
> >             z_stream zstrm;
> >             stream_t* backup;
> > 
> > -           if (moov_sz > SIZE_MAX - 16) {
> > +           if (moov_sz > INT_MAX - 16) {
> >                mp_msg(MSGT_DEMUX, MSGL_ERR, "Invalid cmvd atom size %d\n", moov_sz);
> >                break;
> >              }
> > 
> > With SIZE_MAX, I get "condition always false" or something like that.
> 
> IMO the former one is correct. Though this condition really is always
> false on 64 bit systems. Changing the type of moov_sz from "unsigned
> int" to size_t might be an acceptable workaround though if desired.

How about the attached patch?

Regards,
R.

-- 
MPlayer developer and RPMs maintainer: http://mplayerhq.hu http://rpm.livna.org
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
	-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
-------------- next part --------------
--- demux_mov.c.warn	2007-02-05 22:52:53.000000000 +0100
+++ demux_mov.c	2007-02-06 00:49:02.000000000 +0100
@@ -1392,8 +1392,8 @@
 	}
 	case MOV_FOURCC('c','m','v','d'): {
 //	    int temp=stream_read_dword(demuxer->stream);
-	    unsigned int moov_sz=stream_read_dword(demuxer->stream);
-	    unsigned int cmov_sz=len-4;
+	    size_t moov_sz=stream_read_dword(demuxer->stream);
+	    size_t cmov_sz=len-4;
 	    unsigned char* cmov_buf;
 	    unsigned char* moov_buf;
 	    int zret;
@@ -1401,12 +1401,12 @@
 	    stream_t* backup;
 
 	    if (moov_sz > SIZE_MAX - 16) {
-              mp_msg(MSGT_DEMUX, MSGL_ERR, "Invalid cmvd atom size %d\n", moov_sz);
+              mp_msg(MSGT_DEMUX, MSGL_ERR, "Invalid cmvd atom size %ld\n", moov_sz);
               break;
             }
 	    cmov_buf=malloc(cmov_sz);
 	    moov_buf=malloc(moov_sz+16);
-	    mp_msg(MSGT_DEMUX, MSGL_V, "Compressed header size: %d / %d\n",cmov_sz,moov_sz);
+	    mp_msg(MSGT_DEMUX, MSGL_V, "Compressed header size: %ld / %ld\n",cmov_sz,moov_sz);
 
 	    stream_read(demuxer->stream,cmov_buf,cmov_sz);
 
@@ -1437,7 +1437,7 @@
 	      }
 #endif
 	      if(moov_sz != zstrm.total_out)
-	        mp_msg(MSGT_DEMUX, MSGL_WARN, "Warning! moov size differs cmov: %d  zlib: %ld\n",moov_sz,zstrm.total_out);
+	        mp_msg(MSGT_DEMUX, MSGL_WARN, "Warning! moov size differs cmov: %ld  zlib: %ld\n",moov_sz,zstrm.total_out);
 	      zret = inflateEnd(&zstrm);
 	      
 	      backup=demuxer->stream;


More information about the MPlayer-dev-eng mailing list