I'm attaching a patch which adds a "lint" target to the makefile (running 
lclint with some very lenient settings) and fixes some of the things it 
was griping about.

The changes are all pretty trivial, and fall into the following categories:

   - handle return values which were being ignored (either casting to void 
     or doing something with them)
   - cast IVs to (unsigned int) when printfing them with "%x".
   - remove unused variables  (only in one function)
   - return a value in some places where there was a void return but the 
     function had a return type.

--Josh

-- 
Josh Wilmes  ([EMAIL PROTECTED]) | http://www.hitchhiker.org

Index: Configure.pl
===================================================================
RCS file: /home/perlcvs/parrot/Configure.pl,v
retrieving revision 1.19
diff -u -r1.19 Configure.pl
--- Configure.pl	2001/09/23 14:50:48	1.19
+++ Configure.pl	2001/09/29 07:08:38
@@ -72,7 +72,8 @@
     
 	cc =>			$Config{cc},
 	#ADD C COMPILER FLAGS HERE
-	ccflags =>		$Config{ccflags}." -I./include",
+        cc_inc  =>              "-I./include",
+	ccflags =>		$Config{ccflags},
 	libs =>			$Config{libs},
 	cc_debug =>		'-g',
 	o =>			'.o',		# object files extension
Index: Makefile.in
===================================================================
RCS file: /home/perlcvs/parrot/Makefile.in,v
retrieving revision 1.14
diff -u -r1.14 Makefile.in
--- Makefile.in	2001/09/26 18:13:50	1.14
+++ Makefile.in	2001/09/29 07:08:38
@@ -8,7 +8,7 @@
 #DO NOT ADD C COMPILER FLAGS HERE
 #Add them in Configure.pl--look for the
 #comment 'ADD C COMPILER FLAGS HERE'
-CFLAGS = ${ccflags} ${cc_debug}
+CFLAGS = ${ccflags} ${cc_inc} ${cc_debug}
 
 C_LIBS = ${libs}
 
@@ -18,6 +18,9 @@
 TEST_PROG = test_prog${exe}
 PDUMP = pdump${exe}
 
+LINT = lclint
+LINTFLAGS = +showscan +posixlib -weak +longintegral +matchanyintegral -formattype
+
 .c.o:
 	$(CC) $(CFLAGS) -o $@ -c $<
 
@@ -74,4 +77,7 @@
 
 update:
 	cvs -q update -dP
+
+lint: *.c
+	$(LINT) ${cc_inc} $(LINTFLAGS) *.c
 
Index: basic_opcodes.ops
===================================================================
RCS file: /home/perlcvs/parrot/basic_opcodes.ops,v
retrieving revision 1.25
diff -u -r1.25 basic_opcodes.ops
--- basic_opcodes.ops	2001/09/26 18:13:50	1.25
+++ basic_opcodes.ops	2001/09/29 07:08:40
@@ -140,7 +140,7 @@
 
 /* TIME Ix */
 AUTO_OP time_i {
-  INT_REG(P1) = time(NULL);
+  INT_REG(P1) = (IV)time(NULL);
 }
 
 /* PRINT Ix */
@@ -316,7 +316,7 @@
 
 /* TIME Nx */
 AUTO_OP time_n {
-  NUM_REG(P1) = time(NULL);
+  NUM_REG(P1) = (NV)time(NULL);
 }
 
 /* PRINT Nx */
Index: interpreter.c
===================================================================
RCS file: /home/perlcvs/parrot/interpreter.c,v
retrieving revision 1.20
diff -u -r1.20 interpreter.c
--- interpreter.c	2001/09/26 18:13:50	1.20
+++ interpreter.c	2001/09/29 07:08:40
@@ -235,13 +235,15 @@
     
     /* The default opcode function table would be a good thing here... */
     {
+        /*@-castfcnptr@*/
+
         opcode_t *(**foo)();
         foo = mem_sys_allocate(2048 * sizeof(void *));
         
         BUILD_TABLE(foo);
         
         interpreter->opcode_funcs = (void*)foo;

         BUILD_NAME_TABLE(op_names);
         BUILD_ARG_TABLE(op_args);
     }
