develooper Front page | perl.perl5.porters | Postings from April 2014

[perl #121747] [PATCH] Coverity: ptr values immediately discarded

Thread Previous
From:
Tony Cook via RT
Date:
April 28, 2014 04:56
Subject:
[perl #121747] [PATCH] Coverity: ptr values immediately discarded
Message ID:
rt-4.0.18-19046-1398661007-646.121747-15-0@perl.org
On Sat Apr 26 13:03:54 2014, jhi wrote:
> Attached.

--- a/toke.c
+++ b/toke.c
@@ -10398,7 +10398,7 @@ S_scan_inputsymbol(pTHX_ char *start)
 	    Copy("ARGV",d,5,char);
 
 	/* Check whether readline() is overriden */
-	gv_readline = gv_fetchpvs("readline", GV_NOTQUAL, SVt_PVCV);
+	gv_fetchpvs("readline", GV_NOTQUAL, SVt_PVCV);
 	if ((gv_readline = gv_override("readline",8)))
 	    readline_overriden = TRUE;
 

I think that line can just be removed.  The first thing gv_override() does is:

    GV *gv = gv_fetchpvn(name, len, GV_NOTQUAL, SVt_PVCV);

--- a/x2p/a2py.c
+++ b/x2p/a2py.c
@@ -70,7 +70,7 @@ main(int argc, const char **argv)
 
     myname = argv[0];
     linestr = str_new(80);
-    str = str_new(0);		/* first used for -I flags */
+    str_new(0);		/* first used for -I flags */
     for (argc--,argv++; argc; argc--,argv++) {
 	if (argv[0][0] != '-' || !argv[0][1])
 	    break;

Should simply be removed, str_new() is an allocator that pulls from a free list if it can.

--- a/x2p/walk.c
+++ b/x2p/walk.c
@@ -254,7 +254,7 @@ sub Pick {\n\
 	break;
     case OHUNK:
 	if (len == 1) {
-	    str = str_new(0);
+	    str_new(0);
 	    str = walk(0,level,oper1(OPRINT,0),&numarg,P_MIN);
 	    str_cat(str," if ");
 	    str_scat(str,fstr=walk(0,level,ops[node+1].ival,&numarg,P_MIN));

Again.

@@ -264,7 +264,7 @@ sub Pick {\n\
 	else {
 	    tmpstr = walk(0,level,ops[node+1].ival,&numarg,P_MIN);
 	    if (*tmpstr->str_ptr) {
-		str = str_new(0);
+		str_new(0);
 		str_set(str,"if (");
 		str_scat(str,tmpstr);
 		str_cat(str,") {\n");

This one looks wrong - str is used on the next line.

Tony

---
via perlbug:  queue: perl5 status: new
https://rt.perl.org/Ticket/Display.html?id=121747

Thread Previous


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