]> git.sesse.net Git - vlc/commitdiff
Fix ptrdiff_t abuse. Especially in video_filter_invert:
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 9 Sep 2007 19:56:31 +0000 (19:56 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 9 Sep 2007 19:56:31 +0000 (19:56 +0000)
ptrdiff_t is signed so unequality comparison between pointers would
compute wrong when the two operands are within opposite halves of the
memory space.

modules/misc/memcpy/fastmemcpy.h
modules/video_filter/deinterlace.c
modules/video_filter/invert.c

index efca0490deacaff448ce53e2f9339785736ad50f..4465a9510cfd1b08f771dc486322df75d60f5c4e 100644 (file)
@@ -246,7 +246,7 @@ void * fast_memcpy(void * to, const void * from, size_t len)
        }
 #else
        /* Align destination at BLOCK_SIZE boundary */
-       for(; ((ptrdiff_t)to & (BLOCK_SIZE-1)) && i>0; i--)
+       for(; ((uintptr_t)to & (BLOCK_SIZE-1)) && i>0; i--)
        {
                __asm__ __volatile__ (
 #ifndef HAVE_MMX1
@@ -273,7 +273,7 @@ void * fast_memcpy(void * to, const void * from, size_t len)
                to = (void *) (((unsigned char *)to)+64);
        }
 
-/*     printf(" %p %p\n", (ptrdiff_t)from&1023, (ptrdiff_t)to&1023); */
+/*     printf(" %p %p\n", (uintptr_t)from&1023, (uintptr_t)to&1023); */
        /* Pure Assembly cuz gcc is a bit unpredictable ;) */
 # if 0
        if(i>=BLOCK_SIZE/64)
index 23f9ad9b3ddccfd184c442e36f0e19382f273c45..d409ce7ffaf7fe5417d17349fc8c43d415a7d843 100644 (file)
@@ -1009,7 +1009,7 @@ static void MergeSSE2( void *_p_dest, const void *_p_s1, const void *_p_s2,
     const uint8_t *p_s1 = (const uint8_t *)_p_s1;
     const uint8_t *p_s2 = (const uint8_t *)_p_s2;
     uint8_t* p_end;
-    while( (ptrdiff_t)p_s1 % 16 )
+    while( (uintptr_t)p_s1 % 16 )
     {
         *p_dest++ = ( (uint16_t)(*p_s1++) + (uint16_t)(*p_s2++) ) >> 1;
     }        
index b0c246f3b2ff4a538628b87d78ae04fa99089dc5..c11e1ad4f441c1e29ac099b4d9418d5d8ef57f14 100644 (file)
@@ -151,7 +151,7 @@ static picture_t *Filter( filter_t *p_filter, picture_t *p_pic )
             p_in64 = (uint64_t*)p_in;
             p_out64 = (uint64_t*)p_out;
 
-            for( ; (ptrdiff_t)p_in64 < (ptrdiff_t)p_line_end ; )
+            while( p_in64 < p_line_end )
             {
                 /* Do 64 pixels at a time */
                 *p_out64++ = ~*p_in64++; *p_out64++ = ~*p_in64++;