Index: memory.c
===================================================================
RCS file: /home/perlcvs/parrot/memory.c,v
retrieving revision 1.10
diff -u -r1.10 memory.c
--- memory.c	2001/09/19 20:19:50	1.10
+++ memory.c	2001/09/29 07:08:40
@@ -57,7 +57,7 @@
         }
     }
     
-    mem = malloc(max_to_alloc);
+    mem = malloc((size_t)max_to_alloc);
     if (((IV)mem & mask) < (IV)mem) {
         mem = (void *)(((IV)mem & mask) + ~mask + 1);
     } 
@@ -69,7 +69,7 @@
 */
 void *
 mem_sys_allocate(IV size) {
-    return malloc(size);
+    return malloc((size_t)size);
 }
 
 /*=for api mem mem_setup_allocator
Index: packfile.c
===================================================================
RCS file: /home/perlcvs/parrot/packfile.c,v
retrieving revision 1.5
diff -u -r1.5 packfile.c
--- packfile.c	2001/09/26 18:13:50	1.5
+++ packfile.c	2001/09/29 07:08:42
@@ -282,9 +282,7 @@
 
 IV
 PackFile_unpack(struct PackFile * self, char * packed, IV packed_size) {
-    IV *   segment_ptr;
     IV     segment_size;
-    char * byte_code_ptr;
     char * cursor;
     IV *   iv_ptr;
 
@@ -458,7 +456,7 @@
 PackFile_dump(struct PackFile * self) {
     IV i;
 
-    printf("MAGIC => 0x%08x,\n", self->magic);
+    printf("MAGIC => 0x%08x,\n", (unsigned int)self->magic);
 
     printf("FIXUP => {\n");
     PackFile_FixupTable_dump(self->fixup_table);
@@ -471,9 +469,9 @@
     printf("BCODE => [");
     for (i = 0; i < self->byte_code_size / 4; i++) {
         if (i % 8 == 0) {
-            printf("\n    %08x:  ", i * 4);
+            printf("\n    %08x:  ", (unsigned int) i * 4);
         }
-        printf("%08x ", ((IV *)(self->byte_code))[i]);
+        printf("%08x ", (unsigned int)((IV *)(self->byte_code))[i]);
     }
     printf("\n]\n");
 
@@ -852,7 +850,10 @@
 
     for(i = 0; i < self->const_count; i++) {
         self->constants[i] = PackFile_Constant_new();
-        PackFile_Constant_unpack(self->constants[i], cursor, packed_size - (cursor - packed));
+        if(!PackFile_Constant_unpack(self->constants[i], cursor, packed_size - (cursor - packed))) {
+            fprintf(stderr, "PackFile_ConstTable_unpack: Unable to unpack constant %d\n", i);
+            return 0;
+        }
         /* NOTE: It would be nice if each of these had its own length first */
 
         cursor += PackFile_Constant_pack_size(self->constants[i]);
@@ -961,7 +962,7 @@
 
 =cut
 
