[PATCH] More embed.fnc notes, with new known errors!

2005-07-21 Thread Andy Lester
This patch causes many warnings, but I think that's a good thing, as
we'll see later.

* doio.c: Consting

* op.c: Consting.  Hoisted a boolean subexpression in Perl_newWHILEOP
for clarity.

* pp_ctl.c: Consting.

* regcomp.c: Consting  localizing.

* regexec.c: Consting.

* sv.c: Fixed some indentation.  Whitespace change only.

* util.c: Consting.

* embed.fnc: More NN and NULLOK.  Removed an #if 0 section for static
functions that are hard-coded in toke.c.

The functions that I broke are Perl_sv_vcatpvfn and Perl_sv_vsetpvfn.
The SV **svargs parm now has a NN on it, meaning GCC will squawk at
compile if a null is passed in, because the code refers to *args, which
would be a NULL deref if args is NULL.  However, util.c has code that
passes in hardcoded NULLs. :-(

xoxo,
Andy



-- 
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance
diff -pur bleadperl/doio.c bw/trunk/doio.c
--- bleadperl/doio.c2005-07-18 05:22:23.0 -0500
+++ bw/trunk/doio.c 2005-07-21 13:49:59.0 -0500
@@ -747,7 +747,7 @@ Perl_nextargv(pTHX_ register GV *gv)
 #endif
 Uid_t fileuid;
 Gid_t filegid;
-IO *io = GvIOp(gv);
+IO * const io = GvIOp(gv);
 
 if (!PL_argvoutgv)
PL_argvoutgv = gv_fetchpv(ARGVOUT,TRUE,SVt_PVIO);
@@ -802,9 +802,9 @@ Perl_nextargv(pTHX_ register GV *gv)
continue;
}
if (*PL_inplace) {
-   char *star = strchr(PL_inplace, '*');
+   const char *star = strchr(PL_inplace, '*');
if (star) {
-   char *begin = PL_inplace;
+   const char *begin = PL_inplace;
sv_setpvn(sv, , 0);
do {
sv_catpvn(sv, begin, star - begin);
@@ -2333,7 +2333,7 @@ PerlIO *
 Perl_start_glob (pTHX_ SV *tmpglob, IO *io)
 {
 dVAR;
-SV *tmpcmd = NEWSV(55, 0);
+SV * const tmpcmd = NEWSV(55, 0);
 PerlIO *fp;
 ENTER;
 SAVEFREESV(tmpcmd);
diff -pur bleadperl/embed.fnc bw/trunk/embed.fnc
--- bleadperl/embed.fnc 2005-07-20 07:58:35.0 -0500
+++ bw/trunk/embed.fnc  2005-07-21 15:00:57.0 -0500
@@ -239,7 +239,7 @@ ApdR|char*  |fbm_instr  |NN unsigned char
|NN SV* littlesv|U32 flags
 p  |char*  |find_script|const char *scriptname|bool dosearch \
|const char **search_ext|I32 flags
-p  |OP*|force_list |NN OP* arg
+p  |OP*|force_list |NULLOK OP* arg
 p  |OP*|fold_constants |NN OP* arg
 Afpd   |char*  |form   |NN const char* pat|...
 Ap |char*  |vform  |NN const char* pat|NULLOK va_list* args
@@ -297,7 +297,7 @@ Apd |SV**   |hv_store   |HV* tb|const char* 
 Apd|HE*|hv_store_ent   |HV* tb|SV* key|SV* val|U32 hash
 ApM|SV**   |hv_store_flags |HV* tb|const char* key|I32 klen|SV* val \
|U32 hash|int flags
-Apd|void   |hv_undef   |HV* tb
+Apd|void   |hv_undef   |NULLOK HV* tb
 ApP|I32|ibcmp  |NN const char* a|NN const char* b|I32 len
 ApP|I32|ibcmp_locale   |NN const char* a|NN const char* b|I32 len
 Apd|I32|ibcmp_utf8 |NN const char* a|char **pe1|UV l1|bool u1|NN 
const char* b|char **pe2|UV l2|bool u2
@@ -309,7 +309,7 @@ Ap  |void   |init_tm|struct tm *ptm
 pd |U32|intro_my
 ApPR   |char*  |instr  |NN const char* big|NN const char* little
 pR |bool   |io_close   |NN IO* io|bool not_implicit
-pR |OP*|invert |OP* cmd
+pR |OP*|invert |NULLOK OP* cmd
 dpR|bool   |is_gv_magical  |NN const char *name|STRLEN len|U32 flags
 ApR|I32|is_lvalue_sub
 ApPR   |U32|to_uni_upper_lc|U32 c
@@ -540,30 +540,30 @@ Apda  |SV*|newSVnv|NV n
 Apda   |SV*|newSVpv|const char* s|STRLEN len
 Apda   |SV*|newSVpvn   |const char* s|STRLEN len
 Apda   |SV*|newSVhek   |const HEK *hek
-Apda   |SV*|newSVpvn_share |const char* s|I32 len|U32 hash
+Apda   |SV*|newSVpvn_share |NULLOK const char* s|I32 len|U32 hash
 Afpda  |SV*|newSVpvf   |NN const char* pat|...
 Apa|SV*|vnewSVpvf  |NN const char* pat|NULLOK va_list* args
 Apda   |SV*|newSVrv|NN SV* rv|NULLOK const char* classname
 Apda   |SV*|newSVsv|NULLOK SV* old
-Apa|OP*|newUNOP|I32 type|I32 flags|OP* first
-Apa|OP*|newWHILEOP |I32 flags|I32 debuggable|LOOP* loop \
-   |I32 whileline|OP* expr|OP* block|OP* cont \
+Apa|OP*|newUNOP|I32 type|I32 flags|NULLOK OP* first
+Apa|OP*|newWHILEOP |I32 flags|I32 debuggable|NULLOK LOOP* loop \
+   |I32 whileline|NULLOK OP* expr|NULLOK OP* 
block|NULLOK OP* cont \
|I32 has_my
 Apa|PERL_SI*|new_stackinfo|I32 stitems|I32 cxitems
 Ap |char*  |scan_vstring  

Re: [PATCH] More embed.fnc notes, with new known errors!

2005-07-21 Thread Dave Mitchell
On Thu, Jul 21, 2005 at 04:06:49PM -0500, Andy Lester wrote:
 The functions that I broke are Perl_sv_vcatpvfn and Perl_sv_vsetpvfn.
 The SV **svargs parm now has a NN on it, meaning GCC will squawk at
 compile if a null is passed in, because the code refers to *args, which
 would be a NULL deref if args is NULL.  However, util.c has code that
 passes in hardcoded NULLs. :-(

My reading of the Perl_sv_vcatpvfn documenttaion (and reading of the code)
is that it's perfectly legit to pass a null svargs: one of other of args
or svargs should contain a value, but not both. Also, all *args derefs are
protected by an if(args).

Dave.

-- 
There's a traditional definition of a shyster: a lawyer who, when the law
is against him, pounds on the facts; when the facts are against him,
pounds on the law; and when both the facts and the law are against him,
pounds on the table.
-- Eben Moglen referring to SCO


Re: [PATCH] More embed.fnc notes, with new known errors!

2005-07-21 Thread Andy Lester
On Thu, Jul 21, 2005 at 11:10:51PM +0100, Dave Mitchell ([EMAIL PROTECTED]) 
wrote:
 My reading of the Perl_sv_vcatpvfn documenttaion (and reading of the code)
 is that it's perfectly legit to pass a null svargs: one of other of args
 or svargs should contain a value, but not both. Also, all *args derefs are
 protected by an if(args).

But not svargs.  See the line with sv_catsv(sv, *svargs);

xoxo,
Andy

-- 
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance


Re: [PATCH] More embed.fnc notes, with new known errors!

2005-07-21 Thread Dave Mitchell
On Thu, Jul 21, 2005 at 05:18:01PM -0500, Andy Lester wrote:
 On Thu, Jul 21, 2005 at 11:10:51PM +0100, Dave Mitchell ([EMAIL PROTECTED]) 
 wrote:
  My reading of the Perl_sv_vcatpvfn documenttaion (and reading of the code)
  is that it's perfectly legit to pass a null svargs: one of other of args
  or svargs should contain a value, but not both. Also, all *args derefs are
  protected by an if(args).
 
 But not svargs.  See the line with sv_catsv(sv, *svargs);

Yes, but it's still perfectly legal and ok to pass a hardcoded Null as the
svargs param (as long as args isn't also null), so delaring svargs as NN
is wrong.

-- 
This is a great day for France!
-- Nixon at Charles De Gaulle's funeral


Re: [PATCH] More embed.fnc notes, with new known errors!

2005-07-21 Thread Andy Lester
On Thu, Jul 21, 2005 at 11:45:54PM +0100, Dave Mitchell ([EMAIL PROTECTED]) 
wrote:
 Yes, but it's still perfectly legal and ok to pass a hardcoded Null as the
 svargs param (as long as args isn't also null), so delaring svargs as NN
 is wrong.

Understood.  Anyone see a way that we can eliminate that combination?
It'd be nice to have the compiler watch these things.

xoxo,
Andy

-- 
Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance