develooper Front page | perl.perl6.internals | Postings from December 2001

attempts to clean up a few warnings

From:
Josh Wilmes
Date:
December 19, 2001 17:43
Subject:
attempts to clean up a few warnings
Message ID:
200112200143.TAA22652@sky.net

I'm no sure if i've submitted some of these before, but here goes.

Diffs against current cvs:

Index: Configure.pl
===================================================================
RCS file: /home/perlcvs/parrot/Configure.pl,v
retrieving revision 1.39
diff -u -r1.39 Configure.pl
--- Configure.pl	15 Dec 2001 01:39:40 -0000	1.39
+++ Configure.pl	20 Dec 2001 01:40:30 -0000
@@ -9,7 +9,7 @@
 use ExtUtils::Manifest qw(manicheck);
 use File::Copy;
 
-my($opt_debugging, $opt_defaults, $opt_version, $opt_help) = (0, 0, 0, 0);
+my($opt_debugging, $opt_defaults, $opt_version, $opt_help, $opt_pedantic) = (0, 0, 0, 0, 0);
 my(%opt_defines);
 my $result = GetOptions(
 	'debugging!' => \$opt_debugging,
@@ -17,6 +17,7 @@
 	'version'    => \$opt_version,
 	'help'       => \$opt_help,
 	'define=s'   => \%opt_defines,
+	'pedantic!'  => \$opt_pedantic,
 );
 
 if($opt_version) {
@@ -29,6 +30,7 @@
 $0 - Parrot Configure
 Options:
    --debugging          Enable debugging
+   --pedantic           Add "-ansi -pedantic" if using gcc
    --defaults           Accept all default values
    --define name=value  Defines value name as value
    --help               This text
@@ -73,9 +75,11 @@
 
 	cc =>			$Config{cc},
 	#ADD C COMPILER FLAGS HERE
+        cc_inc  =>              "-I./include",
 	ccflags =>		$Config{ccflags},
 	libs =>			$Config{libs},
 	cc_debug =>		'-g',
+	cc_warn =>		'',
 	o =>			'.o',		# object files extension
 	exe =>			$Config{_exe},
 
@@ -99,6 +103,15 @@
 	cp =>		'cp',
 	slash =>	'/',
 );
+
+
+# If using gcc, crank up its warnings as much as possible and optionally
+# make it behave ansi-ish.
+if ($Config{ccname} eq "gcc") {
+   $c{cc_warn} = " -Wall";
+   $c{cc_warn} .= " -ansi -pedantic" if $opt_pedantic;
+}
+
 
 #copy the things from --define foo=bar
 @c{keys %opt_defines}=values %opt_defines;
Index: Makefile.in
===================================================================
RCS file: /home/perlcvs/parrot/Makefile.in,v
retrieving revision 1.79
diff -u -r1.79 Makefile.in
--- Makefile.in	18 Dec 2001 07:05:00 -0000	1.79
+++ Makefile.in	20 Dec 2001 01:40:30 -0000
@@ -24,7 +24,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} -I./include
+CFLAGS = ${ccflags} ${cc_warn} ${cc_debug} ${cc_inc}
 
 C_LIBS = ${libs}
 
@@ -33,6 +33,8 @@
 PERL = ${perl}
 TEST_PROG = ${test_prog}
 PDUMP = pdump${exe}
+LINT = lclint
+LINTFLAGS = +showscan +posixlib -weak +longintegral +matchanyintegral -formattype
 # This is set to  MAKE=$make if your $make command doesn't
 # do it for you.
 ${make_set_make}
@@ -173,3 +175,6 @@
 update:
 	cvs -q update -dP
 
+lint: ${test_prog}
+	$(LINT) ${cc_inc} -Iclasses $(LINTFLAGS) `echo $(O_FILES) | sed 's/\.o/\.c/g'`
+	$(LINT) ${cc_inc} $(LINTFLAGS) test_main.c
Index: packfile.c
===================================================================
RCS file: /home/perlcvs/parrot/packfile.c,v
retrieving revision 1.16
diff -u -r1.16 packfile.c
--- packfile.c	6 Dec 2001 21:22:13 -0000	1.16
+++ packfile.c	20 Dec 2001 01:40:31 -0000
@@ -333,7 +333,7 @@
 
     if (segment_size % sizeof(opcode_t)) {
         fprintf(stderr, "PackFile_unpack: Illegal fixup table segment size %d (must be multiple of %d)!\n",
-            segment_size, sizeof(opcode_t));
+            (int)segment_size, sizeof(opcode_t));
         return 0;
     }
 
@@ -358,7 +358,7 @@
 
     if (segment_size % sizeof(opcode_t)) {
         fprintf(stderr, "PackFile_unpack: Illegal constant table segment size %d (must be multiple of %d)!\n",
-            segment_size, sizeof(opcode_t));
+            (int)segment_size, sizeof(opcode_t));
         return 0;
     }
 