-/******************************************************************************
+******************************************************************************/
 
 
 /***************************************
@@ -1091,7 +1092,7 @@
 IV
 PackFile_Constant_get_encoding(struct PackFile_Constant * self) {
     if (!self || !self->string) {
-        return;
+        return -1; 
     }
 
     return self->string->encoding->which;
@@ -1130,7 +1131,7 @@
 IV
 PackFile_Constant_get_type(struct PackFile_Constant * self) {
     if (!self || !self->string) {
-        return;
+        return -1;
     }
 
     return self->type;
@@ -1171,7 +1172,7 @@
 IV
 PackFile_Constant_get_size(struct PackFile_Constant * self) {
     if (!self || !self->string) {
-        return;
+        return -1;
     }
 
     return self->string->bufused;
@@ -1191,7 +1192,7 @@
 char *
 PackFile_Constant_get_data(struct PackFile_Constant * self) {
     if (!self || !self->string) {
-        return;
+        return NULL;
     }
 
     return self->string->bufstart;
@@ -1392,7 +1393,7 @@
     }
 
     printf("    {\n");
-    printf("        FLAGS    => %04x,\n", self->string->flags);
+    printf("        FLAGS    => %04x,\n", (unsigned int)self->string->flags);
     printf("        ENCODING => %ld,\n",  self->string->encoding);
     printf("        TYPE     => %ld,\n",  self->string->type);
     printf("        SIZE     => %ld,\n",  self->string->bufused);
Index: pdump.c
===================================================================
RCS file: /home/perlcvs/parrot/pdump.c,v
retrieving revision 1.2
diff -u -r1.2 pdump.c
--- pdump.c	2001/09/26 18:13:50	1.2
+++ pdump.c	2001/09/29 07:08:42
@@ -58,7 +58,10 @@
 
     pf = PackFile_new();
 
-    PackFile_unpack(pf, packed, packed_size);
+    if (!PackFile_unpack(pf, packed, packed_size)) {
+        printf("Error unpacking file.\n");
+        return 1;
+    }
     PackFile_dump(pf);
     PackFile_DELETE(pf);
 
Index: register.c
===================================================================
RCS file: /home/perlcvs/parrot/register.c,v
retrieving revision 1.8
diff -u -r1.8 register.c
--- register.c	2001/09/17 13:44:13	1.8
+++ register.c	2001/09/29 07:08:43
@@ -209,7 +209,7 @@
 Parrot_clear_n(struct Parrot_Interp *interpreter) {
     int i;
     for (i=0; i<NUM_REGISTERS; i++) {
-        NUM_REG(i) = 0;
+        NUM_REG(i) = 0.0;
     }
 }
 
Index: stacks.c
===================================================================
RCS file: /home/perlcvs/parrot/stacks.c,v
retrieving revision 1.1
diff -u -r1.1 stacks.c
--- stacks.c	2001/09/20 02:52:10	1.1
+++ stacks.c	2001/09/29 07:08:43
@@ -10,7 +10,7 @@
  *  References:
  */
 
-struct Stack_Entry *push_generic_entry(
+struct Stack_Entry *push_generic_entry;
 
 /*
  * Local variables:
Index: string.c
===================================================================
RCS file: /home/perlcvs/parrot/string.c,v
retrieving revision 1.9
diff -u -r1.9 string.c
--- string.c	2001/09/24 17:19:47	1.9
+++ string.c	2001/09/29 07:08:43
@@ -34,7 +34,7 @@
     s->encoding = &(Parrot_string_vtable[encoding]);
     s->buflen = s->bufused = buflen;
     s->flags = flags;
-    string_compute_strlen(s);
+    (void)string_compute_strlen(s);
     s->type = type;
     return s;
 }
Index: test_main.c
===================================================================
RCS file: /home/perlcvs/parrot/test_main.c,v
retrieving revision 1.13
diff -u -r1.13 test_main.c
--- test_main.c	2001/09/26 18:13:50	1.13
+++ test_main.c	2001/09/29 07:08:43
@@ -47,16 +47,16 @@
         time_t foo;
         
         printf("String %p has length %i: %.*s\n", s, (int) string_length(s), (int) string_length(s), (char *) s->bufstart);
-        string_concat(s, t, 0);
+        (void)string_concat(s, t, 0);
         printf("String %p has length %i: %.*s\n", s, (int) string_length(s), (int) string_length(s), (char *) s->bufstart);
-        string_chopn(s, 4);
+        (void)string_chopn(s, 4);
         printf("String %p has length %i: %.*s\n", s, (int) string_length(s), (int) string_length(s), (char *) s->bufstart);
-        string_chopn(s, 4);
+        (void)string_chopn(s, 4);
         printf("String %p has length %i: %.*s\n", s, (int) string_length(s), (int) string_length(s), (char *) s->bufstart);
         foo = time(0);
         for (i = 0; i < 100000000; i++) {
-            string_concat(s, t, 0);
-            string_chopn(s, 4);
+            (void)string_concat(s, t, 0);
+            (void)string_chopn(s, 4);
         }
         printf("10000000 concats and chops took %li seconds.\n", time(0)-foo);
         string_destroy(s);
@@ -94,7 +94,10 @@
         }
         
         pf = PackFile_new();
-        PackFile_unpack(pf, (char *)program_code, program_size);
+        if (! PackFile_unpack(pf, (char *)program_code, program_size)) {
+            printf("Error unpacking packfile.\n");
+            return 1;
+        }
         
         if (tracing) {
             interpreter->flags |= PARROT_TRACE_FLAG;

Reply via email to