libDtHelp is unable to read SDL help files
with -ftree-store-ccp optimization which
is enabled by -O2 on gcc 4.2.1.

GifUtils.c and decompress.c didn't work
properly with -ftree-store-ccp enabled.

GifUtils.c was repaired by fixing
those warnings:

GifUtils.c: In function 'create_pixmap':
GifUtils.c:1093: warning: return makes integer from pointer without a cast
GifUtils.c:1110: warning: return makes integer from pointer without a cast
GifUtils.c:1215: warning: return makes integer from pointer without a cast
GifUtils.c: In function 'gif_to_pixmap':
GifUtils.c:1242: warning: return makes integer from pointer without a cast

decompress.c didn't generate warnings, but the
only effect of the -ftree-store-cpp was to introduce
this change:

        addq    $1, %rax
        movq    %rax, (%rbx)
 .L90:
-       cmpl    $157, %edx
+       cmpl    $-99, %edx
        jne     .L86
        movl    8(%rbx), %eax
        subl    $1, %eax

Which corresponds to this source code:

bufioI.h

     57 #define BufFileGet(f)   ((f)->left-- ? *(f)->bufp++ : (*(f)->io) (f))

     42     int     (*io)(/* BufFilePtr f */);

decompress.c
     53 #ifdef NO_UCHAR
     54  typedef char   char_type;
     55 #else
     56  typedef        unsigned char   char_type;
     57 #endif /* UCHAR */
     58
     59 static  char_type magic_header[] = { "\037\235" };      /* 1F 9D */

    131     if ((BufFileGet(f) != (magic_header[0] & 0xFF)) ||
    132         (BufFileGet(f) != (magic_header[1] & 0xFF)))
    133     {
    134         return 0;
    135     }

BufFileGet() returns (int), so the (unsigned char) constants
got promoted to (int) with sign extension; therefore constant
157 decimal (0x9D) became -99 decimal, sign extended
(0xffffff9D), and the comparison was always false.

Tested using:
$ gcc -v
Using built-in specs.
Target: amd64-undermydesk-freebsd
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 4.2.1 20070831 patched [FreeBSD]

Running on:
FreeBSD 10.0-CURRENT (r240948M)
built Wed Sep 26 23:33:08 CEST 2012
---
 cde/lib/DtHelp/GifUtils.c   | 8 ++++----
 cde/lib/DtHelp/decompress.c | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/cde/lib/DtHelp/GifUtils.c b/cde/lib/DtHelp/GifUtils.c
index f0a78c4..d21f869 100644
--- a/cde/lib/DtHelp/GifUtils.c
+++ b/cde/lib/DtHelp/GifUtils.c
@@ -1090,7 +1090,7 @@ create_pixmap( GifObj *g, pixel **image, int width, int 
height, Pixel fg, Pixel
 
   if (!ximData) {
     fprintf(stderr, "Could not allocate ximage data\n");
-    return NULL;
+    return None;
   }
 
   /* Monochrome */
@@ -1107,7 +1107,7 @@ create_pixmap( GifObj *g, pixel **image, int width, int 
height, Pixel fg, Pixel
 
   if (!g->f_ximage) {
     fprintf(stderr, "XCreateImage failed\n");
-    return NULL;
+    return None;
   }
 
 
@@ -1212,7 +1212,7 @@ else
 
   if (!pm) {
     fprintf(stderr, "could not create pixmap\n");
-    return NULL;
+    return None;
   }
 
   _XmPutScaledImage (g->f_dpy,pm,g->f_gc,g->f_ximage,
@@ -1239,7 +1239,7 @@ gif_to_pixmap(GifObj *g, byte *inbuf, unsigned int 
buflen, Dimension *w, Dimensi
 
   /* Create raw image from compress GIF data */
   raw_image = create_raw_image (inbuf, buflen, &width, &height, 1);
-  if (!raw_image) return NULL;
+  if (!raw_image) return None;
 
   /* Create X pixmap from raw image data */
   pixmap = create_pixmap(g, raw_image, width, height, fg, bg, ratio);
diff --git a/cde/lib/DtHelp/decompress.c b/cde/lib/DtHelp/decompress.c
index b96be4f..05698dd 100644
--- a/cde/lib/DtHelp/decompress.c
+++ b/cde/lib/DtHelp/decompress.c
@@ -56,7 +56,7 @@ typedef long int        count_int;
  typedef       unsigned char   char_type;
 #endif /* UCHAR */
 
-static char_type magic_header[] = { "\037\235" };      /* 1F 9D */
+static int magic_header[] = { 0x1F, 0x9D }; 
 
 /* Defines for third byte of header */
 #define BIT_MASK       0x1f
@@ -128,8 +128,8 @@ _DtHelpCeBufFilePushZ (BufFilePtr f)
     CompressedFile  *file;
     int                    extra;
 
-    if ((BufFileGet(f) != (magic_header[0] & 0xFF)) ||
-       (BufFileGet(f) != (magic_header[1] & 0xFF)))
+    if ((BufFileGet(f) != magic_header[0]) ||
+       (BufFileGet(f) != magic_header[1]))
     {
        return 0;
     }
-- 
1.7.11.5


------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
cdesktopenv-devel mailing list
cdesktopenv-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdesktopenv-devel

Reply via email to