@@ -1718,7 +1718,8 @@
                     (long) self->string->bufused);
             /* TODO: Won't do anything reasonable for most encodings */
             printf("        DATA     => '%.*s'\n",
-                    self->string->bufused, (char *) self->string->bufstart);
+                   (int)self->string->bufused,
+                   (char *) self->string->bufstart);
             printf("    } ],\n");
             break;
 
Index: pdump.c
===================================================================
RCS file: /home/perlcvs/parrot/pdump.c,v
retrieving revision 1.6
diff -u -r1.6 pdump.c
--- pdump.c	6 Dec 2001 17:48:58 -0000	1.6
+++ pdump.c	20 Dec 2001 01:40:31 -0000
@@ -62,7 +62,10 @@
 
     pf = PackFile_new();
 
-    PackFile_unpack(interpreter, pf, packed, packed_size);
+    if (!PackFile_unpack(interpreter, pf, packed, packed_size)) {
+        printf( "Can't unpack.\n" );
+        return 1;
+    }
     PackFile_dump(pf);
     PackFile_DELETE(pf);
 
Index: register.c
===================================================================
RCS file: /home/perlcvs/parrot/register.c,v
retrieving revision 1.12
diff -u -r1.12 register.c
--- register.c	22 Oct 2001 18:02:24 -0000	1.12
+++ register.c	20 Dec 2001 01:40:31 -0000
@@ -311,7 +311,7 @@
 Parrot_clear_n(struct Parrot_Interp *interpreter) {
     int i;
     for (i=0; i<NUM_REGISTERS; i++) {
-        interpreter->num_reg->registers[i] = 0;
+        interpreter->num_reg->registers[i] = 0.0;
     }
 }
 
Index: string.c
===================================================================
RCS file: /home/perlcvs/parrot/string.c,v
retrieving revision 1.24
diff -u -r1.24 string.c
--- string.c	13 Dec 2001 16:21:55 -0000	1.24
+++ string.c	20 Dec 2001 01:40:31 -0000
@@ -47,7 +47,7 @@
     s->encoding = encoding;
     s->buflen = s->bufused = buflen;
     s->flags = flags;
-    string_compute_strlen(s);
+    (void)string_compute_strlen(s);
     s->type = type;
 
     return s;
Index: include/parrot/key.h
===================================================================
RCS file: /home/perlcvs/parrot/include/parrot/key.h,v
retrieving revision 1.2
diff -u -r1.2 key.h
--- include/parrot/key.h	12 Dec 2001 02:12:15 -0000	1.2
+++ include/parrot/key.h	20 Dec 2001 01:40:32 -0000
@@ -46,6 +46,7 @@
 INTVAL key_size(struct Parrot_Interp *interpreter, KEY *key);
 void key_set_size(struct Parrot_Interp *interpreter, KEY *key, INTVAL size);
 void key_destroy(struct Parrot_Interp *interpreter, KEY *key);
+INTVAL key_element_type(struct Parrot_Interp *interpreter, KEY* key, INTVAL index);
 KEY_PAIR* key_element_value_i(struct Parrot_Interp *interpreter, KEY *key, INTVAL index);
 KEY_PAIR* key_element_value_s(struct Parrot_Interp *interpreter, KEY *key, STRING* index);
 void key_set_element_value_i(struct Parrot_Interp *interpreter, KEY *key, INTVAL index, KEY_PAIR* value);
Index: include/parrot/trace.h
===================================================================
RCS file: /home/perlcvs/parrot/include/parrot/trace.h,v
retrieving revision 1.2
diff -u -r1.2 trace.h
--- include/parrot/trace.h	13 Dec 2001 16:21:55 -0000	1.2
+++ include/parrot/trace.h	20 Dec 2001 01:40:33 -0000
@@ -19,6 +19,9 @@
 trace_op_dump(struct Parrot_Interp *interpreter, opcode_t *code_start, opcode_t *pc);
 
 void
+trace_op(struct Parrot_Interp *interpreter, opcode_t * code_start, opcode_t * code_end, opcode_t *pc);
+
+void
 trace_op_b0(struct Parrot_Interp *interpreter, opcode_t * code_start, opcode_t *pc);
 
 void
Index: platforms/generic.c
===================================================================
RCS file: /home/perlcvs/parrot/platforms/generic.c,v
retrieving revision 1.2
diff -u -r1.2 generic.c
--- platforms/generic.c	7 Nov 2001 14:43:34 -0000	1.2
+++ platforms/generic.c	20 Dec 2001 01:40:33 -0000
@@ -2,6 +2,7 @@
 ** platform.c [generic version]
 */
 
+#include <time.h>
 #include <sys/time.h>
 #include <dlfcn.h>
 








nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About