On Mon, Dec 31, 2001 at 10:39:54AM -0500, Dan Sugalski wrote:
> Folks,
> 
> I've just made a few minor changes to configure.pl regarding the switches 
> for gcc. Now instead of -Wall being the defaults, it's:
> 
>   -Wall -ansi -pedantic -Wtraditional -Wstrict-prototypes 
> -Wmissing-prototypes -Winline -Wredundant-decls -Wall -Wshadow 
> -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion 
> -Waggregate-return -Winline
> 
> And yes, I see that -Wall's in there twice. (You never notice until after 
> commit)

As is -Winline

> The list of error is rather... impressive. Lets all fix 'em up, shall we?

The appended patch silences the warnings in what I believe is a correct way
[opcode_t will never have more than 32 bits of information, will it?
In which case casting a long long opcode_t back to a 32 bit long isn't going
to lose anything.
Otherwise, we'll have to go the whole hog with knowing printf formats for
the length of our types so that the code will work on strict C89 systems
("the prophet ANSI spake unto us that long is the longest type - what is
this 'long long' heresy of which you speak?") and more recent systems with
long long.

Nicholas Clark

--- packfile.c~ Mon Dec 31 00:15:28 2001
+++ packfile.c  Tue Jan  1 14:26:49 2002
@@ -518,7 +518,7 @@
 PackFile_dump(struct PackFile * self) {
     opcode_t i;
 
-    printf("MAGIC => 0x%08x,\n", self->magic);
+    printf("MAGIC => 0x%08lx,\n", (long) self->magic);
 
     printf("FIXUP => {\n");
 
@@ -536,9 +536,9 @@
 
     for (i = 0; i < self->byte_code_size / 4; i++) {
         if (i % 8 == 0) {
-            printf("\n    %08x:  ", i * 4);
+            printf("\n    %08lx:  ", (long) i * 4);
         }
-        printf("%08x ", ((opcode_t *)(self->byte_code))[i]);
+        printf("%08lx ", (long) ((opcode_t *)(self->byte_code))[i]);
     }
 
     printf("\n]\n");
@@ -1052,7 +1052,7 @@
     }
 
     for(i = 0; i < self->const_count; i++) {
-        printf("    # %d:\n", i);
+        printf("    # %ld:\n", (long) i);
         PackFile_Constant_dump(self->constants[i]);
     }
 
@@ -1330,7 +1330,7 @@
             break;
 
         default:
-            fprintf(stderr, "PackFile_Constant_clear: Unrecognized type '%c' during 
unpack!\n", type);
+            fprintf(stderr, "PackFile_Constant_clear: Unrecognized type '%c' during 
+unpack!\n", (int) type);
             return 0;
             break;
     }
@@ -1712,7 +1712,7 @@
 
         case PFC_STRING:
             printf("    [ 'PFC_STRING', {\n");
-            printf("        FLAGS    => 0x%04x,\n", self->string->flags);
+            printf("        FLAGS    => 0x%04lx,\n", (long) self->string->flags);
             printf("        ENCODING => %s,\n",
                     self->string->encoding->name);
             printf("        TYPE     => %s,\n",

Reply via email to