List Info

Thread: Re: Change 32136: Eliminate some uses of sv_setpv() where we already know the length.




Re: Change 32136: Eliminate some uses of sv_setpv() where we already know the length.
user name
2007-10-18 13:41:31
Nicholas Clark <nwc10+p5p4colon.colondot.net>
wrote:
> Change 32136 by nicholasnicholas-saigo on
2007/10/18 18:06:29
>
> ==== //depot/perl/gv.c#383 (text) ====
> Index: perl/gv.c
> --- perl/gv.c#382~32132~        2007-10-18
09:15:22.000000000 -0700
> +++ perl/gv.c   2007-10-18 11:06:29.000000000 -0700
>  -214,6 +214,7 
>      const U32 old_type = SvTYPE(gv);
>      const bool doproto = old_type > SVt_NULL;
>      const char * const proto = (doproto &&
SvPOK(gv)) ? SvPVX_const(gv) : NULL;
> +    const STRLEN protolen = proto ? SvCUR(gv) : 0;
>      SV *const has_constant = doproto &&
SvROK(gv) ? SvRV(gv) : NULL;
>      const U32 exported_constant = has_constant ?
SvPCS_IMPORTED(gv) : 0;
>
>  -280,8 +281,8 
>         CvFILE_set_from_cop(GvCV(gv), PL_curcop);
>         CvSTASH(GvCV(gv)) = PL_curstash;
>         if (proto) {
> -           sv_setpv((SV*)GvCV(gv), proto);
> -           Safefree(proto);
> +           sv_usepvn_flags((SV*)GvCV(gv), proto,
protolen,
> +                           SV_HAS_TRAILING_NUL);
>         }
>      }
>  }

This change generates the following compiler warning:

gv.c: In function `Perl_gv_init':
gv.c:284: warning: passing arg 3 of `Perl_sv_usepvn_flags'
discards
qualifiers from pointer target type

(Sorry, but I don't know the fix for it.)

Re: Change 32136: Eliminate some uses of sv_setpv() where we already know the length.
user name
2007-10-18 14:23:21
On Thu, Oct 18, 2007 at 02:41:31PM -0400, Jerry D. Hedden
wrote:

> This change generates the following compiler warning:
> 
> gv.c: In function `Perl_gv_init':
> gv.c:284: warning: passing arg 3 of
`Perl_sv_usepvn_flags' discards
> qualifiers from pointer target type
> 
> (Sorry, but I don't know the fix for it.)

Thanks, I also spotted it, although after I committed that
change.
It's irritating that gcc thinks that these are only
warnings. I'd like it
to treat them as errors. Fixed with the appended change.

Nicholas Clark

Change 32139 by nicholasnicholas-saigo on
2007/10/18 19:21:50

	Change 32136 introduced an error - passing a const char *
to
	sv_usepvn_flags(). Fixed.

Affected files ...

... //depot/perl/gv.c#384 edit

Differences ...

==== //depot/perl/gv.c#384 (text) ====

 -213,7
+213,7 
     dVAR;
     const U32 old_type = SvTYPE(gv);
     const bool doproto = old_type > SVt_NULL;
-    const char * const proto = (doproto &&
SvPOK(gv)) ? SvPVX_const(gv) : NULL;
+    char * const proto = (doproto && SvPOK(gv)) ?
SvPVX(gv) : NULL;
     const STRLEN protolen = proto ? SvCUR(gv) : 0;
     SV *const has_constant = doproto && SvROK(gv) ?
SvRV(gv) : NULL;
     const U32 exported_constant = has_constant ?
SvPCS_IMPORTED(gv) : 0;

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )