On Tue, 2004-02-10 at 19:10 -0800, Stas Bekman wrote:
> Philippe M. Chiasson wrote:
> > Caught a few little problems caught by gcc -Wall -Werror this morning.
> 
> Good catches, philippe. But plugging these holes with "random" values is ain't 
> right. There is a logic bug that needs to be fixed if we have these issues.

Yes, I agree with you. I plugged those holes with pretty bad
assumptions. I took in your suggestions, and tested it against my gcc
with success.

Only adding a case default that Perl_croaks works fine too.

With the following patch, compiles cleans & all tests pass!

Index: src/modules/perl/modperl_const.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_const.c,v
retrieving revision 1.9
diff -u -I$Id -r1.9 modperl_const.c
--- src/modules/perl/modperl_const.c    12 May 2003 13:00:15 -0000      1.9
+++ src/modules/perl/modperl_const.c    11 Feb 2004 21:45:37 -0000
@@ -4,17 +4,16 @@
 typedef SV *(*constants_lookup)(pTHX_ const char *);
 typedef const char ** (*constants_group_lookup)(const char *);
 
-static SV *new_constsub(pTHX_ constants_lookup lookup,
+static void new_constsub(pTHX_ constants_lookup lookup,
                         HV *caller_stash, HV *stash,
                         const char *name)
 {
     int name_len = strlen(name);
     GV **gvp = (GV **)hv_fetch(stash, name, name_len, TRUE);
-    SV *val;
 
     /* dont redefine */
     if (!isGV(*gvp) || !GvCV(*gvp)) {
-        val = (*lookup)(aTHX_ name);
+        SV *val = (*lookup)(aTHX_ name);
 
 #if 0
         fprintf(stderr, "newCONSTSUB(%s, %s, %d)\n",
@@ -38,8 +37,6 @@
 
         GvCV(alias) = GvCV(*gvp);
     }
-
-    return val;
 }
 
 int modperl_const_compile(pTHX_ const char *classname,
Index: src/modules/perl/modperl_filter.c
===================================================================
RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_filter.c,v
retrieving revision 1.81
diff -u -I$Id -r1.81 modperl_filter.c
--- src/modules/perl/modperl_filter.c   9 Feb 2004 19:32:42 -0000       1.81
+++ src/modules/perl/modperl_filter.c   11 Feb 2004 21:45:37 -0000
@@ -325,30 +325,28 @@
 int modperl_filter_resolve_init_handler(pTHX_ modperl_handler_t *handler,
                                         apr_pool_t *p)
 {
-    char *init_handler_pv_code;
-    char *package_name;
-    CV *cv;
-    MAGIC *mg;
+    char *init_handler_pv_code = NULL;
     
     if (handler->mgv_cv) {
-        GV *gv;
-        if ((gv = modperl_mgv_lookup(aTHX_ handler->mgv_cv))) {
-            cv = modperl_mgv_cv(gv);
-            package_name = modperl_mgv_as_string(aTHX_ handler->mgv_cv, p, 1);
-            /* fprintf(stderr, "PACKAGE: %s\n", package_name ); */
+        GV *gv = modperl_mgv_lookup(aTHX_ handler->mgv_cv);
+        if (gv) {
+            CV *cv = modperl_mgv_cv(gv);
+            if (cv && SvMAGICAL(cv)) {
+                MAGIC *mg = mg_find((SV*)(cv), '~');
+                init_handler_pv_code = mg ? mg->mg_ptr : NULL;
+            }
+            else {
+                /* XXX: should we complain in such a case? */
+                return 0;
+            }
         }
     }
-
-    if (cv && SvMAGICAL(cv)) {
-        mg = mg_find((SV*)(cv), '~');
-        init_handler_pv_code = mg ? mg->mg_ptr : NULL;
-    }
-    else {
-        /* XXX: should we complain in such a case? */
-        return 0;
-    }
     
     if (init_handler_pv_code) {
+        char *package_name =
+            modperl_mgv_as_string(aTHX_ handler->mgv_cv, p, 1);
+        /* fprintf(stderr, "PACKAGE: %s\n", package_name ); */
+
         /* eval the code in the parent handler's package's context */
         char *code = apr_pstrcat(p, "package ", package_name, ";",
                                  init_handler_pv_code, NULL);
Index: xs/APR/PerlIO/apr_perlio.c
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/PerlIO/apr_perlio.c,v
retrieving revision 1.35
diff -u -I$Id -r1.35 apr_perlio.c
--- xs/APR/PerlIO/apr_perlio.c  10 Oct 2003 19:47:12 -0000      1.35
+++ xs/APR/PerlIO/apr_perlio.c  11 Feb 2004 21:45:37 -0000
@@ -87,6 +87,8 @@
       case 'r':
         apr_flag = APR_READ;
         break;
+      default:
+        Perl_croak(aTHX_ "unknown open mode: %s", mode);
     }
 
     /* APR_BINARY:   we always do binary read and PerlIO is supposed
@@ -249,6 +251,8 @@
       case 2:
         where = APR_END;
         break;
+      default:
+        Perl_croak(aTHX_ "unknown whence mode: %d", whence);
     }
 
     rc = apr_file_seek(st->file, where, &seek_offset);
@@ -451,6 +455,8 @@
       case APR_PERLIO_HOOK_READ:
         mode = "r";
         break;
+      default:
+        Perl_croak(aTHX_ "unknown APR_PERLIO type: %d", type);
     };
     
     PerlIO_apply_layers(aTHX_ f, mode, layers);

